# addy999/omniparser-api architecture

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

- Interactive diagram: https://gitdiagram.com/addy999/omniparser-api
- Repository: https://github.com/addy999/omniparser-api

## Overview

Key Components to Include:

##### Client Layer
- Web browsers and applications (like OneQuery) that consume the API

##### API Layer (FastAPI Server)
- This as the entry point for all requests
- Single endpoint `/process_image`
- Swagger docs endpoint `/docs`

##### Model Layer
- Microsoft's OmniParser Model
- Two main components:

##### Infrastructure Layer
- GPU Processing Unit
- Docker Container
- (Optional) Fly.io hosting platform

Design Guidelines:

##### Component Organization
- [Clients] → [FastAPI Server] → [OmniParser Model] → [GPU Infrastructure]

##### Data Flow Representation
- Input: Image file
- Processing: Model inference
- Output:
a. Annotated image (base64)
b. Parsed elements list

##### Model Component should show
- Description Generation Pipeline
- Model weights loading process

##### Infrastructure Layer
- Docker container boundaries
- GPU allocation
- Memory requirements (16GB RAM)

Important Notes:

##### The clear input/output flow

Remember to maintain a balance between showing the technical complexity of the ML model while keeping the overall architecture clean and understandable.

## Diagram (Mermaid)

```mermaid
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#007bff', 'secondaryColor': '#4CAF50', 'tertiaryColor': '#ff9800', 'primaryBorderColor': '#666666'}}}%%

flowchart TB
    subgraph Clients
        WB[Web Browsers]:::client
        OQ[OneQuery]:::client
        OA[Other Applications]:::client
    end

    subgraph API["API Layer"]
        FAS["FastAPI Server"]:::api
        EP["/process_image Endpoint"]:::api
        DOCS["/docs Swagger UI"]:::api
        
        FAS --> EP
        FAS --> DOCS
    end

    subgraph ML["Model Layer"]
        direction TB
        OP["OmniParser Model"]:::model
        IDS["Icon Detection System"]:::model
        IDSC["Icon Description System"]:::model
        
        OP --> IDS
        OP --> IDSC
    end

    subgraph INFRA["Infrastructure Layer"]
        direction TB
        DOC["Docker Container"]:::infra
        GPU["GPU Processing Unit"]:::infra
        FLY["Fly.io Platform"]:::infra
        
        DOC --> GPU
        DOC --> FLY
    end

    Clients --> API
    API --> ML
    ML --> INFRA

    subgraph Legend
        L1[API Component]:::api
        L2[Model Component]:::model
        L3[Infrastructure Component]:::infra
        L4[Client Component]:::client
    end

    %% Component Mappings
    click FAS "https://github.com/addy999/omniparser-api/blob/main/main.py"
    click DOC "https://github.com/addy999/omniparser-api/tree/main/Dockerfile"
    click FLY "https://github.com/addy999/omniparser-api/blob/main/fly.toml"
    click DOCS "https://github.com/addy999/omniparser-api/tree/main/examples/"
    
    %% Styling
    classDef api fill:#007bff,color:white,stroke:#666
    classDef model fill:#4CAF50,color:white,stroke:#666
    classDef infra fill:#808080,color:white,stroke:#666
    classDef client fill:#ff9800,color:white,stroke:#666

    %% Notes
    note["Requirements:<br/>- 16GB RAM<br/>- GPU Required<br/>- Docker Environment"]:::note
    classDef note fill:#fff,stroke:#333,stroke-dasharray: 5 5
```
