How julianbesteiro/deliverit-back works
Project Type & Purpose
• The project is a back-end service for a package distribution application. It is designed for a package distribution company; with distinct roles for package delivery drivers and administrators.
• The system uses NodeJS, Express, and TypeScript. It is containerized (Docker, EKS manifests) and follows a GitFlow branching strategy.
• The application handles functionalities such as delivery order management, route scheduling, and real-time updates on deliveries.
File Structure Analysis
• Major top-level directories:
• “src”: This contains core application code (controllers, models, services, repositories, middlewares, routes, schemas, config).
• “config”: Holds environment-specific configurations like development, production, and swaggerOptions (API documentation).
• “db”: Contains database configuration/setup scripts.
• “tests”: Contains unit, integration, and end-to-end tests.
• “dist”: Build output reflecting the compiled JavaScript files.
• Deployment-related files: Dockerfile, docker-compose.yml, and folders like “eks” and “.github/workflows” for CI/CD.
• The clear MVC-like pattern emerges with:
• Routes and Controllers managing HTTP requests.
• Services encapsulating business logic.
• Repositories handling data persistence.
• Middleware to intercept and process requests (error handling, authorization checks).
a. Main Components:
• Client/API Gateway: Although the front-end is not part of this repository, the API is exposed through Express routes.
• Express Server: The entry point (src/server.ts) where the Express app is configured.
• Controllers: Including admin, delivery, order, sworn, and user controllers, which receive API requests.
• Middlewares: Authentication (isAuth), authorization (isAdmin), error handling, and other pre-controller functions.
• Services: Modules that implement the core business logic (admin, delivery, order, user, sworn services).
• Repositories: Handle data interactions with the database (admin, delivery, order, user, sworn repositories).
• Models & Schemas: Define the data objects handled by the application (Delivery, Order, Sworn, User).
• Config & Utils: Global configuration files (e.g., DB and swaggerOptions) and utilities for tasks such as email sending, token management, and scheduled jobs.
• External Integrations: For example, AWS S3 utility for file storage, emailing service, and cron jobs for periodic tasks.
• Database: Represented by the “db” folder containing configuration and initialization (even if the specific database type isn’t mentioned, it is a core component).
b. Relationships/Interactions:
• Flow starts at the Express Server receiving HTTP requests which are routed to the appropriate Controller.
• Controllers call corresponding Services that encapsulate business logic.
• Services interact with Repositories to perform CRUD operations with the database.
• Middleware tasks (authentication, error handling) intercept the requests before reaching Controllers.
• Utility modules (for sending emails, uploading to S3, token management) support the core business flow.
• Config files provide the runtime environment, such as DB connections, server port configurations, and Swagger options for API documentation.
• CI/CD pipelines (via GitHub workflows, Dockerfile, and EKS manifests) support automated testing, deployment, and scaling.
c. Important Architectural Patterns/Design Principles:
• MVC-like pattern: Clear separation between Controllers, Services, and Repositories.
• Modular Design: Well-organized components promote separation of concerns with independent modules (middlewares, utils, tests).
• Containerization and CI/CD Integration: The Docker and EKS-related files indicate a container-based deployment and integration pipeline.
• Dependency Inversion: By using interfaces extensively (as seen in the src/interfaces directory), the project favors loosely coupled components.
• Testing Focus: Structured tests (unit, integration, E2E) suggest an emphasis on maintainability and quality assurance.
d. Relevant Technologies/Frameworks:
• Express and NodeJS as the core server framework.
• TypeScript for static typing and better maintainability.
• Docker and Kubernetes (EKS manifests) for deployment.
• GitHub Actions for CI/CD integration.
• Utilities for AWS (S3), email sending, and cron jobs.
• External libraries such as ESLint, Prettier, and Husky for code quality and linting.
Final Recommendations
• Remember that clarity is key: ensure that each component’s role is clearly defined and that connections show logical data flows or dependencies.