# harsh-singh-2023/superjoin-fact-knowledge-layer architecture

> Architecture diagram of the GitHub repository harsh-singh-2023/superjoin-fact-knowledge-layer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsh-singh-2023/superjoin-fact-knowledge-layer
- Repository: https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer

## Overview

This is a PDF-based epistemic fact verification application, exposed through a Streamlit dashboard, REST API, and CLI. Its central workflow parses uploaded documents into page text, extracts atomic claims, checks quote grounding and normalizes values, then compares cross-document facts and presents or persists the results. The graph preserves the documented adversarial reasoning, confidence signals, and showcase capabilities. Some links come from README descriptions or SOURCE INDEX references; unsampled internals are not inferred beyond those links.

Main entry points: [`fact_layer/extractor.py`](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/extractor.py) (Fact Extractor), [`fact_layer/reasoner.py`](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/reasoner.py) (Cross-Document Reasoner), [`fact_layer/showcase.py`](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/showcase.py) (Showcase Cases), [`app.py`](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/app.py) (Streamlit Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Interfaces"]
  node_dashboard["Streamlit Dashboard<br/>[app.py]"]
  node_rest_api["REST API<br/>[api.py]"]
  node_cli["Command Line<br/>[run_cli.py]"]
  node_showcase["Showcase Cases<br/>[showcase.py]"]
end

subgraph group_ingest["Claim Ingestion"]
  node_pdf_parser["PDF Parser<br/>[pdf_parser.py]"]
  node_extractor["Fact Extractor<br/>[extractor.py]"]
  node_verifier["Grounding Verifier<br/>[verifier.py]"]
  node_normalizer["Value Normalizer<br/>[normalizer.py]"]
end

subgraph group_analysis["Epistemic Analysis"]
  node_matcher["Candidate Matcher<br/>[embeddings.py]"]
  node_reasoner["Cross-Document Reasoner<br/>[reasoner.py]"]
end

subgraph group_platform["Knowledge Services"]
  node_models["Domain Models<br/>[models.py]"]
  node_llm_client["LLM Client<br/>[llm_client.py]"]
  node_database[("SQLite Knowledge Store<br/>[database.py]")]
end

node_user(("Document User"))
node_api_client(("API Client"))
node_llm_provider{{"LLM Providers"}}

node_user -->|"uploads PDFs"| node_dashboard
node_user -->|"runs ingestion"| node_cli
node_api_client -->|"submits requests"| node_rest_api
node_dashboard -->|"parses documents"| node_pdf_parser
node_dashboard -->|"extracts claims"| node_extractor
node_dashboard -->|"compares facts"| node_reasoner
node_dashboard -->|"uses knowledge store"| node_database
node_dashboard -->|"runs showcase"| node_showcase
node_rest_api -->|"parses documents"| node_pdf_parser
node_rest_api -->|"extracts claims"| node_extractor
node_rest_api -->|"reasons over facts"| node_reasoner
node_rest_api -->|"persists results"| node_database
node_rest_api -->|"uses showcase"| node_showcase
node_cli -->|"parses documents"| node_pdf_parser
node_cli -->|"extracts claims"| node_extractor
node_cli -->|"compares facts"| node_reasoner
node_cli -->|"uses knowledge store"| node_database
node_cli -->|"runs showcase"| node_showcase
node_pdf_parser -->|"creates metadata"| node_models
node_extractor -->|"requests extraction"| node_llm_client
node_extractor -->|"checks quotes"| node_pdf_parser
node_extractor -->|"verifies grounding"| node_verifier
node_extractor -->|"normalizes values"| node_normalizer
node_extractor -->|"creates facts"| node_models
node_verifier -->|"returns grounding result"| node_models
node_reasoner -->|"finds candidate pairs"| node_matcher
node_reasoner -->|"requests debate"| node_llm_client
node_reasoner -->|"checks numeric values"| node_normalizer
node_reasoner -->|"checks grounding"| node_verifier
node_reasoner -->|"creates relationships"| node_models
node_llm_client -->|"calls providers"| node_llm_provider
node_database -->|"hydrates records"| node_models
node_showcase -->|"loads source PDFs"| node_pdf_parser
node_showcase -->|"extracts claims"| node_extractor
node_showcase -->|"evaluates cases"| node_reasoner
node_showcase -->|"seeds cases"| node_database
node_showcase -->|"builds case data"| node_models

click node_dashboard "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/app.py"
click node_rest_api "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/api.py"
click node_cli "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/run_cli.py"
click node_showcase "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/showcase.py"
click node_pdf_parser "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/pdf_parser.py"
click node_extractor "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/extractor.py"
click node_verifier "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/verifier.py"
click node_normalizer "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/normalizer.py"
click node_models "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/models.py"
click node_llm_client "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/llm_client.py"
click node_matcher "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/embeddings.py"
click node_reasoner "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/reasoner.py"
click node_database "https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/database.py"

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_dashboard,node_rest_api,node_cli,node_showcase,node_user,node_api_client toneBlue
class node_pdf_parser,node_extractor,node_verifier,node_normalizer toneAmber
class node_matcher,node_reasoner toneMint
class node_models,node_llm_client,node_database toneRose
class node_llm_provider toneIndigo
```

## Components

### User Interfaces

- [Streamlit Dashboard](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/app.py): `app.py`
- [REST API](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/api.py): `fact_layer/api.py`
- [Command Line](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/run_cli.py): `run_cli.py`
- [Showcase Cases](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/showcase.py): `fact_layer/showcase.py`

### Claim Ingestion

- [PDF Parser](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/pdf_parser.py): `fact_layer/pdf_parser.py`
- [Fact Extractor](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/extractor.py): `fact_layer/extractor.py`
- [Grounding Verifier](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/verifier.py): `fact_layer/verifier.py`
- [Value Normalizer](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/normalizer.py): `fact_layer/normalizer.py`

### Epistemic Analysis

- [Candidate Matcher](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/embeddings.py): `fact_layer/embeddings.py`
- [Cross-Document Reasoner](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/reasoner.py): `fact_layer/reasoner.py`

### Knowledge Services

- [Domain Models](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/models.py): `fact_layer/models.py`
- [LLM Client](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/llm_client.py): `fact_layer/llm_client.py`
- [SQLite Knowledge Store](https://github.com/harsh-singh-2023/superjoin-fact-knowledge-layer/blob/main/fact_layer/database.py): `fact_layer/database.py`

### Other components

- **Document User**
- **API Client**
- **LLM Providers**

## Connections

- Document User → Streamlit Dashboard: uploads PDFs (evidence: `README.md`)
- Document User → Command Line: runs ingestion (evidence: `README.md`)
- API Client → REST API: submits requests (evidence: `README.md`)
- Streamlit Dashboard → PDF Parser: parses documents (evidence: `app.py`)
- Streamlit Dashboard → Fact Extractor: extracts claims (evidence: `app.py`)
- Streamlit Dashboard → Cross-Document Reasoner: compares facts (evidence: `app.py`)
- Streamlit Dashboard → SQLite Knowledge Store: uses knowledge store (evidence: `app.py`)
- Streamlit Dashboard → Showcase Cases: runs showcase (evidence: `app.py`)
- REST API → PDF Parser: parses documents (evidence: `fact_layer/api.py`)
- REST API → Fact Extractor: extracts claims (evidence: `fact_layer/api.py`)
- REST API → Cross-Document Reasoner: reasons over facts (evidence: `fact_layer/api.py`)
- REST API → SQLite Knowledge Store: persists results (evidence: `fact_layer/api.py`)
- REST API → Showcase Cases: uses showcase (evidence: `fact_layer/api.py`)
- Command Line → PDF Parser: parses documents (evidence: `run_cli.py`)
- Command Line → Fact Extractor: extracts claims (evidence: `run_cli.py`)
- Command Line → Cross-Document Reasoner: compares facts (evidence: `run_cli.py`)
- Command Line → SQLite Knowledge Store: uses knowledge store (evidence: `run_cli.py`)
- Command Line → Showcase Cases: runs showcase (evidence: `run_cli.py`)
- PDF Parser → Domain Models: creates metadata (evidence: `fact_layer/pdf_parser.py`)
- Fact Extractor → LLM Client: requests extraction (evidence: `fact_layer/extractor.py`)
- Fact Extractor → PDF Parser: checks quotes (evidence: `fact_layer/extractor.py`)
- Fact Extractor → Grounding Verifier: verifies grounding (evidence: `fact_layer/extractor.py`)
- Fact Extractor → Value Normalizer: normalizes values (evidence: `fact_layer/extractor.py`)
- Fact Extractor → Domain Models: creates facts (evidence: `fact_layer/extractor.py`)
- Grounding Verifier → Domain Models: returns grounding result (evidence: `fact_layer/extractor.py`)
- Cross-Document Reasoner → Candidate Matcher: finds candidate pairs (evidence: `fact_layer/reasoner.py`)
- Cross-Document Reasoner → LLM Client: requests debate (evidence: `fact_layer/reasoner.py`)
- Cross-Document Reasoner → Value Normalizer: checks numeric values (evidence: `fact_layer/reasoner.py`)
- Cross-Document Reasoner → Grounding Verifier: checks grounding (evidence: `fact_layer/reasoner.py`)
- Cross-Document Reasoner → Domain Models: creates relationships (evidence: `fact_layer/reasoner.py`)
- LLM Client → LLM Providers: calls providers (evidence: `fact_layer/llm_client.py`)
- SQLite Knowledge Store → Domain Models: hydrates records (evidence: `fact_layer/database.py`)
- Showcase Cases → PDF Parser: loads source PDFs (evidence: `fact_layer/showcase.py`)
- Showcase Cases → Fact Extractor: extracts claims (evidence: `fact_layer/showcase.py`)
- Showcase Cases → Cross-Document Reasoner: evaluates cases (evidence: `fact_layer/showcase.py`)
- Showcase Cases → SQLite Knowledge Store: seeds cases (evidence: `fact_layer/showcase.py`)
- Showcase Cases → Domain Models: builds case data (evidence: `fact_layer/showcase.py`)
