This is a NestJS-based project for creating a gamification system. The system includes modules for user management, authentication, game management, challenges, achievements, and leaderboards.
- User Authentication: Secure authentication using JWT.
- User Management: Manage user profiles and scores.
- Game Management: Create and manage games and levels.
- Challenges: Create and manage challenges for users to complete.
- Achievements: Award achievements and badges to users.
- Leaderboards: Display and manage leaderboards based on user scores.
- NestJS: A progressive Node.js framework for building efficient and scalable server-side applications.
- TypeScript: A typed superset of JavaScript that compiles to plain JavaScript.
- TypeORM: An ORM for TypeScript and JavaScript.
- Passport: Authentication middleware for Node.js.
- JWT (JSON Web Tokens): A compact, URL-safe means of representing claims to be transferred between two parties.
To install and run this project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/gamification-system.git cd gamification-system
-
Install dependencies:
npm install
-
Set up the environment variables:
Create a
.env
file in the root of your project and add the necessary environment variables (see Environment Variables). -
Run database migrations (if necessary):
npm run typeorm migration:run
-
Start the application:
npm run start
The application will run on
http://localhost:3000
.
You need to set up a .env
file with the following variables:
# Database settings
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=myuser
DB_PASSWORD=mypassword
DB_NAME=mydatabase
# JWT settings
JWT_SECRET=mySuperSecretKey
JWT_EXPIRES_IN=3600s
You can interact with the API using tools like Postman or cURL. Below are some of the available endpoints:
-
Auth Module:
POST /auth/login
: Log in a user and receive a JWT.POST /auth/register
: Register a new user.
-
User Module:
GET /user
: Get a list of users.GET /user/:id
: Get a specific user by ID.PATCH /user/:id
: Update user information.DELETE /user/:id
: Delete a user.
-
Game Module:
POST /game
: Create a new game.GET /game
: Get a list of games.PATCH /game/:id
: Update a game.DELETE /game/:id
: Delete a game.
-
Challenge Module:
POST /challenge
: Create a new challenge.GET /challenge
: Get a list of challenges.PATCH /challenge/:id
: Update a challenge.DELETE /challenge/:id
: Delete a challenge.
-
Achievement Module:
POST /achievement
: Create a new achievement.GET /achievement
: Get a list of achievements.PATCH /achievement/:id
: Update an achievement.DELETE /achievement/:id
: Delete an achievement.
-
Leaderboard Module:
GET /leaderboard
: Get the leaderboard.
Handles user authentication and authorization using JWT. It includes login, registration, and token validation functionality.
Manages user data including profiles and scores. Users are stored in a relational database with TypeORM.
Handles the creation and management of games and their levels. Each game can have multiple levels or stages.
Manages challenges within the system. Challenges are tasks or missions that users need to complete to earn rewards.
Tracks and awards achievements or badges to users. Achievements can be tied to specific actions or milestones within the system.
Displays user rankings based on scores. The leaderboard updates dynamically as users' scores change.
This project is licensed under the MIT License. See the LICENSE file for details.