How nnminh-sam/competitive-contest-utils-server works
This project is a backend application built using the NestJS framework in TypeScript. The file tree and README indicate that it’s a modular, server-side application designed following the NestJS patterns, and it includes multiple features such as authentication, contest management, mailing, and more.
Overall Project Type and Purpose
• Recognize that this is a NestJS-based server-side application.
• The project uses a modular architecture with clearly defined modules (auth, contest, contestant, affiliation, team, mailing) that encapsulate specific domains.
• It integrates with external services like Redis (used in the database provider) and is containerized (docker-compose.yml is present), indicating a production-ready, scalable back-end system.
Breakdown of the File Structure
• The top-level directories/files include configuration files (e.g., .eslintrc.js, .prettierrc, docker-compose.yml), project metadata (README.md, package.json), and TypeScript configuration files (tsconfig.json, tsconfig.build.json).
• The application’s core resides in the src directory:
○ src/main.ts – the entry point.
○ src/app.module.ts – the root module where all other modules are imported.
• Various feature modules exist under src/modules (affiliation, auth, contest, contestant, mailing, team), each containing its own controller, service, and DTOs.
• There is a “common” directory which includes decorators, DTOs, filters, guards, interceptors, and pipes that provide cross-cutting concerns.
• The “database” directory shows how the application interacts with the persistence layer, including a custom Redis provider.
• Directories like “environment” help manage configuration and environmental variables.
Components to Highlight
a. Core Application Setup:
– An “Entry Point” or “Bootstrap Layer” showing src/main.ts initializing the NestJS application.
– The “App Module” as the central hub, which imports all feature modules.
b. Feature Modules:
– Separate modules such as:
• Auth Module: Handling user authentication with controllers, services, DTOs, and strategies (JWT & Local).
• Contest Module: Managing contest-related functionalities.
• Contestant Module: Handling registrations and contestant data.
• Affiliation Module: Managing affiliations.
• Team Module: Managing team data.
• Mailing Module: Responsible for email integrations.
c. Common/Shared Components:
– Shared functionalities (e.g., decorators, pipes, filters, interceptors) that provide standardized behavior across modules.
d. Infrastructure/External Services:
– Database Layer: Illustrate the “database” module, highlighting Redis integration.
– Environment Module: Show how application configuration is handled.
– Docker Compose: Indicate that the application is containerized and can interact with other services via Docker.
Relationships & Interactions
– The entry point (main.ts) initializes the App Module.
– The App Module imports and wires together all other modules.
– Controllers in each module interact with their corresponding services.
– Business logic resides in services, which may communicate with the database (Redis via redis.provider.ts, redis.service.ts).
– Shared middleware and guards (like JWT.guard.ts and local.guard.ts in the auth module) intercept and secure request flows.
Architectural Patterns and Technologies
• Modular approach inherent to NestJS — each domain (module) encapsulates its own controllers, services, and DTOs.
• Separation of concerns with common utilities (decorators, pipes) abstracted in a “common” folder.
• How dependency injection is used throughout the application.
• Use of microservices concepts if applicable (or simply distinct modules that can be scaled or refactored independently).