# mohamedmoustir/gestion-de-banque-de-sang architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedmoustir/gestion-de-banque-de-sang
- Repository: https://github.com/mohamedmoustir/gestion-de-banque-de-sang

## Overview

##### Project type and purpose
- This is a monolithic Java EE web application (“Système de Gestion de Banque de Sang”) deployed on Apache Tomcat.
- Purpose: manage donors and receivers of blood, perform intelligent matching based on blood‐group compatibility and medical priority.

##### File structure
- Top-level artifacts: pom.xml (Maven), README.md, Tomcat conf and logs folders.
- src/main/java packages the 4 layers:
- presentation (Servlet controllers + SessionUtils)
- application (DTOs, mappers, AppService classes)
- domain (entities, enums, DAO interfaces, domain services, exceptions)
- infrastructure (DAO implementations + BaseDao, JPA/EntityManagerFactory singleton)
- src/main/resources/META-INF/persistence.xml: JPA config
- src/main/webapp: JSP views under presentation/views, static assets (CSS/JS/img), web.xml for servlet mappings
- src/test/java: JUnit tests for application services

##### README for architecture clues
- Confirms MVC pattern:
- Model = domain entities + JPA
- View = JSP + JSTL
- Controller = Servlets
- Service Layer and Repository (DAO) patterns
- Singleton used for EntityManagerFactory

##### Main components and interactions
a. Client Browser
- Sends HTTP requests (login, CRUD, match requests)
b. Web Server / Container (Tomcat)
- web.xml configures URL → Servlet mappings
- Servlets in presentation/controller handle requests
- SessionUtils manages user session
c. Presentation Layer
- Controllers call Application Layer services
- JSP pages render views with JSTL
d. Application Layer
- AppService classes orchestrate use cases (DonneurAppService, OperationAppService, etc.)
- Between DTOs and Domain Entities via Mappers
e. Domain Layer
- Domain Services implement business rules (DonneurService, LoginService…)
- DAO interfaces define data access contract (GenericDao, OperationDao, etc.)
- Entities (Account, Donneur, Receveur, Operation) + enums + exceptions
f. Infrastructure Layer
- DAO Implementations (DonneurDaoImpl, OperationDaoImpl…) using JPA/Hibernate
- Basedao / EntityManagerFactory singleton
g. Persistence / Database
- MySQL/PostgreSQL
- JPA persistence-unit configured in persistence.xml
h. Build & Deployment
- Maven builds WAR
- Optionally Docker container wrapping Tomcat
i. Testing
- JUnit tests invoking Application Services

- Browser → HTTP request → Tomcat
- Tomcat → Servlet (Controller)
- Controller → AppService → DomainService → DAO → EntityManager → Database
- Results bubble back through each layer → JSP → HTML response to Browser

##### Highlighted architectural patterns
- MVC (Controllers / Views / Models)
- Service Layer between presentation and domain
- DAO / Repository pattern for persistence decoupling
- Singleton for EntityManagerFactory
- DTO/Mapper for data transfer between layers
- JPA/Hibernate ORM

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client
    Browser["Client Browser<br/>(HTTP Requests)"]:::client -->|HTTP Request| Tomcat["Apache Tomcat"]:::container

    %% Tomcat Container Boundary
    subgraph "Tomcat Container" 
        direction TB
        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB
            Controllers["Servlet Controllers<br/>(Java EE)"]:::presentation
            SessionUtils["SessionUtils"]:::presentation
            JSP["JSP Views<br/>(JSP + JSTL)"]:::presentation
            WebXML["web.xml<br/>(Servlet Mappings)"]:::presentation
        end

        %% Application Layer
        subgraph "Application Layer"
            direction TB
            DTOs["DTOs"]:::application
            Mappers["Mappers"]:::application
            AppServices["AppService Classes"]:::application
        end

        %% Domain Layer
        subgraph "Domain Layer"
            direction TB
            Entities["Entities"]:::domain
            Enums["Enums"]:::domain
            Exceptions["Exceptions"]:::domain
            DAOInterfaces["DAO Interfaces"]:::domain
            DomainServices["Domain Services"]:::domain
        end

        %% Infrastructure Layer
        subgraph "Infrastructure Layer"
            direction TB
            DAOImpl["DAO Implementations"]:::infrastructure
            BaseDAO["BaseDao"]:::infrastructure
            JPAConfig["EntityManagerFactory Singleton"]:::infrastructure
        end

        %% Persistence
        Database["Database<br/>(MySQL/PostgreSQL)"]:::database
    end

    %% Build & Deployment
    Maven["Maven POM<br/>(pom.xml)"]:::build -->|build WAR| WAR["WAR Artifact"]:::build
    WAR -->|deploy| Tomcat

    %% Testing
    Tests["JUnit Tests<br/>(Application Services)"]:::test --> AppServices

    %% Data Flow
    Controllers -->|calls| AppServices
    AppServices -->|uses Mappers| Mappers
    AppServices -->|calls| DomainServices
    DomainServices -->|uses| DAOInterfaces
    DAOInterfaces -->|implemented by| DAOImpl
    DAOImpl -->|uses JPA| JPAConfig
    JPAConfig -->|connects to| Database
    Controllers -->|forwards to| JSP
    JSP -->|renders HTML| Browser

    %% Click Events
    click Controllers "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/presentation"
    click SessionUtils "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/blob/main/src/main/java/presentation/Utils/SessionUtils.java"
    click JSP "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/webapp/presentation/views"
    click WebXML "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/blob/main/src/main/webapp/WEB-INF/web.xml"
    click DTOs "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/application/dto"
    click Mappers "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/application/mapper"
    click AppServices "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/application/service"
    click Entities "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/domain/entity"
    click Enums "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/domain/enums"
    click Exceptions "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/domain/exception"
    click DAOInterfaces "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/domain/dao"
    click DomainServices "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/domain/service"
    click DAOImpl "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/main/java/infrastructure/persistence"
    click JPAConfig "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/blob/main/src/main/resources/META-INF/persistence.xml"
    click Maven "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/blob/main/pom.xml"
    click Tests "https://github.com/mohamedmoustir/gestion-de-banque-de-sang/tree/main/src/test/java/application/service"

    %% Styles
    classDef client fill:#87CEEB,stroke:#000,stroke-width:1px
    classDef container fill:#f0f8ff,stroke:#000,stroke-width:1px
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:1px
    classDef application fill:#90ee90,stroke:#000,stroke-width:1px
    classDef domain fill:#ffa500,stroke:#000,stroke-width:1px
    classDef infrastructure fill:#dda0dd,stroke:#000,stroke-width:1px
    classDef database fill:#d3d3d3,stroke:#000,stroke-width:1px
    classDef build fill:#ffffe0,stroke:#000,stroke-width:1px
    classDef test fill:#ffe4e1,stroke:#000,stroke-width:1px
```
