# devgomesai/nexaai-deepseek-ocr architecture

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

- Interactive diagram: https://gitdiagram.com/devgomesai/nexaai-deepseek-ocr
- Repository: https://github.com/devgomesai/nexaai-deepseek-ocr

## Overview

##### Project type and purpose
- This is a full-stack OCR application combining a local AI model server (NexaAI + DeepSeek-OCR) with a Chainlit-powered web interface and a command-line API.
- Purpose: extract text from images (local files or URLs) with high accuracy and privacy, offering both interactive web UI and programmatic access.

##### File structure
- Top-level files:
- app.py – Chainlit web app entry point
- ocr.py – Core OCR logic, OpenAI client integration to NexaAI
- chainlit.md – UI welcome page content
- pyproject.toml & uv.lock – dependency metadata and lock file
- .chainlit/ – Chainlit configuration and translations
- images/ – sample images for testing
- README.md – documentation
- Patterns:
- Separation of concerns: frontend (Chainlit UI in app.py + chainlit.md), backend logic (ocr.py), external service (NexaAI server)
- Configuration files (.chainlit/config.toml, .python-version) and environment specs

##### Insights from the README
- Architecture described implicitly:
- Local NexaAI server at http://127.0.0.1:18181/v1 serving the DeepSeek model
- Python client (OpenAI library) for API calls
- Chainlit to expose web interface on http://localhost:8000
- Tech stack: Python 3.13+, NexaAI, Chainlit, OpenAI client library, LXML, Pandas

##### Detailed capture of essential elements
- Don’t omit the translations directory – note it configures multi-language support in the UI
- Chainlit.md welcome page as part of UI content
- Configuration (.chainlit/config.toml) as customizing UI behavior (themes, limits)
- That both web and CLI share the same OCR core (ocr.py)
- Sample images directory as a testing resource

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["Chainlit Web UI"]:::frontend
        CLI["CLI Interface"]:::frontend
        MD["Welcome Page (chainlit.md)"]:::frontend
        CIconfig["UI Config (.chainlit/config.toml)"]:::frontend
        CLtrans["Translations (.chainlit/translations/)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        AP["app.py"]:::backend
        OCR["OCR Core (ocr.py)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        NEXA["NexaAI Server"]:::service
        MODEL["DeepSeek-OCR Model"]:::service
    end

    %% Auxiliary Resources
    subgraph "Auxiliary Resources"
        IMGS["Sample Images (images/)"]:::aux
        DOC1["README.md"]:::aux
        DEP1["pyproject.toml"]:::aux
        DEP2["uv.lock"]:::aux
        DEP3[".python-version"]:::aux
    end

    %% Connections
    UI -->|"user input/upload or URL"| AP
    AP -->|"invoke OCR"| OCR
    CLI -->|"invoke OCR"| OCR
    OCR -->|"HTTP API Call"| NEXA
    NEXA -->|"Serves Model"| MODEL
    MODEL -->|"OCR Result JSON"| NEXA
    NEXA -->|"HTTP Response"| OCR
    OCR -->|"post-processed text"| AP
    AP -->|"render results"| UI
    OCR -->|"returns text"| CLI

    UI -->|"content"| MD
    UI -->|"config"| CIconfig
    UI -->|"translations"| CLtrans

    %% Click Events
    click AP "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/app.py"
    click MD "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/chainlit.md"
    click CIconfig "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/.chainlit/config.toml"
    click CLtrans "https://github.com/devgomesai/nexaai-deepseek-ocr/tree/main/.chainlit/translations/"
    click OCR "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/ocr.py"
    click IMGS "https://github.com/devgomesai/nexaai-deepseek-ocr/tree/main/images/"
    click DOC1 "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/README.md"
    click DEP1 "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/pyproject.toml"
    click DEP2 "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/uv.lock"
    click DEP3 "https://github.com/devgomesai/nexaai-deepseek-ocr/blob/main/.python-version"

    %% Styles
    classDef frontend fill:#B3D1FF,stroke:#333,stroke-width:1px
    classDef backend fill:#C6F6D5,stroke:#333,stroke-width:1px
    classDef service fill:#FFD59E,stroke:#333,stroke-width:1px
    classDef aux fill:#E2E8F0,stroke:#333,stroke-width:1px
```
