How snack-25/back works
Overall Project Type and Purpose
• SNACK25 is a backend service built with NestJS for a one-stop snack purchasing management solution. Its purpose is to manage snack-related transactions and data in an organized and secure manner.
• The README confirms that the back-end leverages NestJS with a robust modular design, integrates with a PostgreSQL database (via Prisma), includes authentication (with JWT and Argon2), and utilizes Swagger for API documentation.
Main Components
a. Application Entry Point & Core Infrastructure
• Main entry (main.ts) that bootstraps the NestJS application.
• Global configurations (nest-cli.json, tsconfig, etc.) which affect the overall behavior.
b. Modular Domain Components (as individual blocks)
• Auth Module: Contains controllers, services, DTOs, strategies (JWT, guards) for managing authentication and authorization.
• Budgets, Carts, Categories, Companies, Invitations, Order Requests, Orders, Products, Users, and Wishlists Modules: Each domain module has its own controller, service, DTOs, and entity definitions. Outline these as separate components to show separation of concerns.
c. Shared Infrastructure and Services
• Shared Module: Include general utilities, helper functions, middleware, decorators, and any shared constants.
• AWS S3 Integration: Within the shared/aws directory, highlight that there is a dedicated S3 service and controller for managing file uploads/storage.
• Prisma Module: Clearly mark the Prisma integration (from both the prisma directory and shared/prisma) used for database access, including migration management and seed operations.
d. External Interfaces and Tools
• Database: Represent PostgreSQL as the primary persistence layer. Connect Prisma’s ORM functionality to it.
• API Documentation: Include Swagger as an external API documentation tool available via the /api route.
• CI/CD / Deployment: Optionally note the presence of GitHub workflows and Husky hooks that manage coding standards and deployment tasks.
Relationships and Interactions
• Auth components (controllers, guards, JWT strategies) to other modules where secure endpoints require authentication.
• That the shared services (for JWT, AWS S3, etc.) are used by multiple modules, denoting cross-module dependencies.
Architectural Patterns and Design Principles
• Modular structure of NestJS. Label groups as individual domain “modules” and highlight the Separation of Concerns between controllers (handling incoming requests), services (business logic), and Prisma (data access).
• A “Presentation Layer” for API controllers.
• A “Business Logic Layer” for services.
• A “Data Access Layer” for Prisma and the PostgreSQL database.
• “Infrastructure/Integration Components” for shared utilities (AWS S3, authentication, Swagger).
Final Assembly
• Start at the top with the application’s entry point, cascade into the separate modules, and finally point the modules’ interactions with both the PostgreSQL (via Prisma) and external integration services (AWS, Swagger).