# l3p-cv/lost architecture

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

- Interactive diagram: https://gitdiagram.com/l3p-cv/lost
- Repository: https://github.com/l3p-cv/lost

## Overview

##### Main System Components
The system architecture should be divided into these major components:

a. Frontend Layer
- Single Page Application (React-based, located in /frontend/lost)
- Multiple annotation tools (SIA - Single Image Annotation, MIA - Multi Image Annotation)
- Administrative interfaces
- Statistics and monitoring components

b. Backend Layer
- REST API services (/backend/lost/api)
- Authentication and authorization system
- Pipeline execution engine
- Database access layer
- File management system

c. External Services Integration
- Storage systems (S3, Azure Blob, FTP)
- LDAP integration
- Email notification service
- JupyterLab integration

##### Component Relationships

a. Frontend to Backend Communication
- REST API calls between frontend components and corresponding backend endpoints
- WebSocket connections for real-time updates
- File upload/download streams

b. Backend Internal Communication
- Pipeline execution flow
- Database interactions
- File system operations

c. External Service Integration
- Storage system connectors
- Authentication service connections
- Email service integration

##### Specific Architectural Elements

Key architectural patterns:

a. API Layer Structure (/backend/lost/api)
- Annotation endpoints (anno_example, annotask, sia, mia)
- User management (user, group)
- Pipeline management (pipeline)
- File management (filebrowser)
- System configuration (config)

b. Pipeline System
- Pipeline template management
- Pipeline instance execution
- Worker distribution system
- Task scheduling

c. Data Management
- Database layer (/backend/lost/db)
- File storage abstraction
- Caching mechanisms

##### Specific Implementation Details

Important aspects:

a. Security Layer
- Login manager (/backend/lost/api/user/login_manager.py)
- Role-based access control
- API authentication

b. Annotation Tools
- SIA tool components
- MIA tool components
- Annotation export system

c. Pipeline Management
- Pipeline execution engine
- Worker distribution
- Task scheduling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        L1[Frontend Component]:::frontend
        L2[Backend Service]:::backend
        L3[Database]:::database
        L4((External Service)):::external
        L5{Pipeline Component}:::pipeline
        L6[Security Component]:::security
    end

    subgraph "Frontend Layer"
        SPA[React SPA]:::frontend
        click SPA "https://github.com/l3p-cv/lost/tree/master/frontend/lost/"
        
        subgraph "Annotation Tools"
            SIA[Single Image Annotation]:::frontend
            click SIA "https://github.com/l3p-cv/lost/tree/master/frontend/lost/src/containers/Annotation/SIA/"
            MIA[Multi Image Annotation]:::frontend
            click MIA "https://github.com/l3p-cv/lost/tree/master/frontend/lost/src/containers/Annotation/MIA/"
        end
        
        subgraph "Management Interfaces"
            ADMIN[Administrative Interface]:::frontend
            click ADMIN "https://github.com/l3p-cv/lost/tree/master/frontend/lost/src/containers/AdminArea/"
            STATS[Statistics Dashboard]:::frontend
            click STATS "https://github.com/l3p-cv/lost/tree/master/frontend/lost/src/containers/Statistics/"
            LABELS[Label Management]:::frontend
            click LABELS "https://github.com/l3p-cv/lost/tree/master/frontend/lost/src/containers/Labels/"
        end
    end

    subgraph "Backend Layer"
        API[REST API Services]:::backend
        click API "https://github.com/l3p-cv/lost/tree/master/backend/lost/api/"
        
        subgraph "Core Services"
            AUTH[Authentication System]:::security
            click AUTH "https://github.com/l3p-cv/lost/tree/master/backend/lost/api/user/"
            PIPE_ENGINE{Pipeline Engine}:::pipeline
            click PIPE_ENGINE "https://github.com/l3p-cv/lost/tree/master/backend/lost/logic/pipeline/"
            FILE_MGR[File Management]:::backend
            click FILE_MGR "https://github.com/l3p-cv/lost/tree/master/backend/lost/api/filebrowser/"
        end
        
        subgraph "API Endpoints"
            PIPE_API[Pipeline API]:::backend
            click PIPE_API "https://github.com/l3p-cv/lost/tree/master/backend/lost/api/pipeline/"
            USER_API[User API]:::backend
            click USER_API "https://github.com/l3p-cv/lost/tree/master/backend/lost/api/user/"
            FILE_API[File API]:::backend
            click FILE_API "https://github.com/l3p-cv/lost/blob/master/backend/lost/logic/file_access.py"
        end
        
        DB[(Database)]:::database
        click DB "https://github.com/l3p-cv/lost/tree/master/backend/lost/db/"
    end

    subgraph "External Services"
        S3((S3 Storage)):::external
        AZURE((Azure Blob)):::external
        LDAP((LDAP)):::external
        EMAIL((Email Service)):::external
        click EMAIL "https://github.com/l3p-cv/lost/blob/master/backend/lost/logic/email.py"
        JUPYTER((JupyterLab)):::external
    end

    %% Frontend to Backend Connections
    SPA --> API
    SIA --> API
    MIA --> API
    ADMIN --> API
    STATS --> API
    LABELS --> API

    %% Backend Internal Connections
    API --> AUTH
    API --> PIPE_ENGINE
    API --> FILE_MGR
    PIPE_ENGINE --> DB
    FILE_MGR --> DB
    AUTH --> DB

    %% API Endpoint Connections
    API --> PIPE_API
    API --> USER_API
    API --> FILE_API
    
    %% External Service Connections
    FILE_MGR -.-> S3
    FILE_MGR -.-> AZURE
    AUTH -.-> LDAP
    PIPE_ENGINE -.-> EMAIL
    PIPE_ENGINE -.-> JUPYTER

    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:white
    classDef pipeline fill:#e74c3c,stroke:#c0392b,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
```
