# ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code architecture

> Architecture diagram of the GitHub repository ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code
- Repository: https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code

## Overview

##### Project Type & Purpose
- This is a single‐process, Python‐based Gradio web application that unifies two AI functions:
– Image Description (multimodal LLaVA‐NEXT model)
– Code Generation (Qwen‐1.5B distilled model + Flake8 linting)
- No external database/service is required beyond the Hugging Face Hub.

##### File Structure
Top Level:
- app.py – main entry point that builds & launches the Gradio interface
- requirements.txt – Python dependencies
- assets/, notebooks/, external_files/ – ancillary materials (screenshots, reference notebooks, PDF)
src/ directory (core logic & UI components):
- config.py – central configuration (model names, device selection, default prompts)
- code_generator/
– core.py – model loading & generation logic + Flake8 lint
– interface.py – Gradio components for “Code Generator” tab
- image_descriptor/
– core.py – model loading & image inference logic
– interface.py – Gradio components for “Image Description” tab
- utils/ – any shared utility functions
Notebooks and EXTERNAL_Notebooks – reference, not part of production

##### Extract Architectural Insights from README
- Two tabbed Gradio interfaces sharing one web server
- Models are loaded sequentially onto GPU (4‐bit via bitsandbytes) or CPU/MPS fallback
- Hugging Face Hub serves as external model repository
- UI components in interface.py modules call respective core logic functions

##### Main Components & Interactions
A. Frontend (Gradio Web App)
– app.py orchestrates:
- Layout: three tabs – Image Description, Code Generator, About Me
- Binds UI controls (buttons, sliders, file upload) to backend functions
B. Backend Modules
– src/config.py: global settings (DEVICE, model IDs, default prompts)
– src/image_descriptor/core.py:
- Load llava‐hf model via Hugging Face & bitsandbytes
- Preprocess image, run inference, postprocess text output
– src/code_generator/core.py:
- Load DeepSeek Qwen model via HF & bitsandbytes
- Generate code, run Flake8 lint, return code + lint report
C. External Dependencies & Services
– Hugging Face Model Hub (model downloads & caching)
– bitsandbytes (quantization)
– PyTorch (model execution on GPU/CPU/MPS)
– Flake8 (code quality)
D. Hardware Resource
– GPU with CUDA (preferred), MPS (Mac), or CPU
– VRAM and system RAM

##### Architectural Patterns & Design Principles
- Modular separation: interface vs core logic vs configuration
- Single entry point (app.py) keeps launch logic centralized
- Dependency injection via config.py for easy swapping of models or device
- Sequential model loading with failure detection & UI feedback
- Tabbed UI isolates business logic per feature

## Diagram (Mermaid)

```mermaid
graph TD
    %% Web Server Entry Point
    A["app.py"]:::ui

    %% Shared Modules
    C["config.py"]:::shared
    U["utils"]:::shared

    %% Image Descriptor Package
    subgraph "src/image_descriptor"
        ID_UI["Image Descriptor Interface"]:::ui
        ID_Core["Image Descriptor Core"]:::core
    end

    %% Code Generator Package
    subgraph "src/code_generator"
        CG_UI["Code Generator Interface"]:::ui
        CG_Core["Code Generator Core"]:::core
    end

    %% External Dependencies & Services
    HF["Hugging Face Hub"]:::external
    BNB["bitsandbytes"]:::external
    PT["PyTorch"]:::external
    FLK["Flake8"]:::external
    HW["Hardware (GPU/CPU/MPS)"]:::external
    Cache["Local Model Cache"]:::external

    %% Relationships
    A -->|"uses UI"| ID_UI
    A -->|"uses UI"| CG_UI
    A -->|"imports"| C
    A -->|"imports"| U

    ID_UI -->|"calls"| ID_Core
    CG_UI -->|"calls"| CG_Core

    C -->|"provides settings to"| ID_Core
    C -->|"provides settings to"| CG_Core
    U -->|"shared utils for"| ID_Core
    U -->|"shared utils for"| CG_Core

    ID_Core -->|"fetches model from"| HF
    CG_Core -->|"fetches model from"| HF
    HF -->|"stores models in"| Cache

    ID_Core -->|"quantizes via"| BNB
    CG_Core -->|"quantizes via"| BNB

    ID_Core -->|"executes on"| PT
    CG_Core -->|"executes on"| PT

    CG_Core -->|"runs lint via"| FLK

    ID_Core -->|"runs on"| HW
    CG_Core -->|"runs on"| HW

    ID_Core -->|"returns output to"| ID_UI
    CG_Core -->|"returns output to"| CG_UI

    %% Click Events
    click A "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/app.py"
    click C "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/src/config.py"
    click U "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/tree/main/src/utils/"
    click ID_Core "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/src/image_descriptor/core.py"
    click ID_UI "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/src/image_descriptor/interface.py"
    click CG_Core "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/src/code_generator/core.py"
    click CG_UI "https://github.com/ahmedmostafaattiaaa/dual-ai-workbench-llava-vision-deepseek-code/blob/main/src/code_generator/interface.py"

    %% Styles
    classDef ui fill:#D0E7FF,stroke:#333,stroke-width:1px
    classDef core fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef shared fill:#FFE4B2,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
