How jjikky/cs-hub-be works
Project Type and Purpose
• This is a backend API server built with NestJS following a modular, layered (Domain-Driven) monolithic architecture.
• Purpose: Provide RESTful endpoints for CS Hub features—authentication (with JWT and Kakao OAuth), user management, quizzes, point tracking, and ranking.
• Data persistence with PostgreSQL via TypeORM, deployable with Docker/PM2, supporting seed scripts and e2e tests.
File-Structure Analysis
• Top-level config: Dockerfile, docker-compose.yml, ecosystem.config.js (PM2), GitHub workflows.
• src/app.module.ts wires submodules.
• common/: shared constants, DTOs, decorators, middleware, interceptors.
• config/: configuration modules (app, auth, swagger).
• database/: TypeORM data-source, config, seed modules.
• modules/: one folder per domain (auth, user, quiz, point, ranking), each following subfolders:
• presentation (controllers)
• application (services)
• domain (entities, value objects, repository interfaces)
• infrastructure (TypeORM entities, repository implementations, external clients)
• utils/: config validation.
• test/: e2e tests.
Key Architectural Patterns
• Modular Monolith: each feature as its own module.
• Layered Architecture: presentation → application (use-cases) → domain → infrastructure (data access).
• Dependency Injection via NestJS.
• External OAuth integration (Kakao).
• Configuration management with @nestjs/config.
• Database seeding pipeline.
Main Components & Interactions
A. Client
• Web or mobile frontend, or any HTTP client.
B. API Gateway (NestJS Server)
• HTTP Controllers receive requests.
• Middleware (logger), Guards (JWT), Interceptors (transform responses).
• Module Boundaries: auth, user, quiz, point, ranking.
C. Application Layer
• Business logic encapsulated in Services.
D. Domain Layer
• Core entities, value-objects, domain rules, repository interfaces.
E. Infrastructure Layer
• TypeORM entities & repositories → PostgreSQL.
• External HTTP client for Kakao OAuth.
F. Data Store
• PostgreSQL database.
G. Deployment/DevOps
• Docker container, Docker Compose network, PM2 process manager.
• CI/CD pipeline via GitHub Actions.
Architectural Patterns & Design Principles
• Single Responsibility per module.
• Clear separation of concerns: controllers (HTTP), services (business logic), repositories (data access).
• Dependency Inversion: modules depend on abstractions (interfaces) not implementations.
• Configuration injected at runtime via config modules.
• Use middleware/interceptors for cross-cutting concerns (logging, error handling).
• Seed data orchestration separate from main flow.