# alap06/crt_platforme architecture

> Architecture diagram of the GitHub repository alap06/crt_platforme, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alap06/crt_platforme
- Repository: https://github.com/alap06/crt_platforme

## Overview

##### Project type and purpose
- This is a full-stack donation platform for “Croissant Rouge Tunisien” (Tunisian Red Crescent), with user authentication, admin management, and donation/project tracking.
- The backend is an Express/Node.js REST API; the frontend is a React/Vite single-page app.

##### File structure
- Top-level:
- backend/ – Express app
- frontend/ – React app
- backend follows an MVC-style organization:
- config/db.js – database connection setup
- models/ – data schemas (User.js…)
- controllers/ – business logic (authController, adminController)
- routes/ – express routers per domain (authRoutes, adminRoutes)
- middlewares/ – request validation, authorization
- server.js – main entry point
- frontend is component-driven:
- src/api/ – wrapper modules for calling backend endpoints
- src/components/ – UI components & pages
- src/context/ – React Contexts for auth and theme
- src/hooks/ – custom hooks (useApi, useAuth)
- services/mockData.js – sample or fallback data

##### README for additional insights
- Very brief, confirms it’s a donation & regional project-management platform.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend (React SPA)"
        direction TB
        FEEntry["main.jsx"]:::frontend
        FEApp["App.jsx"]:::frontend
        subgraph "API Wrappers"
            direction TB
            AuthApi["authApi.js"]:::frontend
            AdminApi["adminApi.js"]:::frontend
            ActivitiesApi["activitiesApi.js"]:::frontend
        end
        subgraph "Contexts"
            direction TB
            AuthCtx["AuthContext.jsx"]:::frontend
            ThemeCtx["ThemeContext.jsx"]:::frontend
        end
        subgraph "Hooks"
            direction TB
            UseApi["useApi.js"]:::frontend
            UseAuth["useAuth.js"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            Login["Login.jsx"]:::frontend
            Register["Register.jsx"]:::frontend
            ProtectedRoute["ProtectedRoute.jsx"]:::frontend
            HomePage["HomePage.jsx"]:::frontend
            RegisterPage["RegisterPage.jsx"]:::frontend
            LoginPage["LoginPage.jsx"]:::frontend
            Statstique["Statstique.jsx"]:::frontend
            Volunteers["VolunteersPage.jsx"]:::frontend
            Navbar["Navbar.jsx"]:::frontend
            Footer["Footer.jsx"]:::frontend
            Hero["HeroSection.jsx"]:::frontend
            About["AboutSection.jsx"]:::frontend
            ActivitiesSection["ActivitiesSection.jsx"]:::frontend
            News["NewsSection.jsx"]:::frontend
            Contact["ContactForm.jsx"]:::frontend
            Map["MapLocation.jsx"]:::frontend
            Layout["layout.jsx"]:::frontend
        end
        subgraph "Services"
            direction TB
            MockData["mockData.js"]:::frontend
        end
    end

    Browser["User Browser"]:::external
    Vite["Vite Dev Server"]:::frontend

    Browser --> Vite
    Vite --> FEEntry
    FEEntry --> FEApp
    FEApp --> AuthApi
    FEApp --> AdminApi
    FEApp --> ActivitiesApi
    FEApp --> AuthCtx
    FEApp --> ThemeCtx
    FEApp --> UseApi
    FEApp --> UseAuth
    FEApp --> Login
    FEApp --> Register
    FEApp --> ProtectedRoute
    FEApp --> HomePage
    FEApp --> RegisterPage
    FEApp --> LoginPage
    FEApp --> Statstique
    FEApp --> Volunteers
    FEApp --> Navbar
    FEApp --> Footer
    FEApp --> Hero
    FEApp --> About
    FEApp --> ActivitiesSection
    FEApp --> News
    FEApp --> Contact
    FEApp --> Map
    FEApp --> Layout
    FEApp --> MockData

    subgraph "Backend (Express API)"
        direction TB
        Server["server.js"]:::backend
        DBConfig["db.js"]:::backend
        subgraph "Models"
            direction TB
            UserModel["User.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthController["authController.js"]:::backend
            AdminController["adminController.js"]:::backend
        end
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            AdminRoutes["adminRoutes.js"]:::backend
            RootRouter["index.js"]:::backend
        end
        subgraph "Middlewares"
            direction TB
            AuthMiddleware["authMiddleware.js"]:::backend
            ValidationMiddleware["validationMiddleware.js"]:::backend
        end
    end

    FEApp -->|"REST API calls"| Server
    Server --> DBConfig
    Server --> AuthMiddleware
    Server --> ValidationMiddleware
    AuthMiddleware --> AuthController
    ValidationMiddleware --> AdminController
    Server --> UserModel
    UserModel --> DBConfig
    AuthController -->|reads/writes| UserModel
    AdminController -->|reads/writes| UserModel
    Server -->|connects to| Database[(MongoDB)]:::db
    Server -->|process donation| Payment["Payment Service"]:::external
    Server -->|send email| Email["Email Service"]:::external

    classDef frontend fill:#D0E6FF,stroke:#0366D6,stroke-width:1px
    classDef backend fill:#E6FFEA,stroke:#28A745,stroke-width:1px
    classDef db fill:#FFE6AA,stroke:#D39E00,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#999999,stroke-dasharray:5 5

    click FEEntry "https://github.com/alap06/crt_platforme/blob/main/frontend/src/main.jsx"
    click FEApp "https://github.com/alap06/crt_platforme/blob/main/frontend/src/App.jsx"
    click AuthApi "https://github.com/alap06/crt_platforme/blob/main/frontend/src/api/authApi.js"
    click AdminApi "https://github.com/alap06/crt_platforme/blob/main/frontend/src/api/adminApi.js"
    click ActivitiesApi "https://github.com/alap06/crt_platforme/blob/main/frontend/src/api/activitiesApi.js"
    click AuthCtx "https://github.com/alap06/crt_platforme/blob/main/frontend/src/context/AuthContext.jsx"
    click ThemeCtx "https://github.com/alap06/crt_platforme/blob/main/frontend/src/context/ThemeContext.jsx"
    click UseApi "https://github.com/alap06/crt_platforme/blob/main/frontend/src/hooks/useApi.js"
    click UseAuth "https://github.com/alap06/crt_platforme/blob/main/frontend/src/hooks/useAuth.js"
    click Login "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Login.jsx"
    click Register "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Register.jsx"
    click ProtectedRoute "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/ProtectedRoute.jsx"
    click HomePage "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Pages/HomePage.jsx"
    click RegisterPage "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Pages/RegisterPage.jsx"
    click LoginPage "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Pages/LoginPage.jsx"
    click Statstique "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Pages/Statstique.jsx"
    click Volunteers "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Pages/VolunteersPage.jsx"
    click Navbar "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Navbar.jsx"
    click Footer "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/Footer.jsx"
    click Hero "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/HeroSection.jsx"
    click About "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/AboutSection.jsx"
    click ActivitiesSection "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/ActivitiesSection.jsx"
    click News "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/NewsSection.jsx"
    click Contact "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/ContactForm.jsx"
    click Map "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/MapLocation.jsx"
    click Layout "https://github.com/alap06/crt_platforme/blob/main/frontend/src/compouments/layout.jsx"
    click MockData "https://github.com/alap06/crt_platforme/blob/main/frontend/src/services/mockData.js"
    click Server "https://github.com/alap06/crt_platforme/blob/main/backend/server.js"
    click DBConfig "https://github.com/alap06/crt_platforme/blob/main/backend/config/db.js"
    click UserModel "https://github.com/alap06/crt_platforme/blob/main/backend/models/User.js"
    click AuthController "https://github.com/alap06/crt_platforme/blob/main/backend/controllers/authController.js"
    click AdminController "https://github.com/alap06/crt_platforme/blob/main/backend/controllers/adminController.js"
    click AuthRoutes "https://github.com/alap06/crt_platforme/blob/main/backend/routes/authRoutes.js"
    click AdminRoutes "https://github.com/alap06/crt_platforme/blob/main/backend/routes/adminRoutes.js"
    click RootRouter "https://github.com/alap06/crt_platforme/blob/main/backend/routes/index.js"
    click AuthMiddleware "https://github.com/alap06/crt_platforme/blob/main/backend/middlewares/authMiddleware.js"
    click ValidationMiddleware "https://github.com/alap06/crt_platforme/blob/main/backend/middlewares/validationMiddleware.js"
```
