# pratikid/leg architecture

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

- Interactive diagram: https://gitdiagram.com/pratikid/leg
- Repository: https://github.com/pratikid/leg

## Overview

##### Project type and purpose
- This is a full-stack Laravel (PHP) web application named LEG (Lineage Exploration and Genealogy).

##### File structure
- Top-level:
- `app/` (Models, Controllers, Services, Middleware, Livewire components) – the core MVC application
- `resources/` (Blade views, JS/CSS assets) – the frontend
- `routes/` (web.php, api.php) – HTTP and API endpoints
- `config/`, `bootstrap/` – framework bootstrap & configuration
- `database/` (migrations, seeders) – relational schema
- `docker/` & `docker-compose.yml` – container definitions (PHP-FPM, Nginx)
- Key patterns:
- MVC with Controllers → Services → Repositories/Models
- API versioning under `app/Http/Controllers/Api/V1`
- Livewire for reactive UI, D3.js for visualizations
- Neo4j accessed via `Neo4jIndividualService` for graph queries
- Cache service, queue workers (jobs table), sanctum for API auth

##### README for additional insights
- Tech stack: PHP ≥8.4, Laravel 12.x, Livewire, D3.js, Neo4j, Docker
- Features: GEDCOM 5.5.5 import/export, family tree & timeline visualizations, community forums, role-based authorization

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser"]:::ui
        Blade["Blade Templates"]:::ui
        Livewire["Livewire Components"]:::ui
        D3["D3.js Visualization"]:::ui
    end

    Browser -->|HTTP/HTTPS| Blade
    Browser -->|AJAX/WebSocket| Livewire
    Browser -->|Fetch JSON| D3

    click Blade "https://github.com/pratikid/leg/tree/main/resources/views/"
    click Livewire "https://github.com/pratikid/leg/blob/main/app/Livewire/UserSettings.php"
    click D3 "https://github.com/pratikid/leg/blob/main/resources/js/app.js"

    %% Web Layer
    subgraph "Web Layer"
        Nginx["Nginx"]:::server
        PHPFPM["PHP-FPM"]:::server
        Router["Laravel Router"]:::server
        Middleware["Middleware Pipeline"]:::server
        WebControllers["Web Controllers"]:::server
        APIControllers["API Controllers (v1)"]:::server
        WebRoutes["Web Routes"]:::server
        APIRoutes["API Routes"]:::server
    end

    Blade -->|Served by| Nginx
    Livewire -->|Endpoint| Nginx
    D3 -->|Endpoint| Nginx

    Nginx -->|FastCGI| PHPFPM
    PHPFPM -->|Route Request| Router
    Router -->|via routes/web.php| WebRoutes
    Router -->|via routes/api.php| APIRoutes
    Router -->|passes through| Middleware
    Middleware --> WebControllers
    Middleware --> APIControllers

    click WebControllers "https://github.com/pratikid/leg/tree/main/app/Http/Controllers/"
    click APIControllers "https://github.com/pratikid/leg/tree/main/app/Http/Controllers/Api/V1/"
    click WebRoutes "https://github.com/pratikid/leg/blob/main/routes/web.php"
    click APIRoutes "https://github.com/pratikid/leg/blob/main/routes/api.php"
    click Middleware "https://github.com/pratikid/leg/tree/main/app/Http/Middleware/"

    %% Application Layer
    subgraph "Application Layer"
        GedcomService["GedcomService"]:::service
        Neo4jService["Neo4jIndividualService"]:::service
        CacheService["CacheService"]:::service
        Models["Eloquent Models"]:::service
        Queue["Queue Infrastructure"]:::service
    end

    WebControllers -->|calls| GedcomService
    WebControllers -->|calls| Neo4jService
    WebControllers -->|calls| CacheService
    APIControllers -->|calls| GedcomService
    APIControllers -->|calls| Neo4jService
    APIControllers -->|calls| CacheService

    GedcomService -->|uses| Models
    Neo4jService -->|uses| Models
    CacheService -->|uses| Models
    WebControllers -->|dispatches| Queue
    click GedcomService "https://github.com/pratikid/leg/blob/main/app/Services/GedcomService.php"
    click Neo4jService "https://github.com/pratikid/leg/blob/main/app/Services/Neo4jIndividualService.php"
    click CacheService "https://github.com/pratikid/leg/blob/main/app/Services/CacheService.php"
    click Models "https://github.com/pratikid/leg/tree/main/app/Models/"
    click Queue "https://github.com/pratikid/leg/blob/main/database/migrations/0001_01_01_000002_create_jobs_table.php"

    %% Data Layer
    subgraph "Data Layer"
        RelationalDB["Relational Database (MySQL/Postgres)"]:::database
        Neo4jDB["Graph Database (Neo4j)"]:::database
        RedisCache["Cache (Redis/File)"]:::database
        FileStorage["File Storage (GEDCOM & Media)"]:::database
    end

    Models -->|DB Query| RelationalDB
    Neo4jService -->|Cypher Query| Neo4jDB
    CacheService -->|Cache Get/Set| RedisCache
    GedcomService -->|store files| FileStorage

    click RelationalDB "https://github.com/pratikid/leg/tree/main/database/migrations/"
    click Neo4jDB "https://github.com/pratikid/leg/blob/main/config/database.php"
    click RedisCache "https://github.com/pratikid/leg/blob/main/config/cache.php"
    click FileStorage "https://github.com/pratikid/leg/tree/main/storage/app/"

    %% Infrastructure & Config
    subgraph "Infrastructure & Config"
        Docker["Docker Setup"]:::other
        Bootstrap["Bootstrap & Providers"]:::other
        Auth["Auth & Authorization"]:::other
        Session["Session Storage"]:::other
        Tests["Testing Suite"]:::other
    end

    Nginx --> Docker
    PHPFPM --> Docker
    Router --> Bootstrap
    Router --> Auth
    Middleware --> Session
    WebControllers --> Tests
    APIControllers --> Tests

    click Docker "https://github.com/pratikid/leg/blob/main/docker-compose.yml"
    click Bootstrap "https://github.com/pratikid/leg/blob/main/bootstrap/app.php"
    click Auth "https://github.com/pratikid/leg/blob/main/config/auth.php"
    click Session "https://github.com/pratikid/leg/blob/main/config/session.php"
    click Tests "https://github.com/pratikid/leg/tree/main/tests/Feature/"

    %% Styles
    classDef ui fill:#D6E9FF,stroke:#4D83FF,color:#000
    classDef server fill:#D9FFD6,stroke:#4DBF4D,color:#000
    classDef service fill:#FFF5CC,stroke:#FFCC00,color:#000
    classDef database fill:#FFE0CC,stroke:#FF9900,color:#000
    classDef other fill:#E8E8E8,stroke:#AAAAAA,color:#000
```
