How luansmelo/e-paper works
Project type and purpose
• e-paper is a Dockerized NestJS backend service for document management, exposing a REST API documented via Swagger and storing metadata in PostgreSQL and files in MinIO.
File structure
• Top-level orchestration: Dockerfile, docker-compose.yml, start.sh
• src/main.ts + app.module.ts: application bootstrap & global config (Swagger, Zod)
• src/presentation: Controllers (HTTP endpoints), filters, interceptors, OpenAPI schemas
• src/application: Use-case classes, DTOs, ts-rest contracts, Zod schemas
• src/domain: Core entities and repository interfaces (hexagonal core)
• src/infrastructure:
• database/drizzle: Drizzle ORM service + repository implementations
• database/in-memory: In-memory repos for testing
• migrations: SQL and snapshots
• ioc modules: NestJS DI for database & document modules
• Configuration: src/config (global, Swagger, Multer-S3)
Diagramming the architecture
a. Main components (top-level “containers”)
• API Service (NestJS application)
• PostgreSQL database
• MinIO object storage
• (Optional) API client / Swagger UI
b. Layers inside the API Service
• Presentation Layer: HTTP Controllers → Validation (nestjs-zod)
• Application Layer: Use Cases (add, load, update, delete, upload)
• Domain Layer: Entities + Repository Interfaces (ports)
• Infrastructure Layer:
– Repository Adapters (Drizzle/Postgres, In-Memory)
– File Storage Adapter (Multer-S3 → MinIO)
• Bootstrapping & Configuration Modules
c. Data flow & interactions
• HTTP Request → Controller → DTO/Zod Validation → Use Case
• Use Case → Domain Entity Logic → Repository Interface → Drizzle Adapter → PostgreSQL
• File Upload Use Case → File Validation Interceptor → Multer-S3 Config → MinIO → URL returned → persisted in DB
• Swagger Module serves OpenAPI at /api via ts-rest contracts
d. Architectural patterns & technologies
• Hexagonal (Onion) Architecture: clear separation of concerns by layer
• Dependency Injection via NestJS modules
• Drizzle ORM for type-safe DB access
• Zod & nestjs-zod for runtime validation + type inference
• ts-rest for synchronized contracts + API docs
Essential elements
• Clear labels for containers, layers, modules, external services
• Call out the bootstrap sequence (main.ts → app.module → modules)