This is the backend for the Online Card Game project, built using Node.js, Strapi, and PostgreSQL. The backend handles game logic, player authentication, and data management. It is designed to work seamlessly with the game's frontend.
- Features
- Technologies
- Requirements
- Installation
- Environment Variables
- Database Setup
- Running the Project
- Deployment
- License
- User authentication and management
- Game session management
- RESTful API for the game frontend
- Admin panel for managing game data (powered by Strapi)
- Secure JWT-based authentication
- Integration with PostgreSQL database
- Node.js: Backend server runtime
- Strapi: Headless CMS for managing content and data
- PostgreSQL: Relational database management system
- Docker: Containerization of the application for consistent development and production environments
Before you begin, ensure you have met the following requirements:
- Node.js (>= 14.x)
- Docker and Docker Compose
- PostgreSQL (if not using Docker)
- Yarn (Package Manager)
-
Clone the repository:
git clone https://github.com/yourusername/online-card-game-backend.git cd online-card-game-backend -
Install dependencies:
yarn install
Create a .env file in the root directory and add the following environment variables:
NODE_ENV=production
DATABASE_CLIENT=postgres
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_NAME=onlinecardgame
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=yourpassword
DATABASE_SSL=false
JWT_SECRET=your_jwt_secret
ADMIN_JWT_SECRET=your_admin_jwt_secret
PUBLIC_URL=your_production_url
PROJECT_SLUG=onlinecardgameReplace the placeholders with your actual configuration.
If using Docker, the PostgreSQL database will be set up automatically. If running locally:
-
Ensure PostgreSQL is installed and running.
-
Create a new database with the name specified in your
.envfile.createdb onlinecardgame
To run the project in development mode:
cd backend
yarn developThis will start the Strapi server and provide access to the admin panel.
To build and run the project in production:
cd backend
yarn build
yarn start-
Push your code to GitHub.
-
Connect your GitHub repository to Render.
-
Set environment variables in the Render dashboard.
-
Use the following build and start commands in Render:
- Build Command:
yarn --frozen-lockfile install; yarn build - Start Command:
yarn start
- Build Command:
-
Push your code to GitHub.
-
Connect your GitHub repository to Railway.
-
Set environment variables in the Railway dashboard.
-
Use the following build and start commands in Railway:
- Build Command:
yarn --frozen-lockfile install; yarn build - Start Command:
yarn start
- Build Command:
This project is licensed under the MIT License - see the LICENSE file for details.
You can copy this file directly to your GitHub repository.