How nievas2/tech-library works
Project Overview
• The backend (in the “back” directory) is built with Node.js/TypeScript and follows a modular structure. It’s organized by domains (e.g., auth, library, like, tag, user) and contains components such as controllers, services, entities, routes, strategies (for authentication with JWT, GitHub, Google, local login), and shared utilities (for error handling, middlewares, configuration, etc.).
• The frontend (in the “front” directory) is a React-based application bootstrapped by Vite. It is organized into pages, components, hooks, contexts, services, and utilities, supporting features like authentication, library management, tag handling, and user dashboards.
• Docker files and a docker-compose configuration in the “back” folder indicate containerization for deployment and development. The “back/mysql/init.sql” file shows that MySQL is used as the primary database.
Main Components
a. Frontend:
• Frontend Application (React/Vite) – include major directories like pages, components, contexts, hooks, and API service connectors (e.g., axiosInstance).
• Features/components: Authentication pages (login, register), Dashboard pages (admin and user), Home and Landing pages, and UI components.
b. Backend:
• API Server (main entry point: back/src/server.ts) – encapsulates the business logic.
• Authentication Module – handling user authentication with various strategies, controllers, and routes.
• Library Module – managing library resources (entities, controllers, service, and middleware for libraries).
• Like Module – operations related to “likes” with its own service and error handling.
• Tag Module – managing tags through its controllers, services, and middleware.
• User Module – for user management (controllers, services, entities) and role definitions.
• Shared Utilities – common error handling routines, middlewares, response formats, and utility functions.
• Configuration & Environment Management – all the configuration files and environment variables loaded for different environments.
c. Database & Infrastructure:
• MySQL Database – represented as its own component (with initialization via back/mysql/init.sql).
• Docker & Deployment – Dockerfile(s) and docker-compose setups that orchestrate container-based deployment.
Relationships and Interactions
• Within the Backend, illustrate how the API server routes requests to the appropriate modules. For example, requests that hit “auth.router” delegate to authentication controllers which, in turn, use strategies (like JWT, GitHub, etc.) and services.
• How shared middlewares (e.g., error handling, request validation) are used by each module to process incoming requests.
• Connection between the Backend and the MySQL database to show data persistence.
• Optionally, show that Docker is used to containerize the backend and database: a container for Node.js and a container for the MySQL instance.
Architectural Patterns & Design Principles
• Separation of Concerns: Each domain/module in the backend encapsulates its own controllers, services, entities, exceptions, and middlewares.
• Modular Architecture: Clear segmentation of functionalities (auth, library, like, tag, user) enables maintainability and scalability.
• API Layer: The server layer (with a clear routing mechanism) manages the API requests and delegates functionality to the business logic.
• Containerization: Docker is used for consistency across environments with environmental variables and docker-compose for multi-container orchestration.
• On the frontend, component-based design (React with contexts and hooks) promotes reusability and a clean separation between UI components and business logic/service calls.
Extra Details
• API Gateway/LB (if applicable) – although not explicitly defined, you might want to note that the Node.js server could be handling incoming requests.
– The overall separation between frontend and backend,
– Modular domain-specific architecture in the backend,
– Infrastructure elements (like MySQL and Docker) used in deployment,
– Clear flow of data and interactions between the distinct components of the application.
This level of detail will provide clarity to both technical and non-technical stakeholders and serve as a solid blueprint for understanding the system’s architecture.