# mehdi-devops-cv/cloud-devops-project architecture

> Architecture diagram of the GitHub repository mehdi-devops-cv/cloud-devops-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mehdi-devops-cv/cloud-devops-project
- Repository: https://github.com/mehdi-devops-cv/cloud-devops-project

## Overview

1. This is a monorepo for an “AppBTP” construction/project-management system with three product surfaces: a Node/Express backend API, a React web frontend, and an Expo/React Native mobile app. The backend is the shared system-of-record; both clients consume it over HTTP.

2. The backend lives in `backend/src`. `app.js` assembles the Express app, `db.js` handles MongoDB connectivity, and `middlewares/` centralizes auth, admin checks, and error handling. The API is organized by domain routes rather than by UI concerns, which makes it the main architectural boundary.

3. Authentication and user control are a distinct subsystem: `routes/auth.js`, `models/User.js`, `middlewares/auth.js`, and `middlewares/isAdmin.js`. The README confirms JWT-based login/register/logout/user endpoints, with bcrypt-based password hashing. This is the security boundary for all protected business routes.

4. The core business domain is split across several MongoDB models and routes: `Effectif` for workforce tracking, `Note` and `Remarque` for annotations, `Constatation` for inspections/findings, `Building` and `City` for reference/master data, and `Folder`/`FolderPhoto` for document/photo grouping. Routes mirror those domains: `effectifs`, `notes`, `remarques`, `constatations`, `reference`, `folders`, and `upload`.

5. There is an admin/reference-data layer separate from end-user operations. `routes/admin.js` and the seed scripts in `backend/scripts/` (`create_admin.js`, `create_user.js`, `add_cities.js`, `add_buildings.js`, `list_users.js`) indicate the app expects controlled provisioning of users and reference entities, likely used during environment setup and operational maintenance.

6. Media handling is its own concern. The presence of `upload.js`, `FolderPhoto.js`, and the `utils/avatar.js` helper suggests the backend manages user avatars and project photos/documents as first-class records, not just text data. This is likely one of the main integration points between mobile/web capture flows and persistence.

7. The web frontend in `frontend/` is a Vite + React application. `src/config/api.js` centralizes backend endpoint configuration, `context/AuthContext.jsx` manages session state, and `utils/storage.js` likely abstracts token/local storage. The main pages are `Home`, `Login`, `Dashboard`, and `RapportPhoto`, indicating a relatively focused UI on authentication, overview, and photo/report workflows.

8. The mobile app in `mobile/` is a separate Expo React Native client with a richer native packaging footprint (`android/`, `ios/`, EAS scripts). Its structure is split into controller-like coordination code under `Controleur/` and view/screen code under `Vue/`, with reusable components in `component/` and shared utilities in `utils/`. It appears to implement the same business flows as the web app, but optimized for on-site use.

9. The mobile app also includes role/session/navigation infrastructure: `UserRoleContext`, `TabContext`, custom navigation helpers, splash/transition UI, and locale assets (`locales/fr.json`). That suggests the mobile client is not just a thin shell; it has its own presentation state and role-aware navigation while still relying on the backend API for data.

10. Persistence is MongoDB Atlas, per the README, with Mongoose-style models in the backend. The architecture is therefore API-centric: both clients call the backend, the backend validates/authenticates, then reads/writes domain documents in MongoDB. There is no evidence of a separate frontend-owned state store beyond local auth/session storage.

11. Infrastructure is handled in layers. `infra/` contains Terraform modules for `network`, `compute`, `storage`, and `iam`, implying cloud resources are provisioned as code. Separately, `docker/` and the root `docker-compose*.yml` provide containerized local/runtime environments, including backend, frontend, nginx, and Jenkins images.

12. CI/CD is explicitly split by surface with `Jenkinsfile.backend`, `Jenkinsfile.frontend`, and `Jenkinsfile.mobile`. That means each client/backend can be built and deployed independently, while still sharing a common repository and infrastructure conventions. For an architecture diagram, this repo should be drawn as one platform with three deployable applications plus shared infrastructure and automation around them.

Main entry points: [`backend/src/app.js`](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/app.js) (Express app), [`frontend/src/main.jsx`](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/main.jsx) (React entry), [`backend/src/models/index.js`](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/models/index.js) (Domain models), [`backend/src/routes/auth.js`](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/auth.js) (Auth API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform"]
  node_infra_tf{{"Terraform<br/>infra<br/>[main.tf]"}}
  node_compose{{"Compose stack<br/>runtime orchestration<br/>[docker-compose.yml]"}}
  node_ci_backend{{"Backend CI<br/>pipeline"}}
  node_ci_frontend{{"Frontend CI<br/>pipeline"}}
  node_ci_mobile{{"Mobile CI<br/>pipeline<br/>[Jenkinsfile.mobile]"}}
end

subgraph group_backend["Backend API"]
  node_backend_app["Express app<br/>api bootstrap<br/>[app.js]"]
  node_backend_db[("MongoDB<br/>db connector<br/>[db.js]")]
  node_backend_auth_route["Auth API<br/>route<br/>[auth.js]"]
  node_backend_auth_mw["Auth guard<br/>middleware<br/>[auth.js]"]
  node_backend_user_model["User model<br/>mongoose model<br/>[User.js]"]
  node_backend_domain_models["Domain models<br/>mongoose models<br/>[index.js]"]
  node_backend_effectifs["Effectifs<br/>domain route<br/>[effectifs.js]"]
  node_backend_reference["Reference data<br/>domain route<br/>[reference.js]"]
  node_backend_folders["Folders<br/>domain route<br/>[folders.js]"]
  node_backend_upload["Media upload<br/>media route<br/>[upload.js]"]
  node_backend_admin["Admin API<br/>admin route<br/>[admin.js]"]
  node_backend_error["Error handler<br/>middleware<br/>[errorHandler.js]"]
  node_backend_avatar["Avatar util<br/>helper<br/>[avatar.js]"]
  node_backend_seed["Seed admin<br/>script<br/>[create_admin.js]"]
end

subgraph group_frontend["Web App"]
  node_frontend_entry["React entry<br/>ui bootstrap<br/>[main.jsx]"]
  node_frontend_auth["Session state<br/>context<br/>[AuthContext.jsx]"]
  node_frontend_api["API config<br/>client config<br/>[api.js]"]
  node_frontend_dashboard["Dashboard<br/>page<br/>[Dashboard.jsx]"]
  node_frontend_rapport["Photo report<br/>page<br/>[RapportPhoto.jsx]"]
end

subgraph group_mobile["Mobile App"]
  node_mobile_entry["Expo app<br/>app bootstrap<br/>[App.tsx]"]
  node_mobile_wrapper["App wrapper<br/>ui shell<br/>[AppWrapper.js]"]
  node_mobile_role["Role context<br/>[UserRoleContext.js]"]
  node_mobile_tabs["Tab context<br/>navigation state<br/>[TabContext.js]"]
  node_mobile_home["Home screen<br/>[HomePage.js]"]
  node_mobile_report["Photo report<br/>screen<br/>[RapportPhoto.js]"]
end

node_backend_app -->|"connects"| node_backend_db
node_backend_app -->|"mounts"| node_backend_auth_route
node_backend_app -->|"mounts"| node_backend_effectifs
node_backend_app -->|"mounts"| node_backend_reference
node_backend_app -->|"mounts"| node_backend_folders
node_backend_app -->|"mounts"| node_backend_upload
node_backend_app -->|"mounts"| node_backend_admin
node_backend_app -->|"uses"| node_backend_error
node_backend_auth_route -->|"protects"| node_backend_auth_mw
node_backend_auth_route -->|"reads/writes"| node_backend_user_model
node_backend_auth_route -->|"depends on"| node_backend_domain_models
node_backend_effectifs -->|"reads/writes"| node_backend_domain_models
node_backend_reference -->|"reads/writes"| node_backend_domain_models
node_backend_folders -->|"reads/writes"| node_backend_domain_models
node_backend_upload -->|"uses"| node_backend_avatar
node_backend_upload -->|"reads/writes"| node_backend_domain_models
node_backend_admin -->|"guards"| node_backend_auth_mw
node_backend_admin -.->|"influences"| node_backend_seed
node_frontend_entry -->|"wraps"| node_frontend_auth
node_frontend_entry -->|"configures"| node_frontend_api
node_frontend_entry -->|"routes to"| node_frontend_dashboard
node_frontend_dashboard -->|"navigates to"| node_frontend_rapport
node_frontend_auth -->|"uses"| node_frontend_api
node_mobile_entry -->|"boots"| node_mobile_wrapper
node_mobile_wrapper -->|"provides"| node_mobile_role
node_mobile_wrapper -->|"provides"| node_mobile_tabs
node_mobile_wrapper -->|"shows"| node_mobile_home
node_mobile_home -->|"navigates to"| node_mobile_report
node_infra_tf -.->|"provisions"| node_backend_db
node_infra_tf -.->|"complements"| node_compose
node_compose -.->|"runs"| node_backend_app
node_compose -.->|"runs"| node_frontend_entry
node_ci_backend -->|"builds"| node_backend_app
node_ci_frontend -->|"builds"| node_frontend_entry
node_ci_mobile -->|"builds"| node_mobile_entry

click node_backend_app "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/app.js"
click node_backend_db "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/db.js"
click node_backend_auth_route "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/auth.js"
click node_backend_auth_mw "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/middlewares/auth.js"
click node_backend_user_model "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/models/User.js"
click node_backend_domain_models "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/models/index.js"
click node_backend_effectifs "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/effectifs.js"
click node_backend_reference "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/reference.js"
click node_backend_folders "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/folders.js"
click node_backend_upload "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/upload.js"
click node_backend_admin "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/admin.js"
click node_backend_error "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/middlewares/errorHandler.js"
click node_backend_avatar "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/utils/avatar.js"
click node_backend_seed "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/scripts/create_admin.js"
click node_frontend_entry "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/main.jsx"
click node_frontend_auth "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/context/AuthContext.jsx"
click node_frontend_api "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/config/api.js"
click node_frontend_dashboard "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/pages/Dashboard.jsx"
click node_frontend_rapport "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/pages/RapportPhoto.jsx"
click node_mobile_entry "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/App.tsx"
click node_mobile_wrapper "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/AppWrapper.js"
click node_mobile_role "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/UserRoleContext.js"
click node_mobile_tabs "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/TabContext.js"
click node_mobile_home "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Vue/HomePage.js"
click node_mobile_report "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Vue/RapportPhoto.js"
click node_infra_tf "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/infra/main.tf"
click node_compose "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/docker-compose.yml"
click node_ci_backend "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.backend"
click node_ci_frontend "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.frontend"
click node_ci_mobile "https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.mobile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_infra_tf,node_compose,node_ci_backend,node_ci_frontend,node_ci_mobile toneBlue
class node_backend_app,node_backend_db,node_backend_auth_route,node_backend_auth_mw,node_backend_user_model,node_backend_domain_models,node_backend_effectifs,node_backend_reference,node_backend_folders,node_backend_upload,node_backend_admin,node_backend_error,node_backend_avatar,node_backend_seed toneAmber
class node_frontend_entry,node_frontend_auth,node_frontend_api,node_frontend_dashboard,node_frontend_rapport toneMint
class node_mobile_entry,node_mobile_wrapper,node_mobile_role,node_mobile_tabs,node_mobile_home,node_mobile_report toneRose
```

## Components

### Platform

Shared backend, clients, infrastructure, and delivery automation

- [Terraform](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/infra/main.tf): infra · Cloud infrastructure as code · `infra/main.tf`
- [Compose stack](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/docker-compose.yml): runtime orchestration · Local containerized backend, frontend, and nginx services · `docker-compose.yml`
- [Backend CI](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.backend): pipeline · Jenkins pipeline for backend build and deploy · `Jenkinsfile.backend`
- [Frontend CI](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.frontend): pipeline · Jenkins pipeline for web client build and deploy · `Jenkinsfile.frontend`
- [Mobile CI](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/Jenkinsfile.mobile): pipeline · Jenkins pipeline for mobile build and submission · `Jenkinsfile.mobile`

### Backend API

Express application and MongoDB domain layer

- [Express app](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/app.js): api bootstrap · Assembles middleware and domain routes · `backend/src/app.js`
- [MongoDB](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/db.js): db connector · Initializes database connectivity · `backend/src/db.js`
- [Auth API](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/auth.js): route · Login, register, logout, and user session endpoints · `backend/src/routes/auth.js`
- [Auth guard](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/middlewares/auth.js): middleware · Protects authenticated business routes · `backend/src/middlewares/auth.js`
- [User model](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/models/User.js): mongoose model · User identity and roles · `backend/src/models/User.js`
- [Domain models](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/models/index.js): mongoose models · Shared persistence for core business entities · `backend/src/models/index.js`
- [Effectifs](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/effectifs.js): domain route · Workforce tracking endpoints · `backend/src/routes/effectifs.js`
- [Reference data](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/reference.js): domain route · Master data for buildings and cities · `backend/src/routes/reference.js`
- [Folders](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/folders.js): domain route · Document and photo grouping endpoints · `backend/src/routes/folders.js`
- [Media upload](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/upload.js): media route · Handles avatar and project file uploads · `backend/src/routes/upload.js`
- [Admin API](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/routes/admin.js): admin route · Controlled provisioning and maintenance endpoints · `backend/src/routes/admin.js`
- [Error handler](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/middlewares/errorHandler.js): middleware · Central API error handling · `backend/src/middlewares/errorHandler.js`
- [Avatar util](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/src/utils/avatar.js): helper · Avatar and profile media helper · `backend/src/utils/avatar.js`
- [Seed admin](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/backend/scripts/create_admin.js): script · Provisioning script for initial admin setup · `backend/scripts/create_admin.js`

### Web App

React/Vite client for browser workflows

- [React entry](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/main.jsx): ui bootstrap · Vite/React application entry point · `frontend/src/main.jsx`
- [Session state](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/context/AuthContext.jsx): context · Manages browser auth state · `frontend/src/context/AuthContext.jsx`
- [API config](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/config/api.js): client config · Central backend endpoint configuration · `frontend/src/config/api.js`
- [Dashboard](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/pages/Dashboard.jsx): page · Main authenticated overview · `frontend/src/pages/Dashboard.jsx`
- [Photo report](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/frontend/src/pages/RapportPhoto.jsx): page · Photo/report workflow screen · `frontend/src/pages/RapportPhoto.jsx`

### Mobile App

Expo/React Native client for field workflows

- [Expo app](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/App.tsx): app bootstrap · React Native application entry point · `mobile/App.tsx`
- [App wrapper](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/AppWrapper.js): ui shell · Top-level mobile composition and layout · `mobile/Controleur/AppWrapper.js`
- [Role context](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/UserRoleContext.js): context · Role-aware session state · `mobile/Controleur/UserRoleContext.js`
- [Tab context](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Controleur/TabContext.js): navigation state · Navigation and tab coordination · `mobile/Controleur/TabContext.js`
- [Home screen](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Vue/HomePage.js): screen · Primary mobile landing page · `mobile/Vue/HomePage.js`
- [Photo report](https://github.com/mehdi-devops-cv/cloud-devops-project/blob/main/mobile/Vue/RapportPhoto.js): screen · Mobile capture and reporting flow · `mobile/Vue/RapportPhoto.js`

## Connections

- Express app → MongoDB: connects · Initializes MongoDB access during app startup
- Express app → Auth API: mounts · Registers authentication endpoints
- Express app → Effectifs: mounts · Registers workforce routes
- Express app → Reference data: mounts · Registers reference-data routes
- Express app → Folders: mounts · Registers folder routes
- Express app → Media upload: mounts · Registers upload routes
- Express app → Admin API: mounts · Registers admin routes
- Express app → Error handler: uses · Routes errors through central handler
- Auth API → Auth guard: protects · Uses auth middleware for protected operations
- Auth API → User model: reads/writes · Authenticates and persists users
- Auth API → Domain models: depends on · Shares domain persistence layer
- Effectifs → Domain models: reads/writes · Persists workforce records
- Reference data → Domain models: reads/writes · Accesses master/reference entities
- Folders → Domain models: reads/writes · Persists folder and media records
- Media upload → Avatar util: uses · Supports avatar handling
- Media upload → Domain models: reads/writes · Stores uploaded media metadata
- Admin API → Auth guard: guards · Restricts admin operations
- Admin API → Seed admin: influences · Matches provisioning and maintenance scripts
- React entry → Session state: wraps · Provides auth/session context to the app
- React entry → API config: configures · Injects backend endpoint configuration
- React entry → Dashboard: routes to · Opens authenticated dashboard flow
- Dashboard → Photo report: navigates to · Links into photo/report workflow
- Session state → API config: uses · Calls backend for login/session actions
- Expo app → App wrapper: boots · Initial mobile shell and layout
- App wrapper → Role context: provides · Makes role state available to screens
- App wrapper → Tab context: provides · Coordinates navigation state
- App wrapper → Home screen: shows · Starts on the main home screen
- Home screen → Photo report: navigates to · Opens photo/report workflow
- Terraform → MongoDB: provisions · Defines supporting cloud resources for persistence and runtime
- Terraform → Compose stack: complements · Infrastructure pairs with local container orchestration
- Compose stack → Express app: runs · Starts backend containerized service
- Compose stack → React entry: runs · Starts frontend containerized service
- Backend CI → Express app: builds · Backend pipeline packages and deploys the API
- Frontend CI → React entry: builds · Frontend pipeline packages and deploys the web app
- Mobile CI → Expo app: builds · Mobile pipeline builds and submits the app
