# dambkz/projet2-cartocodile architecture

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

- Interactive diagram: https://gitdiagram.com/dambkz/projet2-cartocodile
- Repository: https://github.com/dambkz/projet2-cartocodile

## Overview

##### Main System Components

a) Frontend (Client)
- React Application
- Key components: Router, Pages, Components, Context
- Assets and Static Files
- Environment Configuration

b) Backend (Server)
- Express Application
- Module-based Architecture
- Database Connection Layer
- API Routes
- Testing Infrastructure

c) Database
- MySQL Server
- Schema Management
- Migrations System

##### Detailed Component Breakdown

Frontend Layer:
- Pages (Home, About, Gamepage)
- Components hierarchy
- Context management (PseudoData)
- Router configuration
- Asset management

Backend Layer:
- Express application core
- Modular architecture with:
- Item module (actions & repository)
- Database client
- Router configuration
- Testing infrastructure
- Environment configuration

Database Layer:
- MySQL server
- Schema management
- Migration system
- Seeding capability

##### Connection and Data Flow

- HTTP/REST communication between frontend and backend
- Database queries between backend and MySQL
- WebSocket connections (if implemented)
- File system interactions for static assets

##### Infrastructure Components

Containers for:
- Docker configuration
- Traefik reverse proxy
- Environment configuration
- GitHub Actions workflow

**[Client Layer]**

- React App
- Router
- Pages
- Components
- Context

- ▼ HTTP/REST
**[Server Layer]**

- Express App
- Router
- Modules
- Item Module
- Middleware

- ▼ SQL Queries
**[Database Layer]**

- MySQL
- Schema
- Migrations

**[Infrastructure]**
- Docker
- Traefik
- GitHub Actions

##### Additional Elements

- Environment configuration flow
- Testing infrastructure
- Build and deployment pipeline
- Security middleware
- Error handling flow
- Data validation layers

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        React["React Application"]
        Router["Router"]
        Pages["Pages"]
        Components["Components"]
        Context["Context (PseudoData)"]
        Assets["Assets"]
        Types_FE["Types"]

        React --> Router
        React --> Pages
        React --> Components
        React --> Context
        React --> Assets
        React --> Types_FE
    end

    subgraph Server
        Express["Express Application"]
        Router_BE["Router"]
        Modules["Modules"]
        ItemModule["Item Module"]
        Testing["Testing"]
        Types_BE["Types"]
        
        Express --> Router_BE
        Express --> Modules
        Modules --> ItemModule
        Express --> Testing
        Express --> Types_BE
    end

    subgraph Database
        MySQL["MySQL Server"]
        Schema["Schema"]
        Migrations["Migrations"]
        DBClient["Database Client"]
        Seeding["Seeding"]

        MySQL --> Schema
        MySQL --> Migrations
        MySQL --> Seeding
        DBClient --> MySQL
    end

    subgraph Infrastructure
        Docker["Docker Configuration"]
        Traefik["Traefik Proxy"]
        GHActions["GitHub Actions"]
        EnvConfig["Environment Config"]
    end

    Client -->|HTTP/REST| Server
    Server -->|SQL Queries| Database
    Infrastructure -.->|Manages| Client
    Infrastructure -.->|Manages| Server
    Infrastructure -.->|Manages| Database

    %% Click events for component mapping
    click React "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/client/src/"
    click Router "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/client/src/router.tsx"
    click Pages "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/client/src/pages/"
    click Components "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/client/src/components/"
    click Context "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/client/src/context/PseudoData.tsx"
    click Assets "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/client/src/assets/"
    click Types_FE "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/client/src/types/"
    
    click Express "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/server/src/"
    click Router_BE "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/src/router.ts"
    click Modules "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/server/src/modules/"
    click ItemModule "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/server/src/modules/item/"
    click Testing "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/server/tests/"
    click Types_BE "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/server/src/types/"
    
    click DBClient "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/database/client.ts"
    click Schema "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/database/schema.sql"
    click Migrations "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/bin/migrate.ts"
    click Seeding "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/bin/seed.ts"
    
    click Docker "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/Dockerfile"
    click GHActions "https://github.com/DamBKZ/Projet2-Cartocodile/tree/main/.github/workflows/"
    click EnvConfig "https://github.com/DamBKZ/Projet2-Cartocodile/blob/main/server/.env.sample"

    %% Styling
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px
    classDef database fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#E6E6E6,stroke:#333,stroke-width:2px

    class React,Router,Pages,Components,Context,Assets,Types_FE frontend
    class Express,Router_BE,Modules,ItemModule,Testing,Types_BE backend
    class MySQL,Schema,Migrations,DBClient,Seeding database
    class Docker,Traefik,GHActions,EnvConfig infrastructure
```
