How nenuphare/bloomy-app-back works
Project Type & Purpose
• The project is a Node.js backend server providing a RESTful API for a full-stack application (see the repo URLs that point to separate back‐ and front-end repositories).
• The backend supports various domains such as “home”, “room”, “task”, “type”, “user”, and “subscriber” management.
• It relies on JWT-based authentication (with files like jwtMiddleware.js and subscriberJwtMiddleware.js) and incorporates a policy file for access control (e.g., checkUserHome.js).
File Structure Insights & Architectural Breakdown
• Main Entry Point – index.js: This file is likely setting up the Express server, initializing middlewares, and mounting routes.
• Controllers & Routes:
– The “controllers” directory contains individual controllers (home, room, task, type, user) that encapsulate business logic.
– The “routes” directory maps URL endpoints to these controllers (e.g., homeRoute.js, roomRoute.js, etc.).
• Models:
– The “models” directory defines data structures or possibly interfaces to the database (e.g., homeModel.js, roomModel.js, and others). This part of the architecture supports the data persistence layer.
• Middleware & Policy:
– JWT middlewares in “middlewares” and in the “landing” folder manage authentication.
– The “policy” directory (checkUserHome.js) enforces authorization rules.
• Special Components:
– The “landing” directory appears to manage subscriber-specific functionalities, including routes, controllers, and a model tailored to subscribers.
– The “utils” directory with shareCodeGenerator.js holds helper functions to support the core logic.
a. Main Components:
– Client Interface: Though part of a separate repository ("bloomy-app-front"), represent front-end integration with the backend.
– API Gateway / Server Entry: index.js which receives HTTP requests.
– Routing Layer: Individual route files (from the “routes” directory) that direct requests to corresponding controllers.
– Controllers: Modules in “controllers” (and landing) that handle request logic.
– Data Models: Components under “models” that represent and interact with the data – possibly a database connection layer.
– Authentication/Authorization: Middlewares (in “middlewares” and "landing") and policy files that enforce security checks.
– Utility Functions: “utils” for tasks like code generation.
b. Relationships & Interactions:
– Incoming HTTP requests (e.g., from the front-end) hit the API Gateway (index.js).
– Requests are routed via the “routes” layer, which directs them to the proper controller.
– Controllers process the request, often interacting with the Models to fetch or store data.
– Before reaching controllers, authentication middlewares (JWT validation) and authorization policies intercept requests.
– Utility functions may be called within controllers to handle specific tasks.
c. Architectural Patterns & Principles:
– MVC (Model-View-Controller): Even though it's a backend, the separation between routing, controllers (logic), and models (data) is clear.
– Middleware-based Security: Integration of authentication (JWT) and authorization (policy) aspects supports secure request handling.
– Modularity: Each domain (home, room, task, etc.) is clearly separated into its own controllers, routes, and models.
d. Relevant Technologies:
– Node.js/Express (implied by the file naming and typical project structure).
– JSON Web Tokens (JWT) for authentication.
– Possibly an ORM or direct database access via models.
– Utility libraries for additional functionalities such as shared code generation.