# senthilnathan8114-create/justice-ledger architecture

> Architecture diagram of the GitHub repository senthilnathan8114-create/justice-ledger, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/senthilnathan8114-create/justice-ledger
- Repository: https://github.com/senthilnathan8114-create/justice-ledger

## Overview

Justice Ledger is a Flask eVault for legal records. The principal workflow is an authenticated user uploading a document (and ownership declaration), screening and storing it encrypted, then recording its signed version on the ledger; users can later retrieve or verify records and produce portable proofs or selective disclosures. Other documented capabilities include legal case/evidence management, identity and access controls, AI assistance, integrations, and replicated nodes. Edges are limited to calls visible in excerpts or references documented by the README/SOURCE INDEX; unsampled internals are represented only at supported paths.

Main entry points: [`app/routes_core.py`](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_core.py) (Record and case routes), [`app/db.py`](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/db.py) (Application database), [`app/services.py`](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/services.py) (Version and verification services), [`app/routes_trust.py`](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_trust.py) (Verification and sharing routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Identity and access"]
  node_auth_routes["Authentication routes<br/>[routes_auth.py]"]
  node_admin_login["Admin portal login"]
  node_webauthn["Passkey login<br/>[routes_webauthn.py]"]
  node_auth["Identity and RBAC<br/>[auth.py]"]
  node_access_rules["Record permissions<br/>[access.py]"]
end

subgraph group_records["Legal records"]
  node_db[("Application database<br/>[db.py]")]
  node_core_routes["Record and case routes<br/>[routes_core.py]"]
  node_services["Version and verification services<br/>[services.py]"]
  node_vault["Encrypted content vault<br/>[storage.py]"]
end

subgraph group_trust["Ledger and proofs"]
  node_blockchain[("Signed ledger<br/>[blockchain.py]")]
  node_trust_routes["Verification and sharing routes<br/>[routes_trust.py]"]
  node_proof["Offline proof packages<br/>[proof.py]"]
  node_redaction["Selective disclosure<br/>[redaction.py]"]
  node_audit[("Tamper-evident activity log<br/>[audit.py]")]
  node_contracts["Policy contracts<br/>[contracts.py]"]
end

subgraph group_operations["Node operations"]
  node_network_routes["Node administration routes<br/>[routes_node.py]"]
  node_network["Peer replication and healing<br/>[network.py]"]
  node_keys_routes["Key management routes<br/>[routes_keys.py]"]
  node_keys["Versioned key ring<br/>[keys.py]"]
end

subgraph group_intelligence["AI and integration"]
  node_ai_screen["Forgery screening<br/>[ai.py]"]
  node_interop_routes["External API routes<br/>[routes_interop.py]"]
  node_interop["API keys and webhooks<br/>[interop.py]"]
  node_extra_routes["Search and assistant routes<br/>[routes_extra.py]"]
  node_grounded["Grounded legal Q&amp;A<br/>[grounded.py]"]
  node_search["Concept search<br/>[search.py]"]
  node_i18n["Legal language glossary<br/>[legal_i18n.py]"]
end

node_user(("Legal user"))
node_admin(("Administrator"))
node_web["Web UI<br/>[app.js]"]
node_external_system(("E-filing system"))
node_ipfs[("IPFS node")]

node_user -->|"uses"| node_web
node_admin -->|"opens portal"| node_web
node_web -.->|"requests login"| node_auth_routes
node_web -.->|"uploads records"| node_core_routes
node_auth_routes -->|"checks identity"| node_auth
node_admin_login -->|"issues admin session"| node_auth
node_webauthn -->|"uses authentication"| node_auth
node_auth_routes -->|"reads and writes"| node_db
node_core_routes -->|"requires permission"| node_auth
node_core_routes -->|"checks visibility"| node_access_rules
node_core_routes -->|"stores version"| node_services
node_core_routes -->|"reads and writes"| node_db
node_services -->|"stores ciphertext"| node_vault
node_services -->|"extracts text"| node_ai_screen
node_services -->|"records version"| node_blockchain
node_services -->|"stores metadata"| node_db
node_vault -.->|"stores blobs"| node_ipfs
node_trust_routes -->|"checks records"| node_blockchain
node_trust_routes -->|"logs activity"| node_audit
node_trust_routes -->|"uses policies"| node_contracts
node_trust_routes -->|"reads and writes"| node_db
node_extra_routes -->|"creates proofs"| node_proof
node_extra_routes -->|"handles disclosure"| node_redaction
node_extra_routes -->|"runs search"| node_search
node_extra_routes -->|"runs AI tools"| node_ai_screen
node_grounded -->|"retrieves passages"| node_search
node_grounded -->|"uses disclosure"| node_redaction
node_grounded -->|"uses glossary"| node_i18n
node_network_routes -->|"administers peers"| node_network
node_network_routes -->|"reads state"| node_db
node_keys_routes -->|"rotates keys"| node_keys
node_interop_routes -->|"manages integrations"| node_interop
node_interop_routes -.->|"serves filings"| node_external_system
node_core_routes -->|"notifies case events"| node_interop
node_interop -->|"uses ledger"| node_blockchain
node_interop -->|"reads and writes"| node_db

click node_web "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/static/app.js"
click node_auth_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_auth.py"
click node_admin_login "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_admin_login.py"
click node_webauthn "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_webauthn.py"
click node_auth "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/auth.py"
click node_access_rules "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/access.py"
click node_db "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/db.py"
click node_core_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_core.py"
click node_services "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/services.py"
click node_vault "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/storage.py"
click node_ai_screen "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/ai.py"
click node_blockchain "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/blockchain.py"
click node_trust_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_trust.py"
click node_proof "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/proof.py"
click node_redaction "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/redaction.py"
click node_audit "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/audit.py"
click node_contracts "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/contracts.py"
click node_network_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_node.py"
click node_network "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/network.py"
click node_keys_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_keys.py"
click node_keys "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/keys.py"
click node_interop_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_interop.py"
click node_interop "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/interop.py"
click node_extra_routes "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_extra.py"
click node_grounded "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/grounded.py"
click node_search "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/search.py"
click node_i18n "https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/legal_i18n.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_auth_routes,node_admin_login,node_webauthn,node_auth,node_access_rules,node_user,node_web toneBlue
class node_db,node_core_routes,node_services,node_vault,node_ipfs toneAmber
class node_blockchain,node_trust_routes,node_proof,node_redaction,node_audit,node_contracts toneMint
class node_network_routes,node_network,node_keys_routes,node_keys toneRose
class node_ai_screen,node_interop_routes,node_interop,node_extra_routes,node_grounded,node_search,node_i18n,node_admin,node_external_system toneIndigo
```

## Components

### Identity and access

- [Authentication routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_auth.py): `app/routes_auth.py`
- [Admin portal login](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_admin_login.py): `app/routes_admin_login.py`
- [Passkey login](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_webauthn.py): `app/routes_webauthn.py`
- [Identity and RBAC](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/auth.py): `app/auth.py`
- [Record permissions](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/access.py): `app/access.py`

### Legal records

- [Application database](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/db.py): `app/db.py`
- [Record and case routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_core.py): `app/routes_core.py`
- [Version and verification services](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/services.py): `app/services.py`
- [Encrypted content vault](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/storage.py): `app/storage.py`

### Ledger and proofs

- [Signed ledger](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/blockchain.py): `app/blockchain.py`
- [Verification and sharing routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_trust.py): `app/routes_trust.py`
- [Offline proof packages](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/proof.py): `app/proof.py`
- [Selective disclosure](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/redaction.py): `app/redaction.py`
- [Tamper-evident activity log](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/audit.py): `app/audit.py`
- [Policy contracts](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/contracts.py): `app/contracts.py`

### Node operations

- [Node administration routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_node.py): `app/routes_node.py`
- [Peer replication and healing](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/network.py): `app/network.py`
- [Key management routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_keys.py): `app/routes_keys.py`
- [Versioned key ring](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/keys.py): `app/keys.py`

### AI and integration

- [Forgery screening](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/ai.py): `app/ai.py`
- [External API routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_interop.py): `app/routes_interop.py`
- [API keys and webhooks](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/interop.py): `app/interop.py`
- [Search and assistant routes](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/routes_extra.py): `app/routes_extra.py`
- [Grounded legal Q&A](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/grounded.py): `app/grounded.py`
- [Concept search](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/search.py): `app/search.py`
- [Legal language glossary](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/app/legal_i18n.py): `app/legal_i18n.py`

### Other components

- **Legal user**
- **Administrator**
- [Web UI](https://github.com/senthilnathan8114-create/justice-ledger/blob/main/static/app.js): `static/app.js`
- **E-filing system**
- **IPFS node**

## Connections

- Legal user → Web UI: uses
- Administrator → Web UI: opens portal
- Web UI → Authentication routes: requests login
- Web UI → Record and case routes: uploads records
- Authentication routes → Identity and RBAC: checks identity (evidence: `app/routes_auth.py`)
- Admin portal login → Identity and RBAC: issues admin session (evidence: `app/routes_admin_login.py`)
- Passkey login → Identity and RBAC: uses authentication (evidence: `app/routes_webauthn.py`)
- Authentication routes → Application database: reads and writes (evidence: `app/routes_auth.py`)
- Record and case routes → Identity and RBAC: requires permission (evidence: `app/routes_core.py`)
- Record and case routes → Record permissions: checks visibility (evidence: `app/routes_core.py`)
- Record and case routes → Version and verification services: stores version (evidence: `app/routes_core.py`)
- Record and case routes → Application database: reads and writes (evidence: `app/routes_core.py`)
- Version and verification services → Encrypted content vault: stores ciphertext (evidence: `app/services.py`)
- Version and verification services → Forgery screening: extracts text (evidence: `app/services.py`)
- Version and verification services → Signed ledger: records version (evidence: `app/services.py`)
- Version and verification services → Application database: stores metadata (evidence: `app/services.py`)
- Encrypted content vault → IPFS node: stores blobs
- Verification and sharing routes → Signed ledger: checks records (evidence: `app/routes_trust.py`)
- Verification and sharing routes → Tamper-evident activity log: logs activity (evidence: `app/routes_trust.py`)
- Verification and sharing routes → Policy contracts: uses policies (evidence: `app/routes_trust.py`)
- Verification and sharing routes → Application database: reads and writes (evidence: `app/routes_trust.py`)
- Search and assistant routes → Offline proof packages: creates proofs (evidence: `app/routes_extra.py`)
- Search and assistant routes → Selective disclosure: handles disclosure (evidence: `app/routes_extra.py`)
- Search and assistant routes → Concept search: runs search (evidence: `app/routes_extra.py`)
- Search and assistant routes → Forgery screening: runs AI tools (evidence: `app/routes_extra.py`)
- Grounded legal Q&A → Concept search: retrieves passages (evidence: `app/grounded.py`)
- Grounded legal Q&A → Selective disclosure: uses disclosure (evidence: `app/grounded.py`)
- Grounded legal Q&A → Legal language glossary: uses glossary (evidence: `app/grounded.py`)
- Node administration routes → Peer replication and healing: administers peers (evidence: `app/routes_node.py`)
- Node administration routes → Application database: reads state (evidence: `app/routes_node.py`)
- Key management routes → Versioned key ring: rotates keys (evidence: `app/routes_keys.py`)
- External API routes → API keys and webhooks: manages integrations (evidence: `app/routes_interop.py`)
- External API routes → E-filing system: serves filings
- Record and case routes → API keys and webhooks: notifies case events (evidence: `app/routes_core.py`)
- API keys and webhooks → Signed ledger: uses ledger (evidence: `app/interop.py`)
- API keys and webhooks → Application database: reads and writes (evidence: `app/interop.py`)
