How fabianosl1/api-plans works
Project type and purpose
• This is a single‐service RESTful API (a backend microservice) for managing “plans” and “products,” built with Nest.js, TypeScript and Prisma.
• It follows a Hexagonal (Ports & Adapters) architecture, keeping the domain model isolated from framework and infrastructure concerns.
File structure
• Top-level:
• src/ – application code
• prisma/ – schema and migrations for the database
• docs/ – Postman/Hoppscotch collection
• Dockerfile, docker-compose.yml, entrypoint.sh – containerization and orchestration
• Inside src/: three main modules:
• auth/ – authentication logic
• plans/ – business logic around plans/products
• shared/ – cross-cutting concerns (exceptions, filters, middleware, common services)
• Each module substructure:
• application/ – DTOs and use-case classes
• domain/ – entities and repository interfaces (contracts)
• infra/ – controllers, Nest modules, and concrete repository implementations
• test/ – unit tests for use cases
Insights from the README
• Confirms Hexagonal layering: application, domain, infra separated per module
• Tech stack: Nest.js, Prisma, Docker, Jest/Supertest, GitHub Actions, SonarQube
• Endpoints documented in docs/api-collection.json
Main components & their interactions
a. Client(s) (Postman, browser, other services)
→ HTTP requests over REST
b. NestJS Application (Docker container)
• Controllers (infra layer) receive HTTP calls
• Controllers invoke Use-Case classes (application layer)
• Use-Cases operate on Domain Entities and depend on Repository interfaces (domain layer)
• Repository implementations (infra/adapters) use PrismaService to talk to the database
• Shared middleware (e.g., auth.jwt middleware) and filters handle cross-cutting concerns
c. Database (PostgreSQL managed by Prisma)
d. External services (JWT provider within shared infra, Render for hosting)
Architectural patterns & design principles
• Hexagonal Architecture (Ports & Adapters)
• Clear separation of concerns: controllers ⟷ use-cases ⟷ domain ⟷ adapters
• Dependency Inversion: use-cases depend on abstract repository interfaces
• Module‐based organization: auth, plans, shared