# tomfregonese/le-livre-dont-vous-etes-le-heros architecture

> Architecture diagram of the GitHub repository tomfregonese/le-livre-dont-vous-etes-le-heros, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomfregonese/le-livre-dont-vous-etes-le-heros
- Repository: https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros

## Overview

##### Project type and purpose
- This is a three-module Java backend application using Maven and Spring Boot.
- It follows a clean/hexagonal (ports and adapters) style:
- narraty-web-api: HTTP entry point (controllers, filters, security, Swagger)
- narraty-core: domain, DTOs, use-cases (application/business logic), ports (interfaces)
- narraty-infrastructure: adapters (JPA entities, Spring Data repositories, service implementations)
- It implements “Le livre dont vous êtes le héros” – an interactive story engine with tales, scenes, choices and user sessions.

##### File structure
- Top‐level modules:
- narraty-web-api (presentation layer)
- narraty-core (application + domain layer)
- narraty-infrastructure (infrastructure layer)
- Core patterns:
- DTOsCore, exceptions, interfaces (ports), models (domain entities), usecases (application services), validators
- Infrastructure provides repository adapters and service implementations for the core ports
- Web-API contains REST controllers, request/response DTOs, security config, authentication filter, Swagger

##### README insights
- We derive architecture solely from file organization and naming.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    User["Player/Author"]:::external
    SwaggerUI["Swagger UI"]:::external

    %% Web/API Layer
    subgraph "Web/API Layer (narraty-web-api)" 
        direction TB
        NarratyApp["NarratyApplication"]:::web
        SecurityConfig["SecurityConfig"]:::web
        SwaggerConfig["SwaggerConfig"]:::web
        AuthFilter["BearerAuthenticationFilter"]:::web
        AuthController["AuthController"]:::web
        EditStoryController["EditStoryController"]:::web
        PlayStoryController["PlayStoryController"]:::web
        PublicStoryController["PublicStoryController"]:::web
        WebDTOs["Web DTOs"]:::web
        AppProps["application.properties"]:::web
    end

    %% Core Layer
    subgraph "Core Layer (narraty-core)"
        direction TB
        CoreDTOs["Core DTOs"]:::core
        CoreExceptions["Core Exceptions"]:::core
        PortsDAOs["Core Ports - DAOs"]:::core
        PortsServices["Core Ports - Services"]:::core
        DomainModels["Domain Models"]:::core
        UseCases["Use-Cases"]:::core
        Validators["Validators"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer (narraty-infrastructure)"
        direction TB
        Entities["JPA Entities"]:::infra
        ReposAdapters["Repositories & Adapters"]:::infra
        PasswordService["PasswordService"]:::infra
        SessionService["SessionService"]:::infra
    end

    %% Database
    Database[(Relational Database)]:::db

    %% Flow Arrows
    User -->|HTTP Request| AuthFilter
    SwaggerUI -->|HTTP Request| NarratyApp
    AuthFilter -->|Authenticated Call| AuthController
    AuthFilter -->|Authenticated Call| EditStoryController
    AuthFilter -->|Authenticated Call| PlayStoryController
    User -->|Public Call| PublicStoryController

    AuthController -->|uses| WebDTOs
    EditStoryController -->|uses| WebDTOs
    PlayStoryController -->|uses| WebDTOs
    PublicStoryController -->|uses| WebDTOs

    AuthController -->|calls| UseCases
    EditStoryController -->|calls| UseCases
    PlayStoryController -->|calls| UseCases
    PublicStoryController -->|calls| UseCases

    UseCases -->|validates| Validators
    UseCases -->|uses| DomainModels
    UseCases -->|calls DAO Port| PortsDAOs
    UseCases -->|calls Service Port| PortsServices

    PortsDAOs -->|implemented by| ReposAdapters
    PortsServices -->|implemented by| PasswordService
    PortsServices -->|implemented by| SessionService

    ReposAdapters -->|JPA| Database
    PasswordService -->|DB Access| Database
    SessionService -->|DB Access| Database

    %% Click Events
    click NarratyApp "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/NarratyApplication.java"
    click SecurityConfig "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/config/SecurityConfig.java"
    click SwaggerConfig "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/config/SwaggerConfig.java"
    click AuthFilter "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/middlewares/BearerAuthenticationFilter.java"
    click AuthController "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/controllers/AuthController.java"
    click EditStoryController "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/controllers/EditStoryController.java"
    click PlayStoryController "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/controllers/PlayStoryController.java"
    click PublicStoryController "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/controllers/PublicStoryController.java"
    click WebDTOs "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-web-api/src/main/java/com/ynov/javaformation/narraty/dtos/"
    click CoreDTOs "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/dtosCore/"
    click CoreExceptions "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/exceptions/"
    click PortsDAOs "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/interfaces/daos/"
    click PortsServices "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/interfaces/services/"
    click DomainModels "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/models/"
    click UseCases "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/usecase/"
    click Validators "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-core/src/main/java/com/ynov/javaformation/narraty/validators/"
    click Entities "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-infrastructure/src/main/java/com/ynov/javaformation/narraty/data/entities/"
    click ReposAdapters "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/tree/main/narraty-infrastructure/src/main/java/com/ynov/javaformation/narraty/data/repositories/"
    click PasswordService "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-infrastructure/src/main/java/com/ynov/javaformation/narraty/services/PasswordService.java"
    click SessionService "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-infrastructure/src/main/java/com/ynov/javaformation/narraty/services/SessionService.java"
    click AppProps "https://github.com/tomfregonese/le-livre-dont-vous-etes-le-heros/blob/main/narraty-web-api/src/main/resources/application.properties"

    %% Styles
    classDef web fill:#D6EAF8,stroke:#2980B9,color:#1B4F72
    classDef core fill:#D5F5E3,stroke:#27AE60,color:#145A32
    classDef infra fill:#FAD7A0,stroke:#D68910,color:#7E5109
    classDef external fill:#F5F5F5,stroke:#AAB7B8,color:#566573
    classDef db fill:#D5D8DC,stroke:#5D6D7E,color:#2C3E50,stroke-width:2px,shape:cylinder
```
