# elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app architecture

> Architecture diagram of the GitHub repository elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app
- Repository: https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app

## Overview

PlateShare connects food donors with beneficiaries: donors publish surplus, beneficiaries discover nearby offers, reserve a basket and receive a pickup code, then a donor validates that code to complete collection. The React app routes users through exploration, account access and role-based dashboards; its API client calls the Express API, whose routes and controllers enforce access and update MongoDB records. The README documents geolocation, distance/category/free filters and pickup tracking; some feature implementations were not sampled, so their internal links are omitted where unverified.

Main entry points: [`client/src/pages/ExplorePage.jsx`](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/ExplorePage.jsx) (Explore offers), [`client/src/App.jsx`](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/App.jsx) (React app routes), [`server/src/app.js`](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/app.js) (Express API), [`server/src/controllers/reservation.controller.js`](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/reservation.controller.js) (Reservation operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["React app routes<br/>[App.jsx]"]
  node_home["Home page<br/>[HomePage.jsx]"]
  node_explore["Explore offers<br/>[ExplorePage.jsx]"]
  node_filters["Listing filters<br/>[ListingFilters.jsx]"]
  node_map["Map and geolocation<br/>[LeafletMap.jsx]"]
  node_foodcard["Offer cards<br/>[FoodCard.jsx]"]
  node_timer["Pickup countdown<br/>[CountdownTimer.jsx]"]
  node_reserveui["Reservation dialog"]
  node_register["Account registration<br/>[RegisterPage.jsx]"]
  node_auth["Session and roles<br/>[AuthContext.jsx]"]
  node_dashboard["Role dashboard<br/>[DashboardPage.jsx]"]
  node_http["API client<br/>[api.js]"]
end

subgraph group_api["API and access"]
  node_server["Express API<br/>[app.js]"]
  node_listingroutes["Listing routes<br/>[listing.routes.js]"]
  node_authroutes["Authentication routes<br/>[auth.routes.js]"]
  node_resroutes["Reservation routes"]
  node_authmw["JWT authentication<br/>[auth.middleware.js]"]
  node_authctrl["Account operations<br/>[auth.controller.js]"]
  node_usermodel[("User records<br/>[User.js]")]
end

subgraph group_food["Listings and discovery"]
  node_listingctrl["Listing operations"]
  node_foodmodel[("Food listings<br/>[FoodListing.js]")]
end

subgraph group_reservation["Reservations"]
  node_resctrl["Reservation operations"]
  node_resmodel[("Reservation records<br/>[Reservation.js]")]
end

node_visitor(("Donor or beneficiary"))
node_mongo[("MongoDB")]

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_explore
node_app -->|"routes to"| node_register
node_app -->|"protects route"| node_dashboard
node_register -->|"registers through"| node_auth
node_auth -->|"calls"| node_http
node_explore -->|"loads offers"| node_http
node_explore -->|"renders"| node_filters
node_explore -->|"renders"| node_map
node_explore -->|"renders"| node_foodcard
node_explore -->|"opens"| node_reserveui
node_foodcard -->|"renders"| node_timer
node_dashboard -->|"loads and updates"| node_http
node_dashboard -->|"renders"| node_timer
node_http -->|"requests API"| node_server
node_server -->|"mounts routes"| node_listingroutes
node_listingroutes -->|"dispatches"| node_listingctrl
node_listingctrl -->|"queries and changes"| node_foodmodel
node_listingctrl -->|"aggregates nearby offers"| node_mongo
node_server -->|"mounts API routes"| node_authroutes
node_authroutes -->|"dispatches"| node_authctrl
node_authctrl -->|"reads and writes"| node_usermodel
node_server -.->|"mounts API routes"| node_resroutes
node_resroutes -->|"dispatches"| node_resctrl
node_resctrl -->|"creates and updates"| node_resmodel
node_resctrl -->|"updates offer status"| node_foodmodel
node_resctrl -.->|"persists reservations"| node_mongo
node_listingroutes -->|"authenticates writes"| node_authmw
node_resroutes -->|"authenticates access"| node_authmw
node_authroutes -->|"authenticates session"| node_authmw
node_authmw -->|"loads user"| node_usermodel
node_foodmodel -.->|"stores listings"| node_mongo
node_usermodel -.->|"stores accounts"| node_mongo
node_resmodel -.->|"stores reservations"| node_mongo

click node_app "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/App.jsx"
click node_home "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/HomePage.jsx"
click node_explore "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/ExplorePage.jsx"
click node_filters "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/ListingFilters.jsx"
click node_map "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/map/LeafletMap.jsx"
click node_foodcard "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/FoodCard.jsx"
click node_timer "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/CountdownTimer.jsx"
click node_reserveui "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/reservations/ReservationModal.jsx"
click node_register "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/RegisterPage.jsx"
click node_auth "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/DashboardPage.jsx"
click node_http "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/services/api.js"
click node_server "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/app.js"
click node_listingroutes "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/listing.routes.js"
click node_authroutes "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/auth.routes.js"
click node_resroutes "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/reservation.routes.js"
click node_authmw "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/middlewares/auth.middleware.js"
click node_listingctrl "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/listing.controller.js"
click node_foodmodel "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/FoodListing.js"
click node_authctrl "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/auth.controller.js"
click node_usermodel "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/User.js"
click node_resctrl "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/reservation.controller.js"
click node_resmodel "https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/Reservation.js"

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_app,node_home,node_explore,node_filters,node_map,node_foodcard,node_timer,node_reserveui,node_register,node_auth,node_dashboard,node_http toneBlue
class node_server,node_listingroutes,node_authroutes,node_resroutes,node_authmw,node_authctrl,node_usermodel,node_mongo toneAmber
class node_listingctrl,node_foodmodel toneMint
class node_resctrl,node_resmodel toneRose
class node_visitor toneIndigo
```

## Components

### Web application

- [React app routes](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Home page](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/HomePage.jsx): `client/src/pages/HomePage.jsx`
- [Explore offers](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/ExplorePage.jsx): `client/src/pages/ExplorePage.jsx`
- [Listing filters](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/ListingFilters.jsx): `client/src/features/listings/ListingFilters.jsx`
- [Map and geolocation](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/map/LeafletMap.jsx): `client/src/features/map/LeafletMap.jsx`
- [Offer cards](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/FoodCard.jsx): `client/src/features/listings/FoodCard.jsx`
- [Pickup countdown](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/listings/CountdownTimer.jsx): `client/src/features/listings/CountdownTimer.jsx`
- [Reservation dialog](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/features/reservations/ReservationModal.jsx): `client/src/features/reservations/ReservationModal.jsx`
- [Account registration](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/RegisterPage.jsx): `client/src/pages/RegisterPage.jsx`
- [Session and roles](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Role dashboard](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [API client](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API and access

- [Express API](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/app.js): `server/src/app.js`
- [Listing routes](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/listing.routes.js): `server/src/routes/listing.routes.js`
- [Authentication routes](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/auth.routes.js): `server/src/routes/auth.routes.js`
- [Reservation routes](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/routes/reservation.routes.js): `server/src/routes/reservation.routes.js`
- [JWT authentication](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/middlewares/auth.middleware.js): `server/src/middlewares/auth.middleware.js`
- [Account operations](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [User records](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/User.js): `server/src/models/User.js`

### Listings and discovery

- [Listing operations](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/listing.controller.js): `server/src/controllers/listing.controller.js`
- [Food listings](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/FoodListing.js): `server/src/models/FoodListing.js`

### Reservations

- [Reservation operations](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/controllers/reservation.controller.js): `server/src/controllers/reservation.controller.js`
- [Reservation records](https://github.com/elhabchimohammed666-hub/reduire_gaspillage_allimentaire_app/blob/main/server/src/models/Reservation.js): `server/src/models/Reservation.js`

### Other components

- **Donor or beneficiary**
- **MongoDB**

## Connections

- Donor or beneficiary → React app routes: uses (evidence: `client/src/App.jsx`)
- React app routes → Home page: routes to (evidence: `client/src/App.jsx`)
- React app routes → Explore offers: routes to (evidence: `client/src/App.jsx`)
- React app routes → Account registration: routes to (evidence: `client/src/App.jsx`)
- React app routes → Role dashboard: protects route (evidence: `client/src/App.jsx`)
- Account registration → Session and roles: registers through (evidence: `client/src/pages/RegisterPage.jsx`)
- Session and roles → API client: calls (evidence: `client/src/context/AuthContext.jsx`)
- Explore offers → API client: loads offers (evidence: `client/src/pages/ExplorePage.jsx`)
- Explore offers → Listing filters: renders (evidence: `client/src/pages/ExplorePage.jsx`)
- Explore offers → Map and geolocation: renders (evidence: `client/src/pages/ExplorePage.jsx`)
- Explore offers → Offer cards: renders (evidence: `client/src/pages/ExplorePage.jsx`)
- Explore offers → Reservation dialog: opens (evidence: `client/src/pages/ExplorePage.jsx`)
- Offer cards → Pickup countdown: renders (evidence: `client/src/features/listings/FoodCard.jsx`)
- Role dashboard → API client: loads and updates (evidence: `client/src/pages/DashboardPage.jsx`)
- Role dashboard → Pickup countdown: renders (evidence: `client/src/pages/DashboardPage.jsx`)
- API client → Express API: requests API (evidence: `README.md`)
- Express API → Listing routes: mounts routes (evidence: `server/src/app.js`)
- Listing routes → Listing operations: dispatches (evidence: `server/src/routes/listing.routes.js`)
- Listing operations → Food listings: queries and changes (evidence: `server/src/controllers/listing.controller.js`)
- Listing operations → MongoDB: aggregates nearby offers (evidence: `server/src/controllers/listing.controller.js`)
- Express API → Authentication routes: mounts API routes (evidence: `server/src/app.js`)
- Authentication routes → Account operations: dispatches (evidence: `server/src/routes/auth.routes.js`)
- Account operations → User records: reads and writes (evidence: `server/src/controllers/auth.controller.js`)
- Express API → Reservation routes: mounts API routes
- Reservation routes → Reservation operations: dispatches (evidence: `server/src/routes/reservation.routes.js`)
- Reservation operations → Reservation records: creates and updates (evidence: `server/src/controllers/reservation.controller.js`)
- Reservation operations → Food listings: updates offer status (evidence: `server/src/controllers/reservation.controller.js`)
- Reservation operations → MongoDB: persists reservations
- Listing routes → JWT authentication: authenticates writes (evidence: `server/src/routes/listing.routes.js`)
- Reservation routes → JWT authentication: authenticates access (evidence: `server/src/routes/reservation.routes.js`)
- Authentication routes → JWT authentication: authenticates session (evidence: `server/src/routes/auth.routes.js`)
- JWT authentication → User records: loads user (evidence: `server/src/middlewares/auth.middleware.js`)
- Food listings → MongoDB: stores listings
- User records → MongoDB: stores accounts
- Reservation records → MongoDB: stores reservations
