How 4rgc/trellzo-backend works
Main Components
• API Service: This is contained within the “api” folder and provides the core business logic. It is divided into controllers, models, routes, schemas, and various utilities (e.g., JWT, crypt, mongoUrl).
• Database Service: Provided by the MongoDB container (under “mongo”) with seed scripts and configuration files.
• HTTPS Proxy: An Nginx-based proxy provided in the “https-proxy” folder. It acts as the entry point for secure client connections.
• Docker and Orchestration: Dockerfiles, docker-compose files, and scripts indicate that each service (API, MongoDB, Proxy) is containerized. These containers form the deployment unit when running the system.
• Deployment/CI Pipeline: The .github workflows show that continuous integration, delivery, and dependency management tasks are automated.
Relationships and Interactions
• Clients (web or mobile apps) will send requests to the secured endpoint (https://localhost). These requests are handled by the HTTPS proxy.
• The HTTPS proxy routes incoming traffic to the API server where the Routing layer (inside “api/src/routes”) directs requests to the appropriate controllers.
• Controllers use middleware for tasks like request validation (see “middleware/validateRequest.ts”), and delegate data operations to the data-controllers and models.
• The API service communicates with the MongoDB database (using connection settings from “api/src/util/mongoUrl.ts”) to read or write data.
• Docker-compose orchestrates starting/updating these services together, so the proxy, API, and MongoDB containers are connected in the network environment.
Architectural Patterns and Design Principles
• MVC-like Pattern: Although it’s an API, the project separates responsibilities between controllers (handling HTTP requests), models (business data representation), and schemas (data validation).
• Containerization & Microservice Approach: Services are built, deployed, and managed independently as Docker containers.
• Security: The use of HTTPS proxy and JWT-based authentication (see “api/src/util/jwt.ts”) is vital for secure communications.