How poleeast/pinpin_backend works
Project Type and Purpose
• Type: Backend REST API server built with NestJS (Node.js + TypeScript).
• Purpose: CRUD and business logic around users, user profiles, categories, travel-interest data, with JWT-based authentication and file uploads via Cloudinary.
• Key features:
– Modular controllers/services/repositories
– JWT auth (guard + strategy)
– TypeORM entities & custom repositories
– External Cloudinary integration
Main Architectural Layers
a. Presentation Layer
– Controllers (HTTP endpoints)
– Global filters & interceptors for error handling and standardized API responses
b. Application Layer
– Services (business logic) in each module (user, userProfile, category, cloudinary)
c. Domain/Infrastructure Layer
– Entities (TypeORM)
– Repositories (custom TypeORM repositories)
– Database (SQL)
– External services (Cloudinary)
Primary Components
1. Client(s)
– Mobile/Web clients invoking HTTP endpoints
2. API Gateway / NestJS HTTP Server
– Main entrypoint (src/main.ts → app.module)
– global_exception.filter, api_responses.decorator
3. Authentication Subsystem
– jwt.strategy.ts
– jwt.guard.ts
– user module (login/signup)
4. Modules
– UserModule (controllers, services, repos, entities)
– UserProfileModule
– CategoryModule
– CloudinaryModule
5. Database
– SQL database (tables based on entities in src/entities)
– db預設資料.sql seed data
6. External Service
– Cloudinary (image uploads)
Relationships and Data Flow
• Client → HTTP Request → NestJS Controller
• Controller → Service (injects repositories)
• Service → Repository → Database
• Service → External (Cloudinary)
• Auth Flow:
– Client sends JWT in header → jwt.guard → jwt.strategy validates → request.user populated
• Response: Service returns DTO → Controller returns HTTP response (with api_responses decorator)
Architectural Patterns & Principles
• Layered Architecture (Controller → Service → Repository → DB)
• Dependency Injection (Nest providers in modules)
• Modularization (each domain in its own module folder)
• Single Responsibility (separate decorator, filter, guard, util classes)
• Repository Pattern (custom TypeORM repositories)