# chiraggulati098/devflow architecture

> Architecture diagram of the GitHub repository chiraggulati098/devflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chiraggulati098/devflow
- Repository: https://github.com/chiraggulati098/devflow

## Overview

##### Project type and purpose
- DevFlow is a desktop-based, full-stack AI programming assistant.
- It combines a PyQt5 GUI (“frontend/”) with a set of backend modules for PDF processing, vector storage, RAG (Retrieval-Augmented Generation) logic, and external API integration (Google Gemini).
- Its goal is to guide developers through the project lifecycle, answering queries based on uploaded documentation and ultimately scaffolding or generating code.

##### File structure
- Top-level entrypoint: `main.py` – initializes the application, starts the GUI and backend threads.
- frontend/
- UI components: `chat_interface.py`, `menu_interface.py`, `settings_dialog.py`, `tech_stack_dialog.py`, `project_setup.py`
- Shared widget definitions: `components.py`, `ui.py`
- backend/
- PDF ingestion: `pdf_processor.py` (uses pdfplumber to extract and chunk text)
- Vector database: `vector_store.py` (ChromaDB integration, syncing with `docs/`)
- AI integration: `ai_model.py` (Google Gemini calls, query summarization, reranking with sentence-transformers)
- Config & templates: `project_config.py`, `templates/gitignore_template.txt`
- docs/: source PDF materials the system ingests
- requirements.txt: declares dependencies (PyQt5, chromadb, google-generativeai, etc.)

##### Key insights from README
- RAG pipeline: ingest → embed → retrieve → generate → rerank.
- UI runs in the main thread, heavy processing offloaded to QThreads.
- Future modules: `backend/code_generation.py` for project scaffolding and state management.

a. Main components
1. UI Layer (frontend/)
– Chat window, panels for workflow steps, settings dialogs
2. Controller / Orchestrator (main.py + QThread classes)
– Manages user events, delegates tasks to backend
3. PDF Processor (backend/pdf_processor.py)
4. Vector Store (backend/vector_store.py + ChromaDB)
5. AI Model (backend/ai_model.py)
– External service: Google Gemini API
– Local reranker: sentence-transformers
6. Project Config & Templates (backend/project_config.py + templates/)
7. Docs Directory (docs/)
8. Persistent Storage (ChromaDB files on disk)
9. External Services
– Google Gemini endpoint
b. Relationships & data flows
- User types a query in UI → Controller queues it in a QThread
- QThread calls PDF Processor to ensure all `docs/` are chunked
- Controller calls Vector Store to retrieve top-k relevant chunks
- Controller passes query + chunks to AI Model → calls external API → reranks responses → returns answer
- Controller emits signal back to UI thread → UI displays answer
- On project creation / code generation (future): Controller calls Project Config + Templates → writes new files to disk
c. Architectural patterns
– Modular separation of concerns (UI vs. processing vs. storage vs. external API)
– Asynchronous processing via QThreads to maintain responsive UI
– RAG micro-pipeline pattern (ingest → store → retrieve → generate)
– Use of template engine for code scaffolding
d. Key technologies & frameworks
– PyQt5 (GUI)
– pdfplumber (PDF ingestion)
– ChromaDB (vector store)
– Google-generativeai (Gemini API)
– sentence-transformers (reranking)
– python-dotenv (API key management)

##### Detail
- Future extension point: Code Generation module calling Config & Templates.
- Error-retry logic in AI Model (e.g., “retry up to 3×”).
- Notes on threading boundaries to illustrate responsiveness.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        UI["UI Layer<br/>(PyQt5 widgets & dialogs)"]:::ui
    end

    %% Controller / Orchestrator
    Controller["Controller / Orchestrator<br/>(main.py & QThreads)"]:::backend
    click Controller "https://github.com/chiraggulati098/devflow/blob/main/main.py"

    %% Backend Modules
    subgraph "Backend Modules"
        PDF["PDF Processor<br/>(ingestion & chunking)"]:::backend
        click PDF "https://github.com/chiraggulati098/devflow/blob/main/backend/pdf_processor.py"
        VS["Vector Store<br/>(ChromaDB integration)"]:::backend
        click VS "https://github.com/chiraggulati098/devflow/blob/main/backend/vector_store.py"
        AI["AI Model<br/>(Gemini & reranking)"]:::backend
        click AI "https://github.com/chiraggulati098/devflow/blob/main/backend/ai_model.py"
        Config["Project Config & Templates"]:::backend
        click Config "https://github.com/chiraggulati098/devflow/blob/main/backend/project_config.py"
        Templates["Templates<br/>(scaffolding files)"]:::backend
        click Templates "https://github.com/chiraggulati098/devflow/blob/main/backend/templates/gitignore_template.txt"
    end

    %% Data Stores
    Docs[(Docs Directory)]:::datastore
    click Docs "https://github.com/chiraggulati098/devflow/tree/main/docs/"
    ChromaDB[(ChromaDB Files)]:::datastore

    %% External Services
    Gemini((Google Gemini API)):::external

    %% UI-Controller interaction
    UI -->|"signal/slot: user query"| Controller
    Controller -->|"signal/slot: response"| UI

    %% Controller -> Backend pipeline
    Controller -->|"enqueue: chunk docs"| PDF
    PDF -->|"sync"| Docs
    PDF -->|"embed"| VS
    VS -->|"query: top-k chunks"| AI
    AI -->|"HTTP/gRPC"| Gemini
    Gemini -->|"response"| AI
    AI -->|"rerank (retry×3)"| Controller

    %% Project scaffolding (future)
    Controller -->|"generate project"| Config
    Config -->|"use templates"| Templates

    %% Data store persistence
    VS -->|"persist vectors"| ChromaDB
    Docs -->|"source materials"| PDF

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef datastore fill:#FFF5B1,stroke:#E36209,color:#E36209,shape: cylinder;
    classDef external fill:#F0E6FF,stroke:#6F42C1,color:#6F42C1,shape: cloud;
```
