Red-Steam Backend
This repository contains the backend for the Red-Steam project, built with NestJS. It provides the API endpoints for user authentication, game management, and more.
Features
- Secure Authentication: JWT-based authentication with access and refresh tokens, including role-based - authorization and token blacklisting.
- RESTful API: Designed for comprehensive game and user management.
- Modular Architecture: Built with NestJS and TypeORM for scalable, maintainable server-side development.
- Game Media Management: Backend logic for serving and organizing media assets using Dropbox integration and database management.
- Payment Gateway Integration: Secure PayPal sandbox integration for processing game purchases.
- Advanced Security: ReCAPTCHA protection, cookie management with CSRF protection, and custom-built guards.
- Custom Middleware & Logging: Used for authentication, request handling, and efficient structured logging.
- Interceptors & Filters: Custom logic for request transformation and detailed error handling.
- Custom Decorators & DTOs: Reusable code for cleaner and more maintainable logic, with data validation and transformation.
- Cache Management (Work in Progress): Implements caching strategies using Redis for performance optimization.
- Media Uploads & File Handling: Upload and manage media assets like images and videos.
- API Documentation: Integrated Swagger UI for comprehensive API documentation.
- Automated Documentation: Generates detailed, interactive documentation for the project using Compodoc.
- TypeScript: Ensures type safety and enhances maintainability for scalable development.
Technologies
- NestJS: Framework used for building efficient, scalable, and maintainable server-side applications.
- TypeORM: ORM for PostgreSQL, enabling simplified database management and seamless integration with the app.
- PostgreSQL: Manages entities such as Companies, Games, Features, Languages, Tags, and Users.
- MongoDB: Handles JWT token blacklisting and Dropbox access token expiration.
- JWT: Provides secure authentication and role-based authorization.
- Dropbox: Used as a free cloud storage solution for managing media assets, balancing cost and load times.
- Redis: Used for cache management to optimize performance (Work in Progress).
- ReCAPTCHA: Integrates with forms and endpoints for protection against spam and automated abuse.
- Google SMTP: Used for sending email notifications, password recovery, and checkout receipts.
- TypeScript: Ensures type safety and better maintainability during development.
Installation
Prerequisites
Steps
-
Clone the repository:
git clone https://github.com/IbrahemHadidy/red-steam-backend.git
cd red-steam-backend
-
Install dependencies:
pnpm install
-
Set up environment variables:
- Navigate to
src/common/configs/environments/ and copy the content of sample.env into a new file called .env.local.
-Fill in the required values.
-
Run the redsteam.sql script:
-
Run the development server:
pnpm start:dev
-
Access the API documentation (Swagger) at http://localhost:5000/api.
Database Migration
To run TypeORM migrations:
pnpm typeorm migration:run
Build for Production
Build the application:
pnpm build
Start the production server:
pnpm start:prod
Testing
This project includes integration and E2E tests for verifying the application's behavior. Currently, there are no unit tests, and the testing suite is incomplete and may contain issues.
Running Tests
To run the integration tests, use the following command:
pnpm run test
To run the E2E test, use:
pnpm run test:e2e
Documentation
This project uses Compodoc to generate detailed and interactive documentation.
To generate the documentation, run:
pnpm compodoc
Once generated, you can access the documentation in the documentation folder within the project.
Future Plans
If the project continues, the following features are planned for potential development:
- Enhanced Security: Improved security measures including OTP services for secure logins, phone number verification, and transaction authentication.
- Cache Management: Implement caching strategies with Redis to optimize performance.
- GraphQL Support: Adding a GraphQL API for more flexible data queries.
- WebSockets Integration: Real-time updates for user interactions and notifications.
- Advanced Logging: Incorporation of a more robust logging system for better monitoring and debugging.
- API Rate Limiting: Adding API rate limiting to prevent abuse and ensure fair usage.
- CDN Integration: Implementing a Content Delivery Network (CDN) to distribute media assets, replacing traditional cloud storage. This change will enhance load times and improve the overall user experience by ensuring faster and more reliable access to content.
Note: This list is not exhaustive, and additional features may be added as the project evolves.