# sunnysavita10/document_portal architecture

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

- Interactive diagram: https://gitdiagram.com/sunnysavita10/document_portal
- Repository: https://github.com/sunnysavita10/document_portal

## Overview

##### Project type and purpose
- This is a full-stack “Document Portal” service combining a web frontend, a Python API backend, and a suite of document-analysis/chat pipelines.
- The README calls out LLM and embedding models, vector databases, and API keys – so the service ingests user documents, indexes them, and offers single- or multi-document chat/analysis via external LLMs.

##### File structure
Top-level directories/files:
- api/            ← API entrypoint (api/main.py) and persisted data
- src/            ← Core business logic: ingestion, retrieval, analysis, comparison, chat
- model/          ← Model definitions (data classes or ORM models)
- exception/, logger/, utils/ ← Cross-cutting concerns: errors, logging, config, I/O, model loading
- static/, templates/ ← Web UI assets (CSS, HTML)
- config/config.yaml ← Deployment/runtime config
- Dockerfile, .github/workflows/*.yml ← Containerization & CI/CD to AWS
- notebook/       ← Exploratory data science and logging experiments
- prompt/         ← Prompt engineering library

Patterns:
- Layered architecture: Web UI → API layer → Service layer (document pipelines) → Persistence/External services
- Modular pipelines under src/document_analyzer, src/document_compare, src/document_chat, etc.

##### README for additional insights
- Lists supported LLMs and embedding models.
- Emphasizes vector DB choice (in-memory, on-disk, cloud).

##### Elements
– Clear labels for each component and sub-component
- Blues for internal services
- Greens for data stores

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "1. Presentation Layer"
        direction TB
        Browser["Web Browser"]:::external
        FrontendStatic["Static Assets (CSS)"]:::frontend
        FrontendTemplate["Templates (HTML)"]:::frontend
    end

    subgraph "2. API Layer"
        direction TB
        APIGateway["API Gateway / Load Balancer (AWS ALB)"]:::infra
        subgraph "API Container (Docker)"
            direction TB
            APIMain["api/main.py"]:::api
            subgraph "Controllers / Endpoints"
                direction TB
                SingleChat["Single-Document Chat Endpoint"]:::api
                MultiChat["Multi-Document Chat Endpoint"]:::api
                AnalyzerEP["Document Analysis Endpoint"]:::api
                CompareEP["Document Comparison Endpoint"]:::api
            end
        end
    end

    subgraph "3. Service Layer"
        direction TB
        subgraph "Document Pipelines"
            direction TB
            Ingestion["Data Ingestion Service"]:::services
            Analysis["Document Analysis Service"]:::services
            Comparison["Comparison Service"]:::services
            Retrieval["Chat Retrieval Service"]:::services
        end
        subgraph "Utilities & Config"
            direction TB
            ConfigLoader["Configuration Loader"]:::utils
            FileIO["File I/O Utilities"]:::utils
            ModelLoader["Model Loader Utilities"]:::utils
            CustomLogger["Custom Logger"]:::utils
            CustomException["Custom Exceptions"]:::utils
            Models["Data Models / ORM"]:::data
            PromptLib["Prompt Engineering Library"]:::services
        end
    end

    subgraph "4. Data Layer"
        direction TB
        FileStore["File System Store"]:::data
        VectorDB["Vector Database"]:::data
    end

    subgraph "5. External Services"
        direction TB
        LLMs["LLM Providers"]:::external
        Embeddings["Embedding APIs"]:::external
    end

    subgraph "6. CI/CD & Infra"
        direction TB
        GHActions["GitHub Actions"]:::infra
        DockerRegistry["Docker Registry"]:::infra
        AWSECS["AWS ECS/EKS / Fargate"]:::infra
    end

    %% Relationships
    Browser -->|"HTTP/HTTPS"| FrontendStatic
    Browser -->|"HTTP/HTTPS"| FrontendTemplate
    FrontendTemplate -->|renders| Browser

    Browser -->|"HTTP/JSON"| APIGateway
    APIGateway -->|routes| APIMain
    APIMain -->|calls| SingleChat
    APIMain -->|calls| MultiChat
    APIMain -->|calls| AnalyzerEP
    APIMain -->|calls| CompareEP

    SingleChat -->|invokes| Retrieval
    SingleChat -->|invokes| PromptLib
    MultiChat -->|invokes| Retrieval
    MultiChat -->|invokes| PromptLib
    AnalyzerEP -->|invokes| Analysis
    CompareEP -->|invokes| Comparison
    Ingestion -->|stores| FileStore
    Ingestion -->|indexes| VectorDB
    Retrieval -->|queries| VectorDB
    Retrieval -->|reads| FileStore
    Analysis -->|uses| Models
    Comparison -->|uses| Models
    Retrieval -->|calls| LLMs
    Retrieval -->|calls| Embeddings

    APIMain -->|loads config| ConfigLoader
    APIMain -->|logs| CustomLogger
    APIMain -->|handles errors| CustomException
    Ingestion -->|uses| FileIO
    Analysis -->|uses| ModelLoader

    GHActions -->|builds image| DockerRegistry
    DockerRegistry -->|deploys| AWSECS

    %% Click Events
    click FrontendStatic "https://github.com/sunnysavita10/document_portal/blob/main/static/style.css"
    click FrontendTemplate "https://github.com/sunnysavita10/document_portal/blob/main/templates/index.html"
    click APIMain "https://github.com/sunnysavita10/document_portal/blob/main/api/main.py"
    click FileStore "https://github.com/sunnysavita10/document_portal/tree/main/api/data/"
    click ConfigLoader "https://github.com/sunnysavita10/document_portal/blob/main/utils/config_loader.py"
    click FileIO "https://github.com/sunnysavita10/document_portal/blob/main/utils/file_io.py"
    click ModelLoader "https://github.com/sunnysavita10/document_portal/blob/main/utils/model_loader.py"
    click CustomLogger "https://github.com/sunnysavita10/document_portal/blob/main/logger/custom_logger.py"
    click CustomException "https://github.com/sunnysavita10/document_portal/blob/main/exception/custom_exception.py"
    click Models "https://github.com/sunnysavita10/document_portal/blob/main/model/models.py"
    click Ingestion "https://github.com/sunnysavita10/document_portal/blob/main/src/document_ingestion/data_ingestion.py"
    click Analysis "https://github.com/sunnysavita10/document_portal/blob/main/src/document_analyzer/data_analysis.py"
    click Comparison "https://github.com/sunnysavita10/document_portal/blob/main/src/document_compare/document_comparator.py"
    click Retrieval "https://github.com/sunnysavita10/document_portal/blob/main/src/document_chat/retrieval.py"
    click PromptLib "https://github.com/sunnysavita10/document_portal/blob/main/prompt/prompt_library.py"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#90CAF9,color:#0D47A1;
    classDef api fill:#BBDEFB,stroke:#64B5F6,color:#0D47A1;
    classDef services fill:#C8E6C9,stroke:#81C784,color:#1B5E20;
    classDef utils fill:#FFF9C4,stroke:#FFF176,color:#F57F17;
    classDef data fill:#DCEDC8,stroke:#AED581,color:#33691E;
    classDef external fill:#FFE0B2,stroke:#FFB74D,color:#E65100;
    classDef infra fill:#E0E0E0,stroke:#BDBDBD,color:#424242;
```
