# whenkey2007/synapse architecture

> Architecture diagram of the GitHub repository whenkey2007/synapse, 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/whenkey2007/synapse
- Repository: https://github.com/whenkey2007/synapse

## Overview

Synapse is a self-healing knowledge base: users trigger audits of connected documentation, review detected findings, and approve or roll back corrections. Its backend exposes document, audit, policy, history, authentication, and ledger capabilities; semantic analysis and confidence scoring inform findings, while SQLite stores knowledge and audit state. The README documents the broader product capabilities, but excerpts do not establish every runtime connection—unverified optional notification delivery is shown separately.

Main entry points: [`backend/api.py`](https://github.com/whenkey2007/synapse/blob/main/backend/api.py) (REST API), [`backend/engine.py`](https://github.com/whenkey2007/synapse/blob/main/backend/engine.py) (Audit Engine), [`backend/database.py`](https://github.com/whenkey2007/synapse/blob/main/backend/database.py) (SQLite Knowledge Store), [`backend/intelligence.py`](https://github.com/whenkey2007/synapse/blob/main/backend/intelligence.py) (Semantic Intelligence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface &amp; API"]
  node_frontend["Web Application<br/>[app.js]"]
  node_api["REST API<br/>[api.py]"]
  node_schemas["API Schemas<br/>[models.py]"]
end

subgraph group_reasoning["Audit &amp; Intelligence"]
  node_audit["Audit Engine<br/>[engine.py]"]
  node_semantic["Semantic Intelligence<br/>[intelligence.py]"]
  node_benchmark["AI Evaluation"]
end

subgraph group_governance["Review &amp; Security"]
  node_review["Findings &amp; Healing<br/>[engine.py]"]
  node_security["Authentication &amp; RBAC<br/>[security.py]"]
  node_notifications["Alert Dispatcher<br/>[notifications.py]"]
end

subgraph group_persistence["Knowledge &amp; Ledger"]
  node_sources["Document Sources<br/>[api.py]"]
  node_seed["Initial Knowledge Data<br/>[seed_data.py]"]
  node_store[("SQLite Knowledge Store<br/>[database.py]")]
  node_ledger[("Audit History Ledger<br/>[database.py]")]
end

node_user(("Knowledge Users"))
node_slack["Slack Webhook"]

node_user -->|"uses"| node_frontend
node_frontend -.->|"requests data"| node_api
node_api -->|"serves application"| node_frontend
node_api -->|"uses schemas"| node_schemas
node_api -->|"reads and writes"| node_store
node_api -->|"triggers audits"| node_audit
node_api -->|"authenticates and authorizes"| node_security
node_api -->|"verifies ledger"| node_semantic
node_api -->|"syncs sources"| node_sources
node_audit -->|"reads and updates"| node_store
node_audit -->|"uses reasoning"| node_semantic
node_audit -->|"routes findings"| node_review
node_review -->|"records decisions"| node_ledger
node_semantic -->|"verifies chain"| node_ledger
node_benchmark -->|"evaluates analysis"| node_semantic
node_benchmark -->|"evaluates routing"| node_audit
node_store -->|"loads initial data"| node_seed
node_store -->|"hashes seeded passwords"| node_security
node_review -.->|"may dispatch alerts"| node_notifications
node_notifications -->|"posts webhook"| node_slack

click node_frontend "https://github.com/whenkey2007/synapse/blob/main/dist/app.js"
click node_api "https://github.com/whenkey2007/synapse/blob/main/backend/api.py"
click node_schemas "https://github.com/whenkey2007/synapse/blob/main/backend/models.py"
click node_audit "https://github.com/whenkey2007/synapse/blob/main/backend/engine.py"
click node_semantic "https://github.com/whenkey2007/synapse/blob/main/backend/intelligence.py"
click node_benchmark "https://github.com/whenkey2007/synapse/blob/main/backend/evaluate_ml_model.py"
click node_review "https://github.com/whenkey2007/synapse/blob/main/backend/engine.py"
click node_security "https://github.com/whenkey2007/synapse/blob/main/backend/security.py"
click node_notifications "https://github.com/whenkey2007/synapse/blob/main/backend/notifications.py"
click node_sources "https://github.com/whenkey2007/synapse/blob/main/backend/api.py"
click node_seed "https://github.com/whenkey2007/synapse/blob/main/backend/seed_data.py"
click node_store "https://github.com/whenkey2007/synapse/blob/main/backend/database.py"
click node_ledger "https://github.com/whenkey2007/synapse/blob/main/backend/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_frontend,node_api,node_schemas,node_user toneBlue
class node_audit,node_semantic,node_benchmark toneAmber
class node_review,node_security,node_notifications,node_slack toneMint
class node_sources,node_seed,node_store,node_ledger toneRose
```

## Components

### User Interface & API

- [Web Application](https://github.com/whenkey2007/synapse/blob/main/dist/app.js): `dist/app.js`
- [REST API](https://github.com/whenkey2007/synapse/blob/main/backend/api.py): `backend/api.py`
- [API Schemas](https://github.com/whenkey2007/synapse/blob/main/backend/models.py): `backend/models.py`

### Audit & Intelligence

- [Audit Engine](https://github.com/whenkey2007/synapse/blob/main/backend/engine.py): `backend/engine.py`
- [Semantic Intelligence](https://github.com/whenkey2007/synapse/blob/main/backend/intelligence.py): `backend/intelligence.py`
- [AI Evaluation](https://github.com/whenkey2007/synapse/blob/main/backend/evaluate_ml_model.py): `backend/evaluate_ml_model.py`

### Review & Security

- [Findings & Healing](https://github.com/whenkey2007/synapse/blob/main/backend/engine.py): `backend/engine.py`
- [Authentication & RBAC](https://github.com/whenkey2007/synapse/blob/main/backend/security.py): `backend/security.py`
- [Alert Dispatcher](https://github.com/whenkey2007/synapse/blob/main/backend/notifications.py): `backend/notifications.py`

### Knowledge & Ledger

- [Document Sources](https://github.com/whenkey2007/synapse/blob/main/backend/api.py): `backend/api.py`
- [Initial Knowledge Data](https://github.com/whenkey2007/synapse/blob/main/backend/seed_data.py): `backend/seed_data.py`
- [SQLite Knowledge Store](https://github.com/whenkey2007/synapse/blob/main/backend/database.py): `backend/database.py`
- [Audit History Ledger](https://github.com/whenkey2007/synapse/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Knowledge Users**
- **Slack Webhook**

## Connections

- Knowledge Users → Web Application: uses (evidence: `README.md`)
- Web Application → REST API: requests data
- REST API → Web Application: serves application (evidence: `README.md`)
- REST API → API Schemas: uses schemas (evidence: `backend/api.py`)
- REST API → SQLite Knowledge Store: reads and writes (evidence: `backend/api.py`)
- REST API → Audit Engine: triggers audits (evidence: `backend/api.py`)
- REST API → Authentication & RBAC: authenticates and authorizes (evidence: `backend/api.py`)
- REST API → Semantic Intelligence: verifies ledger (evidence: `backend/api.py`)
- REST API → Document Sources: syncs sources (evidence: `README.md`)
- Audit Engine → SQLite Knowledge Store: reads and updates (evidence: `backend/engine.py`)
- Audit Engine → Semantic Intelligence: uses reasoning (evidence: `backend/engine.py`)
- Audit Engine → Findings & Healing: routes findings (evidence: `README.md`)
- Findings & Healing → Audit History Ledger: records decisions (evidence: `backend/engine.py`)
- Semantic Intelligence → Audit History Ledger: verifies chain (evidence: `backend/api.py`)
- AI Evaluation → Semantic Intelligence: evaluates analysis (evidence: `backend/evaluate_ml_model.py`)
- AI Evaluation → Audit Engine: evaluates routing (evidence: `backend/evaluate_ml_model.py`)
- SQLite Knowledge Store → Initial Knowledge Data: loads initial data (evidence: `backend/database.py`)
- SQLite Knowledge Store → Authentication & RBAC: hashes seeded passwords (evidence: `backend/database.py`)
- Findings & Healing → Alert Dispatcher: may dispatch alerts
- Alert Dispatcher → Slack Webhook: posts webhook (evidence: `backend/notifications.py`)
