Code Monkey home page Code Monkey logo

shivankk26 / spin-wheel-game Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 66 KB

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.

JavaScript 89.79% HTML 4.05% CSS 6.17%
aiven-cloud expressjs javascript mysql nodejs prisma-orm react

spin-wheel-game's Introduction

Spin the Wheel Game

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.

Features

  • 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.

Prerequisites

  • Node.js and npm installed
  • MySQL database (local or hosted, e.g., Aiven)
  • Prisma CLI installed

Setup Instructions

1. Clone the Repository

git clone https://github.com/ShivankK26/Spin-Wheel-Game.git

2. Set Up the Client

Navigate to the client directory and install the dependencies:

cd client
npm install

3. Set Up the Server

Navigate to the server directory and install the dependencies:

cd ../server
npm install

4. Configure Prisma

Initialize Prisma and set up the MySQL connection:

npx prisma init

5. Set Up Environment Variables

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.

6. Run Prisma Migrations

Generate and run the migration to create the database schema:

npx prisma migrate dev --name init
npx prisma generate

7. Start the Server

node index.js

The server will start running on port 5173.

8. Start the Client

Navigate back to the client directory and start the React development server:

cd ../client
npm run dev

The client will start on port 3000.

Connecting to Aiven

To connect the MySQL database to Aiven:

  1. Create a MySQL service on Aiven.

  2. Obtain the connection details from Aiven.

  3. 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.