# gentleman-programming/gentlemanclass_hexagonalarchitecture architecture

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

- Interactive diagram: https://gitdiagram.com/gentleman-programming/gentlemanclass_hexagonalarchitecture
- Repository: https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture

## Overview

##### Project type and purpose
- This is a full-stack sample application demonstrating Hexagonal (Ports & Adapters) architecture in TypeScript.
- The `src` folder contains a React/TSX frontend (Vite-powered) and two “hexagonal” backend modules under `src/services/`:
- `dashboard-api` – the HTTP/TRPC-exposed API
- `repository` – the domain/service layer for user data

##### File structure
- Top-level: `index.html`, `src/main.tsx`, React components (`Login.tsx`, `Register.tsx`), and `trpc.tsx` for client-side TRPC setup.
- `src/services/dashboard-api`:
- `server.ts` – entry point that spins up a TRPC/HTTP server
- `app/` – core business logic (`dashboard-api.ts`) and `composition-root.ts` wiring interfaces to adapters
- `ports/` – Port interfaces:
– `drivers` (inbound) for authenticating requests
– `drivens` (outbound) for repo-querying and control-authenticating
- `adapters/` – Concrete implementations of ports:
– `drivers` side (e.g. `auth-trpc-adapter.ts`)
– `drivens` side (e.g. stub or local repo-query adapters)
- `src/services/repository`:
- Same hexagonal structure but focused on user persistence/monitoring
- No HTTP server here – it’s consumed by `dashboard-api` via its ports/adapters

##### README
- Confirms this is an example of Hexagonal Architecture (Ports & Adapters).
- Emphasizes use of interfaces (ports) and their implementors (adapters) to decouple business logic from I/O.

##### Important details
- Ports and adapters even if currently stubbed
- Composition Root as the central wiring inside each hexagon
- That repository is an internal module consumed by dashboard-api, not directly exposed over HTTP

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "React UI"
        direction TB
        UI1["index.html"]:::frontend
        UI2["main.tsx"]:::frontend
        UI3["App.tsx"]:::frontend
        UI4["Login.tsx"]:::frontend
        UI5["Register.tsx"]:::frontend
    end

    %% TRPC Client
    TRPC["trpc.tsx"]:::frontend

    UI1 --> TRPC
    UI2 --> TRPC
    UI3 --> TRPC
    UI4 --> TRPC
    UI5 --> TRPC

    %% Dashboard-API Service Hexagon
    subgraph "Dashboard-API Service" 
        direction TB
        Inbound["auth-trpc-adapter"]:::adapter
        Comp["composition-root"]:::core
        Core["dashboard-api.ts"]:::core
        SchemaAuth["schemas/auth.ts"]:::core
        SchemaUser["schemas/user.ts"]:::core
        PAuth["for-authenticating.ts"]:::core
        PRepo["for-repo-querying.ts"]:::core
        PControl["for-control-authenticating.ts"]:::core
        AProxy["authenticator-proxy-adapter"]:::adapter
        RepoLocal["repo-querier-local-adapter"]:::adapter
        RepoStub["repo-querier-stub-adapter"]:::adapter
        ControlStub["control-authenticator-stub-adapter"]:::adapter

        Inbound --> Comp
        Comp --> Core
        Core --> SchemaAuth
        Core --> SchemaUser
        Comp --> PAuth
        Comp --> PRepo
        Comp --> PControl
        PAuth --> AProxy
        PRepo --> RepoLocal
        PRepo --> RepoStub
        PControl --> ControlStub
    end

    TRPC --> Inbound

    %% Repository Service Hexagon
    subgraph "Repository Service"
        direction TB
        RComp["composition-root"]:::core
        RCore["repository.ts"]:::core
        RSchema["schemas/user.ts"]:::core
        RPortDrive["for-managing-user.ts"]:::core
        RPortDriven["for-monitoring.ts"]:::core
        RAdapterDrive["user-manager-proxy"]:::adapter
        RAdapterDriven["logger-stub-adapter"]:::adapter

        RComp --> RCore
        RCore --> RSchema
        RComp --> RPortDrive
        RComp --> RPortDriven
        RPortDrive --> RAdapterDrive
        RPortDriven --> RAdapterDriven
    end

    PRepo --> RPortDrive

    %% External Services
    AuthService["Auth Service"]:::external
    UserMgr["User Manager/DB"]:::external

    AProxy --> AuthService
    RAdapterDrive --> UserMgr

    %% Click Events - Frontend
    click UI1 "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/index.html"
    click UI2 "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/main.tsx"
    click UI3 "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/App.tsx"
    click UI4 "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/components/Login.tsx"
    click UI5 "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/components/Register.tsx"
    click TRPC "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/trpc.tsx"

    %% Click Events - Dashboard-API
    click Inbound "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/adapters/drivers/auth-trpc-adapter.ts"
    click Comp "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/app/composition-root.ts"
    click Core "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/app/dashboard-api.ts"
    click SchemaAuth "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/app/schemas/auth.ts"
    click SchemaUser "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/app/schemas/user.ts"
    click PAuth "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/ports/drivers/for-authenticating.ts"
    click PRepo "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/ports/drivens/for-repo-querying.ts"
    click PControl "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/ports/drivens/for-control-authenticating.ts"
    click AProxy "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/adapters/drivers/authenticator-proxy-adapter.ts"
    click RepoLocal "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/adapters/drivens/repo-querier-local-adapter.ts"
    click RepoStub "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/adapters/drivens/repo-querier-stub-adapter.ts"
    click ControlStub "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/dashboard-api/adapters/drivens/control-authenticator-stub-adapter.ts"

    %% Click Events - Repository Service
    click RComp "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/app/composition-root.ts"
    click RCore "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/app/repository.ts"
    click RSchema "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/app/schemas/user.ts"
    click RPortDrive "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/ports/drivers/for-managing-user.ts"
    click RPortDriven "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/ports/drivens/for-monitoring.ts"
    click RAdapterDrive "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/adapters/drivers/user-manager-proxy.ts"
    click RAdapterDriven "https://github.com/gentleman-programming/gentlemanclass_hexagonalarchitecture/blob/main/src/services/repository/adapters/drivens/logger-stub-adapter.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef adapter fill:#90EE90,stroke:#333,stroke-width:1px
    classDef core fill:#98FB98,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
