# akshaypkulkarni/doc-intelligence-platform architecture

> Architecture diagram of the GitHub repository akshaypkulkarni/doc-intelligence-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akshaypkulkarni/doc-intelligence-platform
- Repository: https://github.com/akshaypkulkarni/doc-intelligence-platform

## Overview

##### Project type and purpose
- This is a cloud-native, full-stack document intelligence platform with a RESTful API (no separate UI code) that processes, analyzes, and semantically searches documents using AI.
- It exposes FastAPI endpoints, runs background tasks with Celery, persists in PostgreSQL, caches/queues in Redis, stores objects in S3, and integrates with OpenAI and Pinecone.

##### File structure
- Top-level:
- docker/, docker-compose.yml → containerization
- src/ai_document_platform/ → main application
- scripts/init-db.sql → DB initialization
- tests/ → unit tests
- pyproject.toml, .pre-commit-config.yaml → Python tooling/config
- Inside src/ai_document_platform:
- api/ (FastAPI routes)
- services/ (business logic)
- repositories/ (DB ORM via SQLAlchemy)
- clients/ (external services: OpenAI, Pinecone, S3)
- models/ (Pydantic schemas, data models)
- utils/ (helpers)

##### README for additional insights
- Technology stack calls out: FastAPI, Celery, PostgreSQL, Redis, AWS S3, OpenAI API, Pinecone, Docker/Kubernetes.
- Architecture is described as microservice-like with API + background workers + external integrations.

##### Elements
- Clear component labels (e.g., “FastAPI API”, “Celery Worker”)
- Client → API → DB
- API → Redis → Worker → External Services

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Container Orchestration
    subgraph "Container Platform"
        style ContainerPlatform fill:#FFC0CB,stroke:#333,stroke-width:2px
        ContainerPlatform[/"Docker & Kubernetes"/]
        DC["docker-compose.yml"]:::orch_config
        DF["docker/Dockerfile"]:::orch_config
        ContainerPlatform --> DC
        ContainerPlatform --> DF
    end

    %% Application Code
    subgraph "Application Code"
        style AppCode fill:#ADD8E6,stroke:#333,stroke-width:2px
        Entrypoint["Application Entrypoint"]:::internal
        API["FastAPI API Service"]:::internal
        Worker["Celery Worker"]:::internal
        Services["Service Layer"]:::internal
        Repos["Data Access Layer"]:::internal
        Models["Pydantic Schemas & Models"]:::internal
        Clients["External Service Clients"]:::internal
        Utils["Utility Helpers"]:::internal
    end

    %% External/Internal Components
    Client["Client (curl / SDK)"]:::external
    Postgres[(PostgreSQL)]:::db
    Redis[(Redis Broker & Cache)]:::db
    S3[(AWS S3 Storage)]:::ext
    OpenAI[(OpenAI API)]:::ext
    Pinecone[(Pinecone Vector DB)]:::ext
    DBInit["Init DB Script"]:::orch_config
    Tests["Unit Tests"]:::test

    %% Relationships
    Client -->|"HTTP Request"| API
    API -->|"SQLAlchemy Async"| Postgres
    API -->|"Enqueue Task"| Redis
    Redis -->|"Consume Task"| Worker
    Worker -->|"SQLAlchemy Async"| Postgres
    Worker -->|"Upload/Download"| S3
    Worker -->|"Embeddings & Inference"| OpenAI
    Worker -->|"Store/Query Vectors"| Pinecone

    %% Application Code Flow
    Entrypoint --> API
    Entrypoint --> Worker
    API --> Services
    API --> Repos
    API --> Models
    API --> Clients
    API --> Utils
    Worker --> Services
    Worker --> Repos
    Worker --> Models
    Worker --> Clients
    Worker --> Utils

    %% Tests
    Tests --> API

    %% Click Events
    click Entrypoint "https://github.com/akshaypkulkarni/doc-intelligence-platform/blob/main/src/ai_document_platform/__main__.py"
    click API "https://github.com/akshaypkulkarni/doc-intelligence-platform/blob/main/src/ai_document_platform/api/main.py"
    click Services "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/src/ai_document_platform/services/"
    click Repos "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/src/ai_document_platform/repositories/"
    click Models "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/src/ai_document_platform/models/"
    click Clients "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/src/ai_document_platform/clients/"
    click Utils "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/src/ai_document_platform/utils/"
    click DBInit "https://github.com/akshaypkulkarni/doc-intelligence-platform/blob/main/scripts/init-db.sql"
    click DC "https://github.com/akshaypkulkarni/doc-intelligence-platform/blob/main/docker-compose.yml"
    click DF "https://github.com/akshaypkulkarni/doc-intelligence-platform/tree/main/docker/Dockerfile"
    click Tests "https://github.com/akshaypkulkarni/doc-intelligence-platform/blob/main/tests/unit/test_main.py"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000;
    classDef db fill:#90EE90,stroke:#000;
    classDef ext fill:#FFD700,stroke:#000;
    classDef orch_config fill:#FFC0CB,stroke:#000;
    classDef external fill:#D3D3D3,stroke:#000;
    classDef test fill:#E6E6FA,stroke:#000;
```
