# zakariaghrib/nfccard architecture

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

- Interactive diagram: https://gitdiagram.com/zakariaghrib/nfccard
- Repository: https://github.com/zakariaghrib/nfccard

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React and Vite.
- Purpose: an educational administration dashboard with two roles (admin and professeur) supporting login, dashboard views, CRUD pages (etudiants, filieres, modules, présences, salles, séances), and live presence tracking.

##### File structure
- Top level: package.json, vite.config.js, index.html, public/ (static assets), src/ (application source).
- src/main.jsx & index.html: entry points for the React app.
- src/App.jsx: root component that sets up routing and global providers.
- src/layouts: layout wrappers (AdminLayout, ProfLayout) handling common UI shell per role.
- src/pages: role‐specific pages under admin/ and professeur/.
- src/components: reusable components (DashboardWidget, Sidebar variants).
- src/assets: images and static assets referenced by components.
- Configs: eslint.config.js for lint rules, vite.config.js for build/dev-server behavior.

##### Key insights from README
- Uses Vite for fast bundling and HMR.
- React refreshed via plugin-react or plugin-react-swc.
- ESLint integration recommended for code quality.

##### Main components
a. Client (Browser)
- Runs the built SPA, interacts via HTTP(s) to backend APIs.
b. Frontend Application
- Vite Dev Server (during development with HMR).
- Bundler/Build pipeline (vite build producing static assets).
- React App
- EntryPoint: index.html + main.jsx
- Core Modules: App.jsx (router), Layouts, Pages, Components, Assets, Stylesheet (index.css)
c. Backend API Layer (external to this repo)
- Authentication service (login endpoint, JWT or session)
- Data service for students, filieres, modules, presence, salles, séances
d. Persistent Storage
- Relational or NoSQL database behind the API
e. Optional services
- CDN for serving static assets (the built SPA)
- Monitoring/logging (e.g., Sentry, Datadog)
- CI/CD pipeline invoking vite build, lint, tests, and deployment

##### Relationships and interactions
- Browser → (HTTP) → Frontend App (served by CDN or static server)
- Frontend App → (REST/GraphQL calls) → Backend API
- API → (DB queries) → Database
- Vite Dev Server ↔ Browser (WebSocket HMR) during development
- CI/CD → (build & deploy) → Static hosting / CDN & API hosting

##### Architectural patterns and principles
- Component‐based UI (React) with separation of concerns: Layout vs. Page vs. UI Component
- Role‐based routing and layout composition (AdminLayout, ProfLayout)
- Asset‐folder pattern: public vs. src/assets for static vs. imported assets
- Build vs. Dev environments managed by Vite config
- Linting as part of CI to enforce code quality

##### Detail
- Every layer from developer workflow (lint, dev‐server, HMR) through build (vite build) to deployment (static host).
- Clearly separate reusable “components” vs. “pages” vs. “layouts.”
- Role‐based UI flows: e.g., after login, user is routed to AdminLayout or ProfLayout.
- Do not overcrowd: use zoom‐in callouts for deep dives (e.g., inside src/components).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Workflow
    subgraph "Development Environment" 
        direction TB
        ESLintConfig["eslint.config.js"]:::service
        ViteDev["Vite Dev Server\n(HMR & Plugin React)"]:::service
        BrowserDev["Browser"]:::ui
        ESLintConfig -->|"Lint Code"| ViteDev
        ViteDev -->|"Serves (Dev) Static Files & HMR via WebSocket"| BrowserDev
    end

    %% Production Build & Deploy
    subgraph "Production Pipeline"
        direction TB
        CI["CI/CD Pipeline"]:::service
        ViteBuild["Vite Build\n(Static Asset Bundler)"]:::service
        StaticHost["CDN / Static Host"]:::external
        CI -->|"Run Build & Lint & Tests"| ViteBuild
        ViteBuild -->|"Deploy Static Assets"| StaticHost
        StaticHost -->|"Serves SPA"| Browser
    end

    %% Browser Client
    Browser["Browser"]:::ui

    %% Frontend Application Structure
    subgraph "Frontend Application (src)" 
        direction TB
        subgraph "Entry Point"
            direction TB
            HTML["index.html"]:::ui
            MainJS["main.jsx"]:::ui
        end
        subgraph "Core App"
            direction TB
            AppJS["App.jsx\n(Router & Providers)"]:::ui
        end
        subgraph "Layouts"
            direction TB
            AdminLayout["AdminLayout.jsx"]:::ui
            ProfLayout["ProfLayout.jsx"]:::ui
        end
        subgraph "Pages"
            direction TB
            LoginPage["LoginPage.jsx"]:::ui
            subgraph "Admin Pages"
                direction TB
                AdminDashboard["Dashboard.jsx"]:::ui
                Etudiants["etudiants.jsx"]:::ui
                Filieres["filieres.jsx"]:::ui
                Modules["modules.jsx"]:::ui
                Presences["presence.jsx"]:::ui
                Professeurs["professeurs.jsx"]:::ui
                Salles["salles.jsx"]:::ui
                Seances["seances.jsx"]:::ui
            end
            subgraph "Professeur Pages"
                direction TB
                ProfDashboard["DashboardProf.jsx"]:::ui
                MesSeances["MesSeances.jsx"]:::ui
                PresenceLive["PresenceLive.jsx"]:::ui
            end
        end
        subgraph "Shared Components"
            direction TB
            DashboardWidget["DashboardWidget.jsx"]:::ui
            SidebarAdmin["Sidebar/Sidebar.jsx"]:::ui
            SidebarProf["SidebarProfesseur.jsx"]:::ui
        end
        subgraph "Assets & Styles"
            direction TB
            GlobalCSS["index.css"]:::ui
            AssetsSrc["src/assets/"]:::ui
            AssetsPublic["public/images/"]:::ui
        end

        %% Internal Component Flow
        HTML --> MainJS
        MainJS --> AppJS
        AppJS --> Layouts["Layouts"]
        Layouts --> Pages["Pages"]
        Pages --> Shared["Shared Components"]
        Shared --> Assets["Assets & Styles"]
    end

    %% API & Database Layer
    subgraph "Backend Services" 
        direction TB
        AuthService["Authentication Service\n(Login & JWT)"]:::external
        DataService["Data Service\n(CRUD API)"]:::external
        AuthService -->|Verifies & Issues Token| DataService
    end
    Database[(Database)]:::db

    %% Data Flow
    Browser -->|"REST/GraphQL Requests"| AuthService
    Browser -->|"REST/GraphQL Requests"| DataService
    DataService -->|"Queries"| Database

    %% Click Events
    click HTML "https://github.com/zakariaghrib/nfccard/blob/master/index.html"
    click MainJS "https://github.com/zakariaghrib/nfccard/blob/master/src/main.jsx"
    click AppJS "https://github.com/zakariaghrib/nfccard/blob/master/src/App.jsx"
    click AdminLayout "https://github.com/zakariaghrib/nfccard/blob/master/src/layouts/AdminLayout.jsx"
    click ProfLayout "https://github.com/zakariaghrib/nfccard/blob/master/src/layouts/ProfLayout.jsx"
    click LoginPage "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/LoginPage.jsx"
    click AdminDashboard "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/Dashboard.jsx"
    click Etudiants "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/etudiants.jsx"
    click Filieres "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/filieres.jsx"
    click Modules "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/modules.jsx"
    click Presences "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/presence.jsx"
    click Professeurs "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/professeurs.jsx"
    click Salles "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/salles.jsx"
    click Seances "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/admin/seances.jsx"
    click ProfDashboard "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/professeur/DashboardProf.jsx"
    click MesSeances "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/professeur/MesSeances.jsx"
    click PresenceLive "https://github.com/zakariaghrib/nfccard/blob/master/src/pages/professeur/PresenceLive.jsx"
    click DashboardWidget "https://github.com/zakariaghrib/nfccard/blob/master/src/components/DashboardWidget.jsx"
    click SidebarAdmin "https://github.com/zakariaghrib/nfccard/blob/master/src/components/Sidebar/Sidebar.jsx"
    click SidebarProf "https://github.com/zakariaghrib/nfccard/blob/master/src/components/Sidebar/SidebarProfesseur.jsx"
    click GlobalCSS "https://github.com/zakariaghrib/nfccard/blob/master/src/index.css"
    click AssetsSrc "https://github.com/zakariaghrib/nfccard/tree/master/src/assets/"
    click AssetsPublic "https://github.com/zakariaghrib/nfccard/tree/master/public/images/"
    click ViteDev "https://github.com/zakariaghrib/nfccard/blob/master/vite.config.js"
    click ESLintConfig "https://github.com/zakariaghrib/nfccard/blob/master/eslint.config.js"

    %% Styles
    classDef ui fill:#B3D4FC,stroke:#333,stroke-width:1px
    classDef service fill:#C3FACD,stroke:#333,stroke-width:1px
    classDef db fill:#FEE7C8,stroke:#333,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
