How ryguigas0/espm-bubble-mvp-backend works
Project Type & Purpose
• This is a Node.js/TypeScript backend monolith built with NestJS that exposes RESTful APIs for user management, events, and event attendance.
• It uses JWT for authentication, MongoDB (via Mongoose) for data storage, and is containerized via Docker/Docker Compose.
File Structure
• Top-level concerns:
• Dockerfile, docker-compose.yaml & dev-compose.yaml (container definitions)
• .env.example (environment variables)
• src/ (application code)
• test/ (end‐to‐end tests)
• src/ subdirectories map one‐to‐one to NestJS modules:
• src/auth – authentication + guards + login DTOs
• src/users – user CRUD, DTOs, Mongoose schemas
• src/events – event CRUD, DTOs, Mongoose schemas
• src/user-events – user attendance endpoints + DTOs
• src/config – centralized config for JWT & Mongo
• src/app – root AppModule + global controller/service
• src/util – request helpers, shared schemas
• Each module follows Nest’s Layered Pattern: Controller → Service → Mongoose Model (schema).
Extract Key Insights from README
• Modern framework (NestJS), JWT auth, MongoDB + Mongoose, Docker support, linting/formatting with ESLint/Prettier.
• Dev vs. full-stack compose files: dev-compose.yaml (Mongo + Mongo-Express) vs. docker-compose.yaml (entire stack).
a. Main Components
• Client(s) (e.g., Insomnia, any front-end)
• API Gateway – NestJS HTTP server (single Docker container)
– Subcomponents (modules):
· AuthModule (login, JWT guard)
· UsersModule (user profiles, friends, block)
· EventsModule (create/update events)
· UserEventsModule (attend/unattend events)
· ConfigModule (env management)
• Database Tier
– MongoDB (primary data store)
– Mongo-Express (admin UI)
• DevOps / Infrastructure
– Docker daemon & Docker Compose orchestrating three containers:
· bubble-backend (built from Dockerfile)
· mongo-db
· mongo-express
b. Relationships & Data Flows
1. Client → HTTP(S) → NestJS Controllers
2. Controllers → Services (business logic)
3. Services → Mongoose Models → MongoDB
4. AuthGuard intercepts protected routes, validates JWT via AuthService
5. ConfigService injects environment variables into modules
6. Docker Compose networking: backend ↔ mongo via internal bridge; mongo-express ↔ mongo
c. Architectural Patterns & Principles
• Modular Monolith (Nest modules)
• Layered Architecture (Controller → Service → Data Access)
• Dependency Injection (built into NestJS)
• 12-Factor App principles (config via ENV, containerization)
d. Key Technologies
• NestJS & TypeScript
• Mongoose + MongoDB
• JSON Web Tokens for auth
• Docker & Docker Compose
• ESLint & Prettier for code quality