# sivangbagri/note_be architecture

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

- Interactive diagram: https://gitdiagram.com/sivangbagri/note_be
- Repository: https://github.com/sivangbagri/note_be

## Overview

##### Project Type & Purpose
- This is a backend microservice (“Multilingual Note‑Taking Agent”) built with FastAPI.
- It provides REST endpoints to upload meeting audio, transcribe it, summarize content, perform keyword search, run sentiment analysis, and export PDF summaries.
- Core AI components: Whisper/Faster‑Whisper for ASR; LangChain + Qwen/DeepSeek for summarization; SQLite FTS5 for transcript storage; fpdf for PDF export.

##### File Structure & Architectural Patterns
- Entry point:
- main.py – FastAPI app, routers for `/upload_audio`, `/search`, `/export_pdf`.
- Service modules (under modules/):
- transcriber.py – orchestrates whisper ASR.
- summarizer.py – calls LangChain pipelines to extract summary & action items.
- search.py – queries transcripts.db (SQLite FTS5).
- exporter.py – uses fpdf to assemble PDF with summaries + sentiment charts/fonts.
- fonts/ – PDF font assets.
- Utility modules (under utils/):
- format.py – text cleanup & PDF formatting helpers.
- sentiments.py – computes sentiment scores (charts/tables).
- Persistence & artifacts:
- transcripts.db – SQLite with full-text search.
- output/ – generated PDF summaries.
- Configuration:
- requirements.txt – dependency list (FastAPI, Whisper, LangChain, fpdf, SQLite, etc.).

##### Key Components
a. API Layer (FastAPI)
b. ASR Service
c. Summarization Service
d. Search Service
e. PDF Export Service
f. Utilities
- “Utils” (format.py, sentiments.py) supporting Summarizer & Exporter.
g. Data Store
h. External ML Models
i. Output Storage

##### Architectural Patterns & Principles
- Layered architecture: Presentation (API) → Service layer (modules) → Data layer (SQLite)
- Modular design: each AI capability is its own module
- Single Responsibility: transcriber only handles ASR, summarizer only handles summarization, etc.
- Dependency injection: main.py wires modules into FastAPI routers.

##### Final Checklist
- Clear, self‑explanatory labels on all components
- Grouping of related components (e.g., all modules under a “Service Layer” boundary)
- External dependencies (AI models, client) shown outside the core boundary
- Data store and output artifacts distinctly represented

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client"]:::external

    %% API Layer
    subgraph "API Layer"
        direction TB
        FastAPI["FastAPI App"]:::api
        FA1["/upload_audio"]:::api
        FA2["/search"]:::api
        FA3["/export_pdf"]:::api
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        Transcriber["Transcriber"]:::internal
        Summarizer["Summarizer"]:::internal
        SearchMod["Search"]:::internal
        Exporter["Exporter"]:::internal
        Sample["Pipeline Orchestrator"]:::internal
        Fonts["PDF Font Assets"]:::internal
    end

    %% Utils
    subgraph "Utils"
        direction TB
        Format["format.py"]:::internal
        Sentiments["sentiments.py"]:::internal
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB["transcripts.db\n(SQLite FTS5)"]:::datastore
    end

    %% External AI Models
    subgraph "External AI Models"
        direction TB
        WhisperModel["Whisper\n/ Faster‑Whisper"]:::external
        LangChainModel["LangChain + Qwen/DeepSeek"]:::external
    end

    %% PDF Engine
    subgraph "PDF Engine"
        direction TB
        FPDF["fpdf"]:::external
    end

    %% Output
    subgraph "Output"
        direction TB
        PDFOut["output/*.pdf"]:::output
    end

    %% Connections
    Client -->|"HTTP request"| FastAPI

    FastAPI --> FA1
    FastAPI --> FA2
    FastAPI --> FA3

    FA1 -->|"audio file"| Transcriber
    Transcriber -->|"audio file"| WhisperModel
    WhisperModel -->|"transcript text"| DB

    DB -->|"transcript text"| Summarizer
    DB -->|"transcript text"| Sentiments

    Summarizer -->|"transcript text"| LangChainModel
    LangChainModel -->|"summary & actions"| Exporter

    Sentiments -->|"sentiment data"| Exporter
    Format -->|"formatted text"| Exporter

    Exporter -->|"summary+sentiment+format"| FPDF
    FPDF -->|"PDF file"| PDFOut

    PDFOut --> FastAPI
    FastAPI -->|"PDF or JSON response"| Client

    FA2 -->|"search query"| SearchMod
    SearchMod -->|"read transcript"| DB
    SearchMod -->|"results"| FastAPI

    %% Sample orchestrator
    Sample --> Transcriber
    Sample --> Summarizer

    %% Click Events
    click FastAPI "https://github.com/sivangbagri/note_be/blob/master/main.py"
    click Transcriber "https://github.com/sivangbagri/note_be/blob/master/modules/transcriber.py"
    click Summarizer "https://github.com/sivangbagri/note_be/blob/master/modules/summarizer.py"
    click SearchMod "https://github.com/sivangbagri/note_be/blob/master/modules/search.py"
    click Exporter "https://github.com/sivangbagri/note_be/blob/master/modules/exporter.py"
    click Format "https://github.com/sivangbagri/note_be/blob/master/utils/format.py"
    click Sentiments "https://github.com/sivangbagri/note_be/blob/master/utils/sentiments.py"
    click DB "https://github.com/sivangbagri/note_be/blob/master/transcripts.db"
    click PDFOut "https://github.com/sivangbagri/note_be/tree/master/output/"
    click Sample "https://github.com/sivangbagri/note_be/blob/master/modules/sample.py"
    click Fonts "https://github.com/sivangbagri/note_be/tree/master/modules/fonts/"

    %% Styles
    classDef api fill:#d4f8d4,stroke:#333,stroke-width:1px;
    classDef internal fill:#d4e0f7,stroke:#333,stroke-width:1px;
    classDef external fill:#ffe1a8,stroke:#333,stroke-width:1px;
    classDef datastore fill:#e0e0e0,stroke:#333,stroke-width:1px;
    classDef output fill:#fff5b1,stroke:#333,stroke-width:1px;
```
