# quasar-30/gestiondossiermedicalanimal-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/quasar-30/gestiondossiermedicalanimal-v1
- Repository: https://github.com/quasar-30/gestiondossiermedicalanimal-v1

## Overview

##### Project Type and Purpose
- This is a full-stack monorepo containing:
- A **Spring Boot** backend (“gestionAnimaux”) exposing a JWT-secured REST API plus a WebSocket chat channel.
- A **Flutter** mobile frontend (“MonVeto”) for Android/Windows, used by two user roles (Propriétaire & Vétérinaire).
- Purpose: manage animal medical records, appointments, real-time chat, and push-style notifications.

##### File-Structure Highlights
- Top-level directories: `BACKEND/gestionAnimaux` and `FRONTEND/MonVeto`.
- Backend layers:
- **controllers/** – REST endpoints
- **service/** – business logic
- **repository/** – Spring Data JPA / MySQL
- **security/** – JWT auth, filters, WebSocket config
- Frontend layers:
- **lib/models** – DTOs mirroring backend entities
- **lib/services** – HTTP client wrappers
- **lib/constants** – API URLs, interceptors
- **lib/screens** – UI pages
- Deployment/config: Docker Compose for backend+MySQL, Maven wrapper, Flutter pubspec.

##### Key Architectural Patterns
- **Layered (n-tier) Architecture** in backend: Controllers → Services → Repositories → Database.
- **JWT Authentication** securing HTTP and WebSocket endpoints.
- **WebSocket** channel for real-time chat (ChatWebSocket).
- **Flutter client-server pattern**: UI screens call services via HTTP/WebSocket, map JSON ↔ Dart models.

##### Main Components to Illustrate
A. **Flutter Mobile Client**
- Screens/UI
- Services layer (HTTP client + AuthInterceptor)
- WebSocket client for chat
- Local storage (shared_preferences)
B. **API Gateway / Load Balancer** (optional for production)
C. **Spring Boot Application**
- REST Controllers (AnimalController, AuthController, …)
- Service Layer (AnimauxService, NotificationService, …)
- Repository Layer (Spring Data JPA interfaces)
- Security Layer (JwtUtil, AuthTokenFilter, WebSecurityConfig)
- WebSocket Config & Endpoint
D. **MySQL Database** (schema.sql)
E. **Docker Compose** environment ensuring backend + DB startup

##### Relationships & Data Flows
- Flutter → HTTP(S) → Spring Boot REST Controllers → Services → Repositories → MySQL
- Flutter → WebSocket → Spring Boot ChatWebSocket → broadcast subscribers
- JWT flow: Login → AuthController issues token → AuthInterceptor adds token to each request → WebSecurityConfig validates token
- Notifications: backend schedules reminders (e.g., via @Scheduled) → push via WebSocket or FCM (if integrated)
- Data-model consistency: DTO mapping between Entities ↔ Controllers ↔ Clients

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Flutter Mobile Client"
        direction TB
        Main["main.dart"]:::client
        Screens["UI Screens"]:::client
        ChatScreen["ChatScreen"]:::client
        Services["HTTP Services"]:::service
        AuthInterceptor["AuthInterceptor"]:::service
        ServersConstants["Servers.dart"]:::service
    end

    %% Backend Layer
    subgraph "Spring Boot Backend"
        direction TB
        Application["GestionAnimauxApplication"]:::api
        subgraph "Business API"
            Controllers["REST Controllers\n(Animal, Auth, Appointment)"]:::api
            ServicesBackend["Service Layer"]:::service
            Repository["Repository Layer"]:::service
        end
        subgraph "Data Models"
            DTOs["DTOs"]:::api
            Entities["Entities"]:::api
        end
        subgraph "Security"
            SecurityLayer["Security Layer\n(JwtUtil, AuthTokenFilter, WebSecurityConfig)"]:::api
        end
        subgraph "WebSocket"
            WebSocketConfig["WebSocketConfig"]:::message
            ChatWebSocket["ChatWebSocket"]:::message
        end
        ConfigFiles["Config Files\n(application.properties,\napplication-docker.properties)"]:::infra
    end

    %% Infrastructure
    DockerCompose["Docker Compose"]:::infra
    WaitScript["wait-for-it.sh"]:::infra
    MySQL["MySQL Database"]:::db

    %% Frontend to Backend interactions
    Main --> Screens
    Screens -->|calls HTTP| Services
    Screens -->|connects WebSocket| ChatScreen
    Services -->|uses interceptor| AuthInterceptor
    ServersConstants --> Services

    Services -->|POST /api/auth/signin\nGET /api/animal| Controllers
    ChatScreen -->|CHAT_MESSAGE| ChatWebSocket

    %% Backend internal flows
    Application --> Controllers
    Controllers --> ServicesBackend
    ServicesBackend --> Repository
    Repository --> MySQL
    Controllers --> DTOs
    Controllers --> Entities

    %% Security and WebSocket
    SecurityLayer --> Controllers
    SecurityLayer --> WebSocketConfig
    WebSocketConfig --> ChatWebSocket

    %% Deployment
    DockerCompose --> Application
    DockerCompose --> MySQL
    DockerCompose --> WaitScript

    %% Click Events
    click Main "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/FRONTEND/MonVeto/MonVeto/lib/main.dart"
    click Screens "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/FRONTEND/MonVeto/MonVeto/lib/screens"
    click ChatScreen "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/FRONTEND/MonVeto/MonVeto/lib/screens/ChatScreen.dart"
    click Services "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/FRONTEND/MonVeto/MonVeto/lib/services"
    click AuthInterceptor "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/FRONTEND/MonVeto/MonVeto/lib/Constants/AuthInterceptor.dart"
    click ServersConstants "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/FRONTEND/MonVeto/MonVeto/lib/Constants/Servers.dart"

    click Application "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/GestionAnimauxApplication.java"
    click Controllers "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/controllers"
    click ServicesBackend "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/service"
    click Repository "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/repository"
    click DTOs "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/dto"
    click Entities "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/entites"
    click SecurityLayer "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/tree/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/security"
    click WebSocketConfig "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/security/WebSocketConfig.java"
    click ChatWebSocket "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/BACKEND/gestionAnimaux/src/main/java/com/example/gestionAnimaux/security/ChatWebSocket.java"
    click DockerCompose "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/BACKEND/gestionAnimaux/docker-compose.yml"
    click WaitScript "https://github.com/quasar-30/gestiondossiermedicalanimal-v1/blob/main/BACKEND/gestionAnimaux/wait-for-it.sh"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef service fill:#bbf,stroke:#333,stroke-width:2px
    classDef api fill:#bfb,stroke:#333,stroke-width:2px
    classDef db fill:#fbb,stroke:#333,stroke-width:2px
    classDef infra fill:#ddd,stroke:#333,stroke-width:2px
    classDef message fill:#ff9,stroke:#333,stroke-width:2px
```
