# lfarroco/metriia architecture

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

- Interactive diagram: https://gitdiagram.com/lfarroco/metriia
- Repository: https://github.com/lfarroco/metriia

## Overview

##### Main Components Identification
The project is a full-stack web application with clear separation between frontend and backend:

A. Frontend Layer:
- React-based TypeScript application
- Webpack-bundled static assets
- Client-side routing and state management

B. Backend Layer:
- Django-based Python application
- Custom management commands for AI/ML operations
- Database models and migrations
- REST API endpoints

C. AI/ML Components:
- Embedding calculation system
- Distance computation for embeddings
- Data ingestion pipeline

##### Component Relationships

- Frontend → Backend API calls
- Backend → Database interactions
- Management Commands → AI Processing flow
- Data flow between embedding calculation and storage

##### Technical Stack Indicators

Technology badges or labels for:
- React/TypeScript (Frontend)
- Django/Python (Backend)
- AI/ML processing tools
- Docker containerization

**┌─────────────────────────────────┐**
- Client Interface         │
- (React + TypeScript + Webpack)│
- ┘
- ↕ HTTP/REST
**┌─────────────────────────────────┐**
- Django Backend          │
- (API + Admin + URL Routing)  │
- ┘
- ↕ Internal
**┌─────────────────────────────────┐**
- AI Processing Pipeline     │
- (Embeddings + Distance Calc)   │
- ┘
- ↕ Persistence
**┌─────────────────────────────────┐**
- Data Storage Layer       │
- ┘

##### Additional Notes

Annotations for:
- Asynchronous processes (ASGI configuration present)
- Management command triggers
- Data flow direction
- Security boundaries
- Containerization scope

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#9b59b6,stroke:#8e44ad,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        FApp["React App"]:::frontend
        FBuild["Webpack Build"]:::frontend
        FStatic["Static Assets"]:::frontend
        
        FApp --> FBuild
        FBuild --> FStatic
    end

    %% Backend Layer
    subgraph Backend
        DCore["Django Core"]:::backend
        DAPI["REST API"]:::backend
        DAdmin["Admin Interface"]:::backend
        DRouting["URL Routing"]:::backend
        
        DCore --> DAPI
        DCore --> DAdmin
        DCore --> DRouting
    end

    %% AI/ML Layer
    subgraph AIProcessing
        DataIngest["Data Ingestion"]:::ai
        EmbedCalc["Embedding Calculator"]:::ai
        DistComp["Distance Computer"]:::ai
        
        DataIngest --> EmbedCalc
        EmbedCalc --> DistComp
    end

    %% Data Layer
    subgraph DataStorage
        DB[(Database)]:::data
        Migrations["DB Migrations"]:::data
        
        Migrations --> DB
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        Docker["Docker Container"]:::infra
        ASGI["ASGI Server"]:::infra
        WSGI["WSGI Server"]:::infra
    end

    %% Inter-layer Connections
    Frontend --> |HTTP/REST| Backend
    Backend --> AIProcessing
    AIProcessing --> DataStorage
    Backend --> DataStorage
    Infrastructure --> Backend

    %% Click Events
    click FApp "https://github.com/lfarroco/metriia/blob/main/frontend/src/App.tsx"
    click FBuild "https://github.com/lfarroco/metriia/blob/main/frontend/config/webpack.config.js"
    click DCore "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/settings.py"
    click DAPI "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/views.py"
    click DAdmin "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/admin.py"
    click DRouting "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/urls.py"
    click DataIngest "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/management/commands/ingest.py"
    click EmbedCalc "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/management/commands/calc_embeddings.py"
    click DistComp "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/management/commands/calc_embeddings_distance.py"
    click Migrations "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/migrations/0001_initial.py"
    click ASGI "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/asgi.py"
    click WSGI "https://github.com/lfarroco/metriia/blob/main/backend/src/papers/wsgi.py"
    click Docker "https://github.com/lfarroco/metriia/blob/main/docker-compose.yml"
```
