# cadet-dot-net/liveview-insta-clone architecture

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

- Interactive diagram: https://gitdiagram.com/cadet-dot-net/liveview-insta-clone
- Repository: https://github.com/cadet-dot-net/liveview-insta-clone

## Overview

##### Main Components

a. Web Layer (Phoenix):
- Router (from lib/finsta_web/router.ex)
- Endpoint (from lib/finsta_web/endpoint.ex)
- Controllers (from lib/finsta_web/controllers)
- Views/Templates (represented by the HTML files)
- Components (from lib/finsta_web/components)

b. Core Application:
- Application Supervisor (from lib/finsta/application.ex)
- Repo (Database Interface) (from lib/finsta/repo.ex)
- Mailer Service (from lib/finsta/mailer.ex)

c. Frontend Assets:
- JavaScript (from assets/js)
- CSS/Tailwind (from assets/css)

d. Database Layer:
- A database symbol representing the PostgreSQL database
- Migrations directory connection (priv/repo/migrations)

##### Component Relationships

- Client Browser → Phoenix Endpoint
- Endpoint → Router
- Router → Controllers
- Controllers → Views/Templates
- Controllers → Repo
- Repo → Database
- Templates → Components
- Assets → Client Browser

##### Additional Elements

Supporting components:
- Telemetry system (lib/finsta_web/telemetry.ex)
- Gettext for internationalization
- Configuration layers (config directory)

##### Architectural Patterns to Highlight

- Model-View-Controller (MVC) pattern
- Phoenix's Context pattern (though not heavily implemented yet)
- Supervision tree structure
- Request/Response lifecycle

##### Important Notes

Annotations for:
- Phoenix LiveView capabilities (if implemented)
- Telemetry monitoring points
- Database migration workflow
- Asset compilation pipeline
- Development vs Production configurations

Remember to emphasize:
- The separation between web and core application layers
- The role of the Router and Endpoint as entry points
- The relationship between Controllers, Views, and Templates
- The database interaction layer through the Repo
- The asset compilation and delivery pipeline

This structure will give other developers a clear understanding of how the application's components interact while maintaining Phoenix's conventional architecture.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]:::client
    end

    subgraph "Phoenix Web Layer"
        Endpoint["Phoenix Endpoint"]:::web
        Router["Router"]:::web
        Controllers["Controllers"]:::web
        Views["Views/Templates"]:::web
        WebComponents["Components"]:::web
    end

    subgraph "Core Application"
        AppSupervisor["Application Supervisor"]:::core
        Repo["Database Repository"]:::core
        Mailer["Mailer Service"]:::core
        Telemetry["Telemetry System"]:::core
        Gettext["Internationalization"]:::core
    end

    subgraph "Asset Pipeline"
        JS["JavaScript"]:::asset
        CSS["CSS/Tailwind"]:::asset
    end

    subgraph "Database Layer"
        DB[(PostgreSQL)]:::db
        Migrations["Migrations"]:::db
    end

    Browser --> Endpoint
    Endpoint --> Router
    Router --> Controllers
    Controllers --> Views
    Views --> WebComponents
    Controllers --> Repo
    Repo --> DB
    Migrations --> DB
    JS --> Browser
    CSS --> Browser
    
    %% Click events for component mapping
    click Router "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta_web/router.ex"
    click Endpoint "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta_web/endpoint.ex"
    click Controllers "https://github.com/cadet-dot-net/liveview-insta-clone/tree/main/lib/finsta_web/controllers/"
    click WebComponents "https://github.com/cadet-dot-net/liveview-insta-clone/tree/main/lib/finsta_web/components/"
    click AppSupervisor "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta/application.ex"
    click Repo "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta/repo.ex"
    click Mailer "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta/mailer.ex"
    click JS "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/assets/js/app.js"
    click CSS "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/assets/css/app.css"
    click Telemetry "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta_web/telemetry.ex"
    click Gettext "https://github.com/cadet-dot-net/liveview-insta-clone/blob/main/lib/finsta_web/gettext.ex"
    click Migrations "https://github.com/cadet-dot-net/liveview-insta-clone/tree/main/priv/repo/migrations/"
    click Views "https://github.com/cadet-dot-net/liveview-insta-clone/tree/main/lib/finsta_web/controllers/page_html/"

    %% Styling
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef web fill:#3498db,stroke:#333,stroke-width:2px
    classDef core fill:#9b59b6,stroke:#333,stroke-width:2px
    classDef asset fill:#e67e22,stroke:#333,stroke-width:2px
    classDef db fill:#2ecc71,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Client_L["Client"]:::client
        Web_L["Web Layer"]:::web
        Core_L["Core Application"]:::core
        Asset_L["Asset Pipeline"]:::asset
        DB_L["Database"]:::db
    end
```
