This is a full-stack application for a "Spin the Wheel" game built using React (frontend), Node.js/Express (backend), and Prisma (ORM) connected to a MySQL database hosted on a service provider like Aiven. The application allows users to input the number of segments on the wheel and the content of each segment. When the wheel is spun, a segment is randomly selected, and the result is saved to the database.
- Users can define the number of segments on the wheel.
- Users can enter the content for each segment.
- When the wheel is spun, a segment is randomly selected.
- The result of each spin is saved to a MySQL database using Prisma.
- Node.js and npm installed
- MySQL database (local or hosted, e.g., Aiven)
- Prisma CLI installed
git clone https://github.com/ShivankK26/Spin-Wheel-Game.git
Navigate to the client
directory and install the dependencies:
cd client
npm install
Navigate to the server
directory and install the dependencies:
cd ../server
npm install
Initialize Prisma and set up the MySQL connection:
npx prisma init
Create a .env
file in the server
directory and add your database connection string:
DATABASE_URL="mysql://username:password@hostname:port/database_name"
Replace username
, password
, hostname
, port
, and database_name
with your MySQL service details.
Generate and run the migration to create the database schema:
npx prisma migrate dev --name init
npx prisma generate
node index.js
The server will start running on port 5173.
Navigate back to the client
directory and start the React development server:
cd ../client
npm run dev
The client will start on port 3000.
To connect the MySQL database to Aiven:
-
Create a MySQL service on Aiven.
-
Obtain the connection details from Aiven.
-
Update the
.env
file with the Aiven connection details:DATABASE_URL="mysql://username:password@aiven-hostname:port/database_name"
Replace username
, password
, aiven-hostname
, port
, and database_name
with your Aiven service details.