# peedro10/projet_myski architecture

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

- Interactive diagram: https://gitdiagram.com/peedro10/projet_myski
- Repository: https://github.com/peedro10/projet_myski

## Overview

##### Project type and purpose
- This is a full-stack web application (“Projet Station de Ski”) comprising:
- A React-based Single Page Application (frontend)
- A Node.js/Express REST API (backend)
- A MySQL database storing pistes, remontées, users, comments, itineraires, chats
- Purpose: allow authenticated users to view and modify ski-lift and piste states, post comments, plan itineraries, and chat in real time.

##### File structure
- Top-level separation:
- api/ – backend code
- frontend/ – React SPA
- Backend (api/): follows an MVC-style layout
- index.cjs – Express app bootstrap
- routes/ – Express route definitions per resource
- controllers/ – business logic for auth, chats, commentaires, itineraires, pistes, remontées
- models/ – data schemas and queries against MySQL
- middleware/ – auth checks, error handling
- .cjs + .env – database connection
- Frontend (frontend/): React application
- src/components – UI building blocks (Navbar, Footer, Sections)
- src/pages – page views (Home, Login, Chats, Comments, Itineraires, etc.)
- src/context – React Contexts (auth, darkMode, PrivateRoute)
- public/index.html – SPA entry point
- Deployment and CI:
- .github/workflows/main.yml – CI pipeline
- 2024ski.sql – initial database schema

##### Key insights from the README
- Lists features: authentication, CRUD on pistes/remontées, comments, itineraries, internal chat
- Tech stack: Node.js, Express, MySQL, React
- Run steps: separate npm scripts for api and frontend

##### Detail and essential elements
- Even small pieces (e.g., connect.cjs for DB connection, .env)
- REST endpoint class (auth, users, pistes, remontees, commentaires, chats, itineraires)
- Flow of authentication token from frontend to middleware to controllers
- Optional: show sequence of a typical user action (e.g., “Change Piste State”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (SPA)"
        direction TB
        INDEX["index.html"]:::frontend
        APP["App.js"]:::frontend
        subgraph "Context Providers"
            direction TB
            AUTHCTX["authContext.js"]:::frontend
            DARKCTX["darkModeContext.js"]:::frontend
            PRIVCTX["PrivateRoute.jsx"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            NAV["Navbar.jsx"]:::frontend
            FOOT["Footer.jsx"]:::frontend
            ARTCOMP["ArticlesSection.jsx"]:::frontend
            PAGECOMP["Page.jsx"]:::frontend
        end
        subgraph "Pages"
            direction TB
            HOME["Home.jsx"]:::frontend
            LOGIN["Login.jsx"]:::frontend
            REGISTER["Register.jsx"]:::frontend
            CHATS_PAGE["Chats.jsx"]:::frontend
            COM_PISTES["CommentairesPistes.jsx"]:::frontend
            COM_REM["CommentairesRemontees.jsx"]:::frontend
            ITIN["Itineraires.jsx"]:::frontend
            PISTES_PAGE["Pistes.jsx"]:::frontend
            REM_PAGE["Remontees.jsx"]:::frontend
        end
        INDEX --> APP
        APP --> AUTHCTX
        APP --> DARKCTX
        APP --> PRIVCTX
        APP --> NAV
        APP --> FOOT
        APP --> ARTCOMP
        APP --> PAGECOMP
        APP --> HOME
        APP --> LOGIN
        APP --> REGISTER
        APP --> CHATS_PAGE
        APP --> COM_PISTES
        APP --> COM_REM
        APP --> ITIN
        APP --> PISTES_PAGE
        APP --> REM_PAGE
    end

    Browser["Browser"]:::external
    Browser -->|"HTTP(S)"| APP

    subgraph "Backend (Express API)"
        direction TB
        INDEX_API["index.cjs"]:::backend
        ENV[".env"]:::backend
        CONNECT["connect.cjs"]:::backend
        subgraph "Middleware"
            direction TB
            AUTH_MW["authMiddleware.cjs"]:::backend
            ERR_MW["errorHandlingMiddleware.cjs"]:::backend
        end
        MW_ORDER[/"Middleware Layer"/]:::backend
        subgraph "Routes"
            direction TB
            ROUTES["routes/"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AUTH_CTRL["auth.cjs"]:::backend
            USER_CTRL["user.cjs"]:::backend
            PISTE_CTRL["piste.cjs"]:::backend
            REM_CTRL["remontee.cjs"]:::backend
            COM_P_CTRL["commentaires_pistes.cjs"]:::backend
            COM_R_CTRL["commentaires_remontees.cjs"]:::backend
            ITI_CTRL["itineraires.cjs"]:::backend
            CHAT_CTRL["chats.cjs"]:::backend
        end
        subgraph "Models"
            direction TB
            MODELS["models/"]:::backend
        end
        DB["MySQL Database"]:::db
        INDEX_API --> ENV
        INDEX_API --> MW_ORDER
        MW_ORDER --> AUTH_MW
        MW_ORDER --> ERR_MW
        MW_ORDER --> ROUTES
        ROUTES --> AUTH_CTRL
        ROUTES --> USER_CTRL
        ROUTES --> PISTE_CTRL
        ROUTES --> REM_CTRL
        ROUTES --> COM_P_CTRL
        ROUTES --> COM_R_CTRL
        ROUTES --> ITI_CTRL
        ROUTES --> CHAT_CTRL
        AUTH_CTRL --> MODELS
        USER_CTRL --> MODELS
        PISTE_CTRL --> MODELS
        REM_CTRL --> MODELS
        COM_P_CTRL --> MODELS
        COM_R_CTRL --> MODELS
        ITI_CTRL --> MODELS
        CHAT_CTRL --> MODELS
        MODELS --> CONNECT
        CONNECT --> DB
    end

    Browser -->|"API Calls"| INDEX_API
    APP -->|"API Calls"| INDEX_API
    INDEX_API --> DB

    subgraph "Infrastructure"
        direction TB
        CI["GitHub Actions"]:::ci
        SCHEMA["2024ski.sql"]:::db
    end

    CI --> INDEX_API
    SCHEMA --> DB

    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px;
    classDef backend fill:#D0FFD8,stroke:#333,stroke-width:1px;
    classDef db fill:#FFE4B5,stroke:#333,stroke-width:1px;
    classDef ci fill:#E8E8E8,stroke:#333,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#333,stroke-width:1px;

    click INDEX "https://github.com/peedro10/projet_myski/blob/main/frontend/public/index.html"
    click APP "https://github.com/peedro10/projet_myski/blob/main/frontend/src/App.js"
    click AUTHCTX "https://github.com/peedro10/projet_myski/blob/main/frontend/src/context/authContext.js"
    click DARKCTX "https://github.com/peedro10/projet_myski/blob/main/frontend/src/context/darkModeContext.js"
    click PRIVCTX "https://github.com/peedro10/projet_myski/blob/main/frontend/src/context/PrivateRoute.jsx"
    click NAV "https://github.com/peedro10/projet_myski/blob/main/frontend/src/components/navbar/Navbar.jsx"
    click FOOT "https://github.com/peedro10/projet_myski/blob/main/frontend/src/components/footer/Footer.jsx"
    click ARTCOMP "https://github.com/peedro10/projet_myski/blob/main/frontend/src/components/articlessection/ArticlesSection.jsx"
    click PAGECOMP "https://github.com/peedro10/projet_myski/blob/main/frontend/src/components/pageski/Page.jsx"
    click HOME "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/home/Home.jsx"
    click LOGIN "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/login/Login.jsx"
    click REGISTER "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/register/Register.jsx"
    click CHATS_PAGE "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/chats/Chats.jsx"
    click COM_PISTES "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/commentsPistes/CommentairesPistes.jsx"
    click COM_REM "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/commentsRemontees/CommentairesRemontees.jsx"
    click ITIN "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/itineraires/Itineraires.jsx"
    click PISTES_PAGE "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/pistes/Pistes.jsx"
    click REM_PAGE "https://github.com/peedro10/projet_myski/blob/main/frontend/src/pages/remontees/Remontees.jsx"
    click INDEX_API "https://github.com/peedro10/projet_myski/blob/main/api/index.cjs"
    click ENV "https://github.com/peedro10/projet_myski/blob/main/api/.env"
    click CONNECT "https://github.com/peedro10/projet_myski/blob/main/api/connect.cjs"
    click AUTH_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/auth.cjs"
    click USER_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/user.cjs"
    click PISTE_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/piste.cjs"
    click REM_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/remontee.cjs"
    click COM_P_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/commentaires_pistes.cjs"
    click COM_R_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/commentaires_remontees.cjs"
    click ITI_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/itineraires.cjs"
    click CHAT_CTRL "https://github.com/peedro10/projet_myski/blob/main/api/controllers/chats.cjs"
    click AUTH_MW "https://github.com/peedro10/projet_myski/blob/main/api/middleware/authMiddleware.cjs"
    click ERR_MW "https://github.com/peedro10/projet_myski/blob/main/api/middleware/errorHandlingMiddleware.cjs"
    click ROUTES "https://github.com/peedro10/projet_myski/tree/main/api/routes/"
    click MODELS "https://github.com/peedro10/projet_myski/tree/main/api/models/"
    click CI "https://github.com/peedro10/projet_myski/blob/main/.github/workflows/main.yml"
    click SCHEMA "https://github.com/peedro10/projet_myski/blob/main/2024ski.sql"
```
