# esgi-doctodoc/doctodoc-api architecture

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

- Interactive diagram: https://gitdiagram.com/esgi-doctodoc/doctodoc-api
- Repository: https://github.com/esgi-doctodoc/doctodoc-api

## Overview

##### Project type and purpose
- This is a Java-based, monolithic, backend API built with Spring Boot 3 (Java 21).
- It follows a hexagonal (ports & adapters) architecture to orchestrate healthcare workflows between patients, doctors, and administrators.

##### File structure
- Top-level: Dockerfile, GitHub Actions CI/CD workflows, pom.xml.
- src/main/java/fr/esgi/doctodocapi: divided into
- configuration – Spring beans, filters, clocks, OpenAPI
- infrastructure – adapter implementations for JPA, external APIs (address, SMS, email, Firebase), S3, Stripe, cron jobs, JWT, WebSockets
- model – domain entities, value objects, exceptions, repositories interfaces
- use_cases – application services (ports in/out, DTOs, business logic)
- presentation – REST controllers, error handlers, response wrappers
- src/main/resources: application properties sample
- src/test: unit and integration tests

##### README for additional insights
- Describes features for Patients, Doctors, Admins.
- Mentions core business logic lives in DoctoDoc API.
- Confirms hexagonal design (configuration → infrastructure → model → use_cases → presentation).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Container
    subgraph "Docker Container" 
        direction TB
        %% Configuration Layer
        subgraph "Configuration" 
            direction TB
            CFG["Configuration"]:::layer
        end

        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB
            PC["API Layer (Controllers)"]:::layer
        end

        %% Application Layer
        subgraph "Use Cases Layer" 
            direction TB
            UC["Use Case Services & Ports"]:::layer
        end

        %% Domain Core
        subgraph "Domain Core" 
            direction TB
            DC["Domain Entities & Repository Interfaces"]:::layer
        end

        %% Infrastructure Layer
        subgraph "Infrastructure Adapters" 
            direction TB
            JPA["JPA / Relational DB Adapter"]:::layer
            ADDR["External Address API Adapter"]:::layer
            SMS["SMS Service Adapter"]:::layer
            BREVO["Email (Brevo) Adapter"]:::layer
            S3["AWS S3 Storage Adapter"]:::layer
            FIREBASE["Firebase Push Notifications"]:::layer
            STRIPE["Stripe Payments Service"]:::layer
            CRON["Cron Jobs Scheduler"]:::layer
            JWT["JWT Security Service"]:::layer
            SEC["API Key & WebSecurity Filters"]:::layer
            WS["WebSockets Configuration"]:::layer
        end

        %% Main Entry
        MAIN["MainApplication"]:::layer

        %% Inter-layer Relationships
        PC -->|"invoke"| UC
        UC -->|"use domain"| DC
        UC -->|"outbound ports"| JPA
        UC -->|"outbound ports"| ADDR
        UC -->|"outbound ports"| SMS
        UC -->|"outbound ports"| BREVO
        UC -->|"outbound ports"| S3
        UC -->|"outbound ports"| FIREBASE
        UC -->|"outbound ports"| STRIPE
        UC -->|"schedule calls"| CRON
        PC -->|"secured by"| SEC
        SEC -->|"uses"| JWT
        CFG -->|"provides beans to"| PC
        CFG -->|"provides beans to"| UC
        CFG -->|"provides beans to"| JPA
        CFG -->|"provides beans to"| WS
        MAIN --> CFG
        MAIN --> PC
        MAIN --> UC
        MAIN --> DC
        MAIN --> JPA

        %% External Services & DB
        DB[(Relational Database)]:::db
        APIAddress((Address Autocomplete API)):::external
        SMSAPI((SMS Gateway)):::external
        Brevo((Brevo Email Service)):::external
        S3Cloud((AWS S3)):::external
        Firebase((Firebase Cloud Messaging)):::external
        StripeExt((Stripe API)):::external

        JPA -->|"JDBC"| DB
        ADDR -->|"HTTP"| APIAddress
        SMS -->|"HTTP"| SMSAPI
        BREVO -->|"HTTP"| Brevo
        S3 -->|"SDK"| S3Cloud
        FIREBASE -->|"SDK"| Firebase
        STRIPE -->|"HTTP"| StripeExt

    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        CI["GitHub Actions"]:::ci -->|"build & test"| ContainerRegistry
        ContainerRegistry["Container Registry"]:::ci -->|"deploy"| StageEnv
        ContainerRegistry -->|"deploy"| ProdEnv
    end

    classDef layer fill:#D0E6FF,stroke:#000,stroke-width:1px
    classDef db fill:#C6F5C6,stroke:#000,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#000,stroke-width:1px
    classDef ci fill:#FFF2C6,stroke:#000,stroke-width:1px

    %% Click Events
    click PC "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/presentation"
    click UC "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/use_cases"
    click DC "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/model"
    click CFG "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/configuration"
    click JPA "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/jpa"
    click ADDR "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/api_address"
    click SMS "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/api_sms"
    click BREVO "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/brevo"
    click S3 "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/s3"
    click FIREBASE "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/firebase"
    click STRIPE "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/src/main/java/fr/esgi/doctodocapi/infrastructure/services/StripeService.java"
    click CRON "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/cronner"
    click JWT "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/src/main/java/fr/esgi/doctodocapi/infrastructure/jwt/JwtService.java"
    click SEC "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/main/java/fr/esgi/doctodocapi/infrastructure/security/config"
    click WS "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/src/main/java/fr/esgi/doctodocapi/infrastructure/message_config/WebSocketConfig.java"
    click MAIN "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/src/main/java/fr/esgi/doctodocapi/MainApplication.java"
    click CI "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/ .github/workflows/ci.yml"
    click ContainerRegistry "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/Dockerfile"
    click StageEnv "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/.github/workflows/deploy-stage.yml"
    click ProdEnv "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/.github/workflows/deploy-prod.yml"
    click CI "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/ .github/workflows/create-release.yml"
    click CFG "https://github.com/esgi-doctodoc/doctodoc-api/blob/main/src/main/resources/application.properties.example"
    click DB "https://github.com/esgi-doctodoc/doctodoc-api/tree/main/src/test/java/fr/esgi/doctodocapi"
```
