# niharxd/document-summarizer architecture

> Architecture diagram of the GitHub repository niharxd/document-summarizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/niharxd/document-summarizer
- Repository: https://github.com/niharxd/document-summarizer

## Overview

Document Summarizer accepts PDF, DOCX, and TXT uploads, infers or accepts a legal, medical, or technical domain, and returns a Cohere-generated domain-specific summary with document and processing metrics. Reviewers can rate the result. A separate PySpark ETL path transforms source documents, while summary metrics and feedback feed Grafana-oriented CSV exports. The excerpts show ingestion, transformation, persistence, and export details; some UI wiring and dashboard data-source configuration are supported only by the README, so those links are documented rather than inferred from unsampled code.

Main entry points: [`app/gradio_app.py`](https://github.com/niharxd/document-summarizer/blob/main/app/gradio_app.py) (Gradio interface), [`grafana/export_metrics.py`](https://github.com/niharxd/document-summarizer/blob/main/grafana/export_metrics.py) (Metric exports), [`etl/pipeline.py`](https://github.com/niharxd/document-summarizer/blob/main/etl/pipeline.py) (Spark ETL), [`summarizer/summary_metrics.py`](https://github.com/niharxd/document-summarizer/blob/main/summarizer/summary_metrics.py) (Summary metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Review experience"]
  node_ui["Gradio interface<br/>[gradio_app.py]"]
  node_feedback["Rating persistence<br/>[feedback.py]"]
end

subgraph group_summarization["Summary generation"]
  node_loader["Document ingestion<br/>[document_loader.py]"]
  node_cohere["Domain summarizer<br/>[cohere_client.py]"]
  node_summary_metrics["Summary metrics<br/>[summary_metrics.py]"]
  node_raw_docs["Source documents"]
end

subgraph group_analytics["ETL and analytics"]
  node_etl_pipeline["Spark ETL<br/>[pipeline.py]"]
  node_transformations["Text transformations<br/>[transformations.py]"]
  node_etl_store[("ETL Parquet")]
  node_summary_store[("Summary records")]
  node_feedback_store[("Rating records")]
end

subgraph group_monitoring["Monitoring"]
  node_exporter["Metric exports<br/>[export_metrics.py]"]
  node_csv_exports[("Grafana CSVs")]
  node_csv_server["CSV endpoint<br/>[serve.py]"]
  node_dashboard["Grafana dashboard<br/>[dashboard.json]"]
end

node_reviewer(("Document reviewer"))
node_cohere_service{{"Cohere API"}}

node_reviewer -->|"uploads and reviews"| node_ui
node_ui -->|"loads document"| node_loader
node_ui -->|"requests summary"| node_cohere
node_cohere -->|"calls API"| node_cohere_service
node_ui -->|"records metrics"| node_summary_metrics
node_ui -->|"submits rating"| node_feedback
node_loader -->|"extracts text"| node_raw_docs
node_etl_pipeline -->|"loads documents"| node_loader
node_etl_pipeline -->|"applies transforms"| node_transformations
node_etl_pipeline -->|"writes Parquet"| node_etl_store
node_summary_metrics -->|"counts words"| node_transformations
node_summary_metrics -->|"appends JSONL"| node_summary_store
node_feedback -->|"appends CSV"| node_feedback_store
node_exporter -->|"reads Parquet"| node_etl_store
node_exporter -->|"reads JSONL"| node_summary_store
node_exporter -->|"reads ratings"| node_feedback_store
node_exporter -->|"writes aggregates"| node_csv_exports
node_csv_server -->|"serves CSVs"| node_csv_exports
node_dashboard -.->|"visualizes exports"| node_csv_server

click node_ui "https://github.com/niharxd/document-summarizer/blob/main/app/gradio_app.py"
click node_loader "https://github.com/niharxd/document-summarizer/blob/main/app/document_loader.py"
click node_cohere "https://github.com/niharxd/document-summarizer/blob/main/summarizer/cohere_client.py"
click node_summary_metrics "https://github.com/niharxd/document-summarizer/blob/main/summarizer/summary_metrics.py"
click node_feedback "https://github.com/niharxd/document-summarizer/blob/main/app/feedback.py"
click node_raw_docs "https://github.com/niharxd/document-summarizer/tree/main/data/raw"
click node_etl_pipeline "https://github.com/niharxd/document-summarizer/blob/main/etl/pipeline.py"
click node_transformations "https://github.com/niharxd/document-summarizer/blob/main/etl/transformations.py"
click node_exporter "https://github.com/niharxd/document-summarizer/blob/main/grafana/export_metrics.py"
click node_csv_server "https://github.com/niharxd/document-summarizer/blob/main/grafana/serve.py"
click node_dashboard "https://github.com/niharxd/document-summarizer/blob/main/grafana/dashboard.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ui,node_feedback,node_reviewer toneBlue
class node_loader,node_cohere,node_summary_metrics,node_raw_docs toneAmber
class node_etl_pipeline,node_transformations,node_etl_store,node_summary_store,node_feedback_store,node_cohere_service toneMint
class node_exporter,node_csv_exports,node_csv_server,node_dashboard toneRose
```

## Components

### Review experience

- [Gradio interface](https://github.com/niharxd/document-summarizer/blob/main/app/gradio_app.py): `app/gradio_app.py`
- [Rating persistence](https://github.com/niharxd/document-summarizer/blob/main/app/feedback.py): `app/feedback.py`

### Summary generation

- [Document ingestion](https://github.com/niharxd/document-summarizer/blob/main/app/document_loader.py): `app/document_loader.py`
- [Domain summarizer](https://github.com/niharxd/document-summarizer/blob/main/summarizer/cohere_client.py): `summarizer/cohere_client.py`
- [Summary metrics](https://github.com/niharxd/document-summarizer/blob/main/summarizer/summary_metrics.py): `summarizer/summary_metrics.py`
- [Source documents](https://github.com/niharxd/document-summarizer/tree/main/data/raw): `data/raw`

### ETL and analytics

- [Spark ETL](https://github.com/niharxd/document-summarizer/blob/main/etl/pipeline.py): `etl/pipeline.py`
- [Text transformations](https://github.com/niharxd/document-summarizer/blob/main/etl/transformations.py): `etl/transformations.py`
- **ETL Parquet**
- **Summary records**
- **Rating records**

### Monitoring

- [Metric exports](https://github.com/niharxd/document-summarizer/blob/main/grafana/export_metrics.py): `grafana/export_metrics.py`
- **Grafana CSVs**
- [CSV endpoint](https://github.com/niharxd/document-summarizer/blob/main/grafana/serve.py): `grafana/serve.py`
- [Grafana dashboard](https://github.com/niharxd/document-summarizer/blob/main/grafana/dashboard.json): `grafana/dashboard.json`

### Other components

- **Document reviewer**
- **Cohere API**

## Connections

- Document reviewer → Gradio interface: uploads and reviews (evidence: `README.md`)
- Gradio interface → Document ingestion: loads document (evidence: `README.md`)
- Gradio interface → Domain summarizer: requests summary (evidence: `README.md`)
- Domain summarizer → Cohere API: calls API (evidence: `summarizer/cohere_client.py`)
- Gradio interface → Summary metrics: records metrics (evidence: `README.md`)
- Gradio interface → Rating persistence: submits rating (evidence: `README.md`)
- Document ingestion → Source documents: extracts text (evidence: `app/document_loader.py`)
- Spark ETL → Document ingestion: loads documents (evidence: `etl/pipeline.py`)
- Spark ETL → Text transformations: applies transforms (evidence: `etl/pipeline.py`)
- Spark ETL → ETL Parquet: writes Parquet (evidence: `README.md`)
- Summary metrics → Text transformations: counts words (evidence: `summarizer/summary_metrics.py`)
- Summary metrics → Summary records: appends JSONL (evidence: `summarizer/summary_metrics.py`)
- Rating persistence → Rating records: appends CSV (evidence: `app/feedback.py`)
- Metric exports → ETL Parquet: reads Parquet (evidence: `grafana/export_metrics.py`)
- Metric exports → Summary records: reads JSONL (evidence: `grafana/export_metrics.py`)
- Metric exports → Rating records: reads ratings (evidence: `grafana/export_metrics.py`)
- Metric exports → Grafana CSVs: writes aggregates (evidence: `grafana/export_metrics.py`)
- CSV endpoint → Grafana CSVs: serves CSVs (evidence: `grafana/serve.py`)
- Grafana dashboard → CSV endpoint: visualizes exports (evidence: `README.md`)
