How akshatmittal61/balance-it-server works
Main Components
a. API/HTTP Server Layer:
• Main server (server.ts) that initializes the HTTP server.
• “routes” directory as the entry points for API requests.
• Nodes for middleware (from the “middlewares” directory) that handle authentication, error handling, etc.
b. Controller Layer:
• That controllers receive requests from the HTTP layer and call appropriate services.
c. Service Layer:
• “services” directory with various business logic components (auth.service, expense.service, group.service, etc.).
• For the email functionality, note the “services/email” subfolder with sender and templating modules.
• Link the controllers to these service components to demonstrate business logic processing.
d. Data / Repository Layer:
• “repo” directory which holds the data access code (auth.repo, expense.repo, group.repo, etc.).
• Also, include the “db” directory that manages the database connection (db/container.ts, db/index.ts) and types.
e. Model and Schema Layer:
• Models (from the “models” directory) which define data models, along with “schema” files that may be used for data validation.
f. Utility and Configuration Modules:
• Components for configuration (“config” folder), which includes base, email, oauth, and variables.
• “utils” directory that contains helper functions and API connectors which support various layers.
• Global constants and types (from the “constants” and “types” directories) that serve as standardized elements across the system.
Relationships and Interactions
• Then, link the controller to the corresponding service (e.g., auth.service) where the core business logic is processed.
• That services sometimes call the repository layer (represented by the “repo” directory) to perform CRUD operations on the database (shown via the “db” connection).
Architectural Patterns & Design Principles
• Layered architecture: clearly separating controllers, services, repositories, and configurations.
• Dependency injection and configuration management: configurations and modules loaded early in the application initialization.
• Modularity and Separation of Concerns: each directory (e.g., controllers, services, models) focuses on a specific role.
• Use of middleware in Express-like applications to handle authentication, security, and error management.
• That exceptions (errors and logging) are connected to all layers to emphasize robust error handling.