# anaghapai/anamnesis architecture

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

- Interactive diagram: https://gitdiagram.com/anaghapai/anamnesis
- Repository: https://github.com/anaghapai/anamnesis

## Overview

Anamnesis is an offline organizational knowledge and memory app. Employees sign in, search or ask questions against permission-filtered documents and verified answers, then review cited results; managers can correct answers and facts, with downstream review and impact workflows. The backend also supports document access controls, workspace approvals, organizational insights, graph reasoning, and audit history. The README documents the product capabilities; source excerpts and the SOURCE INDEX identify backend modules, but do not expose most UI-to-API wiring, so those links are omitted or marked unverified.

Main entry points: [`backend/app/main.py`](https://github.com/anaghapai/anamnesis/blob/main/backend/app/main.py) (API routes), [`backend/app/retrieval.py`](https://github.com/anaghapai/anamnesis/blob/main/backend/app/retrieval.py) (Permission-aware retrieval), [`backend/app/models.py`](https://github.com/anaghapai/anamnesis/blob/main/backend/app/models.py) (Domain records), [`frontend/app.js`](https://github.com/anaghapai/anamnesis/blob/main/frontend/app.js) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_web_ui["Web application<br/>[app.js]"]
  node_search_ui["Knowledge search<br/>[search.js]"]
  node_insights_ui["Insights interface<br/>[insights.js]"]
  node_audit_ui["Audit interface<br/>[audit.js]"]
end

subgraph group_api["Application API"]
  node_api_routes["API routes<br/>[main.py]"]
  node_authentication["Authentication<br/>[auth.py]"]
  node_document_features["Document access and workspace<br/>[features.py]"]
  node_help_bot["Help navigation<br/>[help_bot.py]"]
end

subgraph group_knowledge["Knowledge processing"]
  node_document_extract["Document extraction<br/>[extract.py]"]
  node_search_engine["Permission-aware retrieval<br/>[retrieval.py]"]
  node_organization_search["Filtered search<br/>[orgsearch.py]"]
  node_language_processing["Concept matching<br/>[nlp.py]"]
  node_knowledge_graph["Knowledge graph<br/>[graph.py]"]
  node_knowledge_services["Knowledge answers<br/>[knowledge.py]"]
  node_local_reasoning["Local model reasoning<br/>[llm.py]"]
end

subgraph group_governance["Reviews and governance"]
  node_review_features["Document controls<br/>[features.py]"]
  node_insights["Review and memory insights<br/>[insights.py]"]
  node_impact["Dependency impact<br/>[impact.py]"]
  node_audit_view["Audit history<br/>[auditview.py]"]
  node_audit_chain["Audit chain<br/>[auditchain.py]"]
end

subgraph group_storage["Persistence"]
  node_data_model["Domain records<br/>[models.py]"]
  node_sqlite[("SQLite database<br/>[db.py]")]
end

node_employee(("Employee"))

node_employee -->|"uses"| node_web_ui
node_web_ui -.->|"includes"| node_search_ui
node_web_ui -.->|"includes"| node_insights_ui
node_web_ui -.->|"includes"| node_audit_ui
node_web_ui -.->|"calls API"| node_api_routes
node_api_routes -->|"uses"| node_authentication
node_api_routes -->|"routes features"| node_document_features
node_api_routes -->|"uses"| node_document_extract
node_api_routes -->|"uses"| node_search_engine
node_api_routes -->|"routes search"| node_organization_search
node_api_routes -->|"uses"| node_knowledge_graph
node_api_routes -->|"uses"| node_knowledge_services
node_api_routes -->|"routes reasoning"| node_local_reasoning
node_api_routes -->|"routes insights"| node_insights
node_api_routes -->|"routes impact"| node_impact
node_api_routes -->|"routes audit"| node_audit_view
node_api_routes -->|"routes audit chain"| node_audit_chain
node_search_engine -->|"matches concepts"| node_language_processing
node_organization_search -->|"matches concepts"| node_language_processing
node_knowledge_graph -->|"expands terms"| node_language_processing
node_knowledge_graph -->|"stores facts"| node_data_model
node_search_engine -->|"reads documents"| node_data_model
node_document_extract -.->|"returns extracted text"| node_api_routes
node_insights -.->|"updates facts"| node_knowledge_graph
node_insights -->|"uses retrieval"| node_search_engine
node_impact -->|"uses retrieval"| node_search_engine
node_local_reasoning -->|"checks evidence"| node_search_engine
node_document_features -->|"rebuilds chunks"| node_search_engine
node_document_features -->|"manages records"| node_data_model
node_audit_view -->|"reads audit records"| node_data_model
node_audit_chain -->|"reads audit records"| node_data_model
node_authentication -->|"loads users"| node_data_model
node_data_model -.->|"persists entities"| node_sqlite
node_help_bot -.->|"serves help"| node_api_routes

click node_web_ui "https://github.com/anaghapai/anamnesis/blob/main/frontend/app.js"
click node_search_ui "https://github.com/anaghapai/anamnesis/blob/main/frontend/search.js"
click node_insights_ui "https://github.com/anaghapai/anamnesis/blob/main/frontend/insights.js"
click node_audit_ui "https://github.com/anaghapai/anamnesis/blob/main/frontend/audit.js"
click node_api_routes "https://github.com/anaghapai/anamnesis/blob/main/backend/app/main.py"
click node_authentication "https://github.com/anaghapai/anamnesis/blob/main/backend/app/auth.py"
click node_document_features "https://github.com/anaghapai/anamnesis/blob/main/backend/app/features.py"
click node_help_bot "https://github.com/anaghapai/anamnesis/blob/main/backend/app/help_bot.py"
click node_document_extract "https://github.com/anaghapai/anamnesis/blob/main/backend/app/extract.py"
click node_search_engine "https://github.com/anaghapai/anamnesis/blob/main/backend/app/retrieval.py"
click node_organization_search "https://github.com/anaghapai/anamnesis/blob/main/backend/app/orgsearch.py"
click node_language_processing "https://github.com/anaghapai/anamnesis/blob/main/backend/app/nlp.py"
click node_knowledge_graph "https://github.com/anaghapai/anamnesis/blob/main/backend/app/graph.py"
click node_knowledge_services "https://github.com/anaghapai/anamnesis/blob/main/backend/app/knowledge.py"
click node_local_reasoning "https://github.com/anaghapai/anamnesis/blob/main/backend/app/llm.py"
click node_review_features "https://github.com/anaghapai/anamnesis/blob/main/backend/app/features.py"
click node_insights "https://github.com/anaghapai/anamnesis/blob/main/backend/app/insights.py"
click node_impact "https://github.com/anaghapai/anamnesis/blob/main/backend/app/impact.py"
click node_audit_view "https://github.com/anaghapai/anamnesis/blob/main/backend/app/auditview.py"
click node_audit_chain "https://github.com/anaghapai/anamnesis/blob/main/backend/app/auditchain.py"
click node_data_model "https://github.com/anaghapai/anamnesis/blob/main/backend/app/models.py"
click node_sqlite "https://github.com/anaghapai/anamnesis/blob/main/backend/app/db.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_web_ui,node_search_ui,node_insights_ui,node_audit_ui toneBlue
class node_api_routes,node_authentication,node_document_features,node_help_bot toneAmber
class node_document_extract,node_search_engine,node_organization_search,node_language_processing,node_knowledge_graph,node_knowledge_services,node_local_reasoning toneMint
class node_review_features,node_insights,node_impact,node_audit_view,node_audit_chain toneRose
class node_data_model,node_sqlite,node_employee toneIndigo
```

## Components

### User interface

- [Web application](https://github.com/anaghapai/anamnesis/blob/main/frontend/app.js): `frontend/app.js`
- [Knowledge search](https://github.com/anaghapai/anamnesis/blob/main/frontend/search.js): `frontend/search.js`
- [Insights interface](https://github.com/anaghapai/anamnesis/blob/main/frontend/insights.js): `frontend/insights.js`
- [Audit interface](https://github.com/anaghapai/anamnesis/blob/main/frontend/audit.js): `frontend/audit.js`

### Application API

- [API routes](https://github.com/anaghapai/anamnesis/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/anaghapai/anamnesis/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Document access and workspace](https://github.com/anaghapai/anamnesis/blob/main/backend/app/features.py): `backend/app/features.py`
- [Help navigation](https://github.com/anaghapai/anamnesis/blob/main/backend/app/help_bot.py): `backend/app/help_bot.py`

### Knowledge processing

- [Document extraction](https://github.com/anaghapai/anamnesis/blob/main/backend/app/extract.py): `backend/app/extract.py`
- [Permission-aware retrieval](https://github.com/anaghapai/anamnesis/blob/main/backend/app/retrieval.py): `backend/app/retrieval.py`
- [Filtered search](https://github.com/anaghapai/anamnesis/blob/main/backend/app/orgsearch.py): `backend/app/orgsearch.py`
- [Concept matching](https://github.com/anaghapai/anamnesis/blob/main/backend/app/nlp.py): `backend/app/nlp.py`
- [Knowledge graph](https://github.com/anaghapai/anamnesis/blob/main/backend/app/graph.py): `backend/app/graph.py`
- [Knowledge answers](https://github.com/anaghapai/anamnesis/blob/main/backend/app/knowledge.py): `backend/app/knowledge.py`
- [Local model reasoning](https://github.com/anaghapai/anamnesis/blob/main/backend/app/llm.py): `backend/app/llm.py`

### Reviews and governance

- [Document controls](https://github.com/anaghapai/anamnesis/blob/main/backend/app/features.py): `backend/app/features.py`
- [Review and memory insights](https://github.com/anaghapai/anamnesis/blob/main/backend/app/insights.py): `backend/app/insights.py`
- [Dependency impact](https://github.com/anaghapai/anamnesis/blob/main/backend/app/impact.py): `backend/app/impact.py`
- [Audit history](https://github.com/anaghapai/anamnesis/blob/main/backend/app/auditview.py): `backend/app/auditview.py`
- [Audit chain](https://github.com/anaghapai/anamnesis/blob/main/backend/app/auditchain.py): `backend/app/auditchain.py`

### Persistence

- [Domain records](https://github.com/anaghapai/anamnesis/blob/main/backend/app/models.py): `backend/app/models.py`
- [SQLite database](https://github.com/anaghapai/anamnesis/blob/main/backend/app/db.py): `backend/app/db.py`

### Other components

- **Employee**

## Connections

- Employee → Web application: uses (evidence: `README.md`)
- Web application → Knowledge search: includes
- Web application → Insights interface: includes
- Web application → Audit interface: includes
- Web application → API routes: calls API
- API routes → Authentication: uses (evidence: `backend/app/main.py`)
- API routes → Document access and workspace: routes features (evidence: `backend/app/main.py`)
- API routes → Document extraction: uses (evidence: `backend/app/main.py`)
- API routes → Permission-aware retrieval: uses (evidence: `backend/app/main.py`)
- API routes → Filtered search: routes search (evidence: `backend/app/main.py`)
- API routes → Knowledge graph: uses (evidence: `backend/app/main.py`)
- API routes → Knowledge answers: uses (evidence: `backend/app/main.py`)
- API routes → Local model reasoning: routes reasoning (evidence: `backend/app/main.py`)
- API routes → Review and memory insights: routes insights (evidence: `backend/app/main.py`)
- API routes → Dependency impact: routes impact (evidence: `backend/app/main.py`)
- API routes → Audit history: routes audit (evidence: `backend/app/main.py`)
- API routes → Audit chain: routes audit chain (evidence: `backend/app/main.py`)
- Permission-aware retrieval → Concept matching: matches concepts (evidence: `backend/app/retrieval.py`)
- Filtered search → Concept matching: matches concepts (evidence: `backend/app/orgsearch.py`)
- Knowledge graph → Concept matching: expands terms (evidence: `backend/app/graph.py`)
- Knowledge graph → Domain records: stores facts (evidence: `backend/app/graph.py`)
- Permission-aware retrieval → Domain records: reads documents (evidence: `backend/app/retrieval.py`)
- Document extraction → API routes: returns extracted text (evidence: `backend/app/main.py`)
- Review and memory insights → Knowledge graph: updates facts
- Review and memory insights → Permission-aware retrieval: uses retrieval (evidence: `backend/app/insights.py`)
- Dependency impact → Permission-aware retrieval: uses retrieval (evidence: `backend/app/impact.py`)
- Local model reasoning → Permission-aware retrieval: checks evidence (evidence: `backend/app/llm.py`)
- Document access and workspace → Permission-aware retrieval: rebuilds chunks (evidence: `backend/app/features.py`)
- Document access and workspace → Domain records: manages records (evidence: `backend/app/features.py`)
- Audit history → Domain records: reads audit records (evidence: `backend/app/auditview.py`)
- Audit chain → Domain records: reads audit records (evidence: `backend/app/auditchain.py`)
- Authentication → Domain records: loads users (evidence: `backend/app/auth.py`)
- Domain records → SQLite database: persists entities
- Help navigation → API routes: serves help
