# yiannislevy/bloodpanel architecture

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

- Interactive diagram: https://gitdiagram.com/yiannislevy/bloodpanel
- Repository: https://github.com/yiannislevy/bloodpanel

## Overview

##### Project type and purpose
- This is a full-stack web application (“Blood Test OCR & AI Parser”) that lets users upload PDF blood tests, runs OCR and an LLM parser, then stores and displays structured results in a dashboard.

##### File structure
- Top-level dirs:
- backend/ (FastAPI service with routers, models, utils, DB setup)
- frontend/ (React SPA with components, API wrapper, utils)
- alembic/ & alembic.ini (DB migration config)
- Config and entry points: requirements.txt, package.json, backend/main.py, frontend/src/index.js

##### Extract README insights
- Key workflow: PDF upload → pdfplumber/pdf2image OCR → OpenAI GPT-4o parsing → Pydantic validation → PostgreSQL via SQLAlchemy → React dashboard
- Tech stack: React + react-dropzone, FastAPI, Pydantic, SQLAlchemy, Alembic, OpenAI GPT-4o, pdfplumber, pdf2image

- Blue for frontend/UI
- Green for backend internal modules
- Orange for external services (OpenAI)
- Grey for database

##### Detailed coverage
- DB migration path (Alembic) in the backend block.
- Pydantic as the glue between raw LLM output and ORM models.
- Routers (sessions, upload) are called out in the API layer.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend (Browser/React SPA)"
        direction TB
        Browser["User's Browser"]:::frontend
        Index["index.js"]:::frontend
        App["App.js"]:::frontend
        subgraph "Components"
            direction TB
            Upload["Upload"]:::frontend
            SessionList["SessionList"]:::frontend
            SessionDetails["SessionDetails"]:::frontend
            MetricTrend["MetricTrend"]:::frontend
            Dashboard["Dashboard"]:::frontend
        end
        API["API Wrapper (api.js)"]:::frontend
        Utils["String Utils (stringUtils.js)"]:::frontend
    end

    subgraph "Backend (FastAPI Service)"
        direction TB
        Main["main.py"]:::backend
        subgraph "Routers"
            direction TB
            UploadEP["upload.py"]:::backend
            SessionsEP["sessions.py"]:::backend
        end
        UtilsBP["Text Processors (text_processors.py)"]:::backend
        Pydantic["Data Models (data_models.py)"]:::backend
        ORM["ORM Models (orm_models.py)"]:::backend
        DBConn["Database (database.py)"]:::backend
        subgraph "Migrations (Alembic)"
            direction TB
            AlembicEnv["env.py"]:::backend
            AlembicIni["alembic.ini"]:::backend
            Migrations["versions/*.py"]:::backend
            Templates["script.py.mako"]:::backend
        end
    end

    OpenAI["OpenAI GPT-4o API"]:::external
    Postgres["PostgreSQL"]:::db

    Browser --> Index
    Index --> App
    App --> Upload
    App --> SessionList
    App --> SessionDetails
    App --> MetricTrend
    App --> Dashboard
    Upload --> API
    SessionList --> API
    SessionDetails --> API
    MetricTrend --> API
    Dashboard --> API
    API -->|"POST /upload\nGET /sessions"| Main
    Main --> UploadEP
    Main --> SessionsEP
    UploadEP --> UtilsBP
    UtilsBP --> OpenAI
    UploadEP --> Pydantic
    SessionsEP --> Pydantic
    Pydantic --> ORM
    SessionsEP --> ORM
    ORM --> DBConn
    DBConn --> Postgres
    DBConn -->|"migration"| AlembicEnv
    AlembicEnv --> AlembicIni
    AlembicEnv --> Migrations
    AlembicEnv --> Templates
    UploadEP --> API
    SessionsEP --> API
    API --> Browser

    click Index "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/index.js"
    click App "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/App.js"
    click Upload "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/components/Upload.js"
    click SessionList "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/components/SessionList.js"
    click SessionDetails "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/components/SessionDetails.js"
    click MetricTrend "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/components/MetricTrend.js"
    click Dashboard "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/components/Dashboard.js"
    click API "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/api.js"
    click Utils "https://github.com/yiannislevy/bloodpanel/blob/main/frontend/src/utils/stringUtils.js"
    click Main "https://github.com/yiannislevy/bloodpanel/blob/main/backend/main.py"
    click UploadEP "https://github.com/yiannislevy/bloodpanel/blob/main/backend/routers/upload.py"
    click SessionsEP "https://github.com/yiannislevy/bloodpanel/blob/main/backend/routers/sessions.py"
    click UtilsBP "https://github.com/yiannislevy/bloodpanel/blob/main/backend/utils/text_processors.py"
    click Pydantic "https://github.com/yiannislevy/bloodpanel/blob/main/backend/models/data_models.py"
    click ORM "https://github.com/yiannislevy/bloodpanel/blob/main/backend/models/orm_models.py"
    click DBConn "https://github.com/yiannislevy/bloodpanel/blob/main/backend/database.py"
    click AlembicIni "https://github.com/yiannislevy/bloodpanel/blob/main/alembic.ini"
    click AlembicEnv "https://github.com/yiannislevy/bloodpanel/blob/main/alembic/env.py"
    click Migrations "https://github.com/yiannislevy/bloodpanel/blob/main/alembic/versions/*.py"
    click Templates "https://github.com/yiannislevy/bloodpanel/blob/main/alembic/script.py.mako"

    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef external fill:#fff3cd,stroke:#856404,color:#856404
    classDef db fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
