How marcelotadini/scoders-back works
Project type and purpose
• This is a NestJS-based server-side application written in TypeScript. It exposes REST endpoints (via Controllers) and a WebSocket gateway for real-time communication, implements authentication, user management, and product management, and persists data in MongoDB via Mongoose.
File structure to uncover architectural choices
• Top-level “src” folder broken into feature modules: auth/, user/, product/, plus shared/ for cross-cutting concerns.
• Each feature module follows the “Controller → Service → Repository” pattern and houses DTOs, schemas, and (in product/) a WebSocket gateway.
• Global pipes, filters, interceptors, and guards live in shared/.
• Configuration files (nest-cli.json, tsconfig.json, Dockerfile) enable build, linting, formatting, containerization, and CI/CD (via .github/workflows/main.yml).
README for tech stack
• NestJS framework (Express by default), TypeScript, Mongoose (MongoDB), Docker, GitHub Actions.
• Testing harness: Jest for unit and e2e tests.
• Validation pipe uses Zod under the hood.
Main components
a. NestJS HTTP Server (Express/Fastify adapter)
b. Middleware & Global Utilities
• Redoc middleware (serves API docs)
• HTTP exception filter
• Logging interceptor
• Cache interceptor
• Zod validation pipe
• Auth guard
c. Feature Modules (loaded into Nest’s DI container)
• AuthModule (AuthController → AuthService)
• UserModule (UserController → UserService → UserRepository)
• ProductModule (ProductController, ProductGateway → ProductService → ProductRepository)
d. Data Layer
• Repositories using Mongoose
• MongoDB database (collections: users, products)
e. External & DevOps
• Docker container
• CI/CD pipeline (GitHub Actions)
• Prettier, ESLint, Nest CLI
Interactions & Data Flow
• REST flow: Client → HTTP Server → (Middleware → Guard → Interceptor → Pipe) → Controller → Service → Repository → MongoDB → Service → Controller → HTTP Response
• WebSocket flow: Client WS → ProductGateway → ProductService → ProductRepository → MongoDB → ProductGateway (Broadcast)
• CI/CD: Commits → GitHub Actions → Docker build → Test suite → Push image to registry
Architectural patterns & principles
• Modular Monolith: logically separated modules, single process
• Dependency Injection: all controllers/services/repositories injected by Nest
• Layered Architecture: Presentation (HTTP/WS) → Business (Services) → Data (Repositories)
• Cross-cutting concerns centralized in shared/
Essential elements
• A middleware/interceptor pipeline in front of controllers
• Authentication guard sitting between middleware and controllers
• Docker boundary around the NestJS application
• CI/CD flow upstream of container build