How anct-cnum/api-conseiller-numerique works
Project Type and Purpose
• This is a backend API built on the Feathers framework that serves as the application’s main server. Its purpose is to provide a real-time API integrated with various services such as authentication, data exports, email sending, and more. Its integration with MongoDB is core (with PostgreSQL as an optional secondary database) and there are many administrative and data-processing tools.
• The README emphasizes setup for MongoDB (and optionally PostgreSQL), API startup, and testing. This confirms that the project is centered on a backend service offering REST and real-time functionalities using Feathers.
File Structure for Architectural Insights
• Top-Level components include:
• Configuration files (e.g., config/, .eslintrc.json, package.json) which indicate environment-specific setups (default, production, test).
• The src/ directory which holds the application code. This directory is further split into key areas:
▸ Core Application Files: app.js, index.js, logger.js, mailer.js, and the MongoDB connection (mongodb.js).
▸ Services: Organized under src/services with many domain areas (conseillers, coordinateurs, cras, structures, users, stats, and more). This suggests a microservices-like or modular service architecture within a Feathers application.
▸ Emails: In src/emails, with many templates (using mjml.ejs) and corresponding JS files, indicating an extensive email notification subsystem.
▸ Tools and Admin Scripts: Located in src/tools (with subdirectories for admin tasks, exports, jobs, population, scripts, etc.) which are used for maintenance, data processing, or administrative operations.
▸ Common Utilities and Repositories: In src/common, supporting shared logic and data access (like feathers.utils.js, document templates, and repositories).
• Public: Likely static assets.
• Tests appear under test/ and include integration and unit tests which highlight robust testing strategy.
• The presence of numerous GitHub workflow files (in .github/workflows) points to CI/CD practices including linting, dependency management, and automated deployments (to production, demo, etc.).
a. Main Components to Represent:
• API Server (Core Application Layer): Represented by the Feathers app (src/app.js, src/index.js).
• Services Modules: Each major domain (conseillers, coordinateurs, cras, structures, users, etc.) should be a separate component. Group them or show them as distinct microservice blocks under “Services.”
• Email System: Separate component detailing email templates, notification modules, and hooks used to trigger email events.
• Tools/Administration: A section for admin scripts and maintenance tasks (located under src/tools) which interact with the core database or trigger certain jobs.
• Database(s):
▸ Primary: MongoDB – indicated by the src/mongodb.js and related configuration.
▸ Optional: PostgreSQL – as described in the README, using Docker instructions.
• External Interfaces: Indicate integration with external systems (like CleverCloud configurations in the clevercloud folder, and possible external APIs in src/utils/entreprise.api.gouv.js).
b. Relationships and Data Flows:
• Client/UI (or other consumers) interact with the API server.
• The API server routes requests to the appropriate Feathers services.
• Services interact with the MongoDB database (via repositories and direct calls in src/services).
• Some services may trigger email flows and administrative scripts.
• The Tools/Jobs layer may run periodically (e.g., via cron or Docker jobs as seen in the clevercloud and src/tools/jobs directories) to process or export data.
c. Architectural Patterns:
• Modular Design: The services are separated by domain (using Feathers services and hooks) ensuring clear separation of concerns.
• Real-Time & RESTful API: Built on Feathers which supports both REST and real-time (websocket) communications.
• Dependency Injection & Utility Libraries: The presence of common utilities and repositories indicate reusability and adherence to DRY principles.
• CI/CD and Automated Testing: Indicated by GitHub workflows and extensive test directories.
d. Relevant Technologies and Frameworks:
• FeathersJS as the main framework for real-time API.
• MongoDB (and optionally PostgreSQL) as the primary data storage.
• Docker containerization for running the databases.
• Node.js / npm for the runtime environment and dependency management.
• Email templating via MJML integrated in the emails section.
• GitHub Actions for deployment and integration (CI/CD).
• API Server (Feathers Application)
• Each main Service Module (e.g., Conseillers, Coordinateurs, Structures, Cras, Stats, Users)
• Email System (detailing both admin and user email templates)
• Tools / Admin Scripts (grouped by purpose if needed)
• Primary Database (MongoDB) and optional Secondary Database (PostgreSQL)
• External Integrations (e.g., CleverCloud, external APIs)
• Every component and data flow is clearly labeled to capture dependency relationships and interactions.