# johnbenjaminmccarthy/mathsgenealogyapi architecture

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

- Interactive diagram: https://gitdiagram.com/johnbenjaminmccarthy/mathsgenealogyapi
- Repository: https://github.com/johnbenjaminmccarthy/mathsgenealogyapi

## Overview

##### Data Flow Representation

- Client Request → Controllers → Services → [Repositories ↔ Database]
- → [Scraper ↔ External Website]

##### Key Components Detail

- Domain Models (Node, Edge, Advisor, Dissertation)
- DTOs (NodeDto, EdgeDto, etc.)
- Data conversion flow (Entity ↔ DTO)

##### Architectural Patterns to Highlight

a. Layer separation:
- Presentation (Controllers)
- Business Logic (Services)
- Data Access (Repositories)
- External Integration (Scraper)

b. Caching Strategy:
- Database caching mechanism
- 30-day refresh policy

##### Technical Stack Callouts

Technology badges or notes for:
- Spring Boot
- Hibernate
- PostgreSQL
- Docker
- Jsoup (for scraping)
- Log4j2

##### Component Interactions

- User-facing components (e.g., controllers)
- Business logic (services)
- Data persistence (repositories and database)
- External integration (scraper)

A small example of the graph structure (similar to the one in the README) to illustrate the actual data representation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef controller fill:#e1f5fe,stroke:#01579b
    classDef service fill:#e8f5e9,stroke:#1b5e20
    classDef repository fill:#fff3e0,stroke:#e65100
    classDef model fill:#f3e5f5,stroke:#4a148c
    classDef external fill:#fbe9e7,stroke:#bf360c
    classDef database fill:#ede7f6,stroke:#311b92
    classDef config fill:#efebe9,stroke:#3e2723

    %% API Layer
    subgraph API
        GC["GraphController"]:::controller
        NC["NodeController"]:::controller
    end

    %% Service Layer
    subgraph Services
        GS["GraphService"]:::service
        NS["NodeService"]:::service
    end

    %% Data Access Layer
    subgraph Repositories
        NR["NodeRepository"]:::repository
        ER["EdgeRepository"]:::repository
        AR["AdvisorRepository"]:::repository
        DR["DissertationRepository"]:::repository
    end

    %% Domain Models
    subgraph Models
        N["Node"]:::model
        E["Edge"]:::model
        A["Advisor"]:::model
        D["Dissertation"]:::model
    end

    %% DTOs
    subgraph DTOs
        ND["NodeDTO"]:::model
        ED["EdgeDTO"]:::model
        AD["AdvisorDTO"]:::model
        DD["DissertationDTO"]:::model
    end

    %% External Components
    SCR["Scraper"]:::external
    DB[(PostgreSQL)]:::database
    EXT["mathgenealogy.org"]:::external

    %% Configuration
    AC["Application Config"]:::config
    WC["Web Config"]:::config

    %% Relationships
    GC --> GS
    NC --> NS
    GS --> NR & ER
    NS --> NR & AR & DR
    NR & ER & AR & DR --> DB
    GS & NS --> SCR
    SCR --> EXT
    
    %% Click Events
    click GC "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/graph/GraphController.java"
    click NC "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/node/NodeController.java"
    click GS "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/graph/GraphService.java"
    click NS "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/node/NodeService.java"
    click NR "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/node/NodeRepository.java"
    click ER "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/edge/EdgeRepository.java"
    click AR "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/advisor/AdvisorRepository.java"
    click DR "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/dissertation/DissertationRepository.java"
    click SCR "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/scraper/Scraper.java"
    click N "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/node/Node.java"
    click E "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/edge/Edge.java"
    click A "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/advisor/Advisor.java"
    click D "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/dissertation/Dissertation.java"
    click ND "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/node/NodeDto.java"
    click ED "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/edge/EdgeDto.java"
    click AD "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/advisor/AdvisorDto.java"
    click DD "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/dissertation/DissertationDto.java"
    click AC "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/MathsgenealogyapiApplication.java"
    click WC "https://github.com/johnbenjaminmccarthy/mathsgenealogyapi/blob/master/src/main/java/com/mathsgenealogyapi/WebConfig.java"
```
