# siddharth-varma-raja/clauseguard architecture

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

- Interactive diagram: https://gitdiagram.com/siddharth-varma-raja/clauseguard
- Repository: https://github.com/siddharth-varma-raja/clauseguard

## Overview

ClauseGuard is presented as an Irish lease-review product, but the shown runtime is chiefly an identity/account API plus a small lease-template diff engine. The documented tenant workflow is upload a lease, inspect clause flags and citations, and ask grounded questions; those analysis capabilities are goals in the README, not evidenced end-to-end in the sampled implementation. The graph distinguishes that documented workflow from the implemented auth and diff components. Source excerpts support the API wiring; frontend-to-backend and analysis-pipeline connections are not shown.

Main entry points: [`Development/backend/app/api/v1/endpoints/auth.py`](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/auth.py) (Auth endpoints), [`Development/backend/app/api/v1/endpoints/account.py`](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/account.py) (Account endpoints), [`Development/backend/app/core/firebase.py`](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/core/firebase.py) (Firebase identity), [`Development/backend/app/api/deps.py`](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/deps.py) (User authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Tenant web app"]
  node_web_home["Public interface<br/>[page.tsx]"]
  node_web_auth["Auth forms<br/>[LoginForm.tsx]"]
  node_web_dashboard["Dashboard<br/>[page.tsx]"]
end

subgraph group_api["Identity API"]
  node_api_app["API application<br/>[main.py]"]
  node_api_routes["Versioned routes<br/>[router.py]"]
  node_auth_endpoints["Auth endpoints<br/>[auth.py]"]
  node_account_endpoints["Account endpoints<br/>[account.py]"]
end

subgraph group_identity["Identity and persistence"]
  node_auth_deps["User authorization<br/>[deps.py]"]
  node_firebase["Firebase identity<br/>[firebase.py]"]
  node_user_store[("User and audit records<br/>[user.py]")]
  node_db_session["Database sessions<br/>[database.py]"]
  node_user_schemas["User schemas<br/>[user.py]"]
end

subgraph group_review["Lease review"]
  node_lease_upload["Lease upload and review"]
  node_diff_engine["Template comparison<br/>[diff_engine.py]"]
  node_review_api["Checker API<br/>[api.py]"]
  node_review_output["Flags and explanations<br/>[schemas.py]"]
  node_legal_knowledge["Legal citations and Q&amp;A"]
end

node_tenant(("Tenant"))
node_external_firebase["Firebase service"]

node_tenant -->|"opens"| node_web_home
node_tenant -.->|"signs in"| node_web_auth
node_tenant -.->|"submits lease"| node_lease_upload
node_lease_upload -.->|"returns findings"| node_review_output
node_review_output -.->|"cites guidance"| node_legal_knowledge
node_web_dashboard -.->|"asks grounded questions"| node_legal_knowledge
node_api_app -->|"mounts routes"| node_api_routes
node_api_app -->|"initializes"| node_firebase
node_api_routes -->|"registers"| node_auth_endpoints
node_api_routes -->|"registers"| node_account_endpoints
node_auth_endpoints -->|"requires user"| node_auth_deps
node_account_endpoints -->|"requires user"| node_auth_deps
node_auth_deps -->|"verifies token"| node_firebase
node_auth_deps -->|"queries users"| node_db_session
node_auth_endpoints -->|"manages identity"| node_firebase
node_account_endpoints -->|"revokes sessions"| node_firebase
node_auth_endpoints -->|"reads and writes"| node_db_session
node_account_endpoints -->|"reads and writes"| node_db_session
node_user_store -->|"uses model base"| node_db_session
node_auth_endpoints -->|"validates responses"| node_user_schemas
node_account_endpoints -->|"validates responses"| node_user_schemas
node_firebase -->|"calls"| node_external_firebase
node_review_api -->|"uses comparison"| node_diff_engine
node_review_api -->|"uses schemas"| node_review_output
node_lease_upload -.->|"routes requests"| node_review_api

click node_web_home "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/app/(public)/page.tsx"
click node_web_auth "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/components/auth/LoginForm.tsx"
click node_web_dashboard "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/app/(protected)/dashboard/page.tsx"
click node_api_app "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/main.py"
click node_api_routes "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/router.py"
click node_auth_endpoints "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/auth.py"
click node_account_endpoints "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/account.py"
click node_auth_deps "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/deps.py"
click node_firebase "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/core/firebase.py"
click node_user_store "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/models/user.py"
click node_db_session "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/database.py"
click node_user_schemas "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/schemas/user.py"
click node_lease_upload "https://github.com/siddharth-varma-raja/clauseguard/tree/main/Development/backend/document_checker"
click node_diff_engine "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/diff_engine.py"
click node_review_api "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/api.py"
click node_review_output "https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/schemas.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_home,node_web_auth,node_web_dashboard toneBlue
class node_api_app,node_api_routes,node_auth_endpoints,node_account_endpoints toneAmber
class node_auth_deps,node_firebase,node_user_store,node_db_session,node_user_schemas toneMint
class node_lease_upload,node_diff_engine,node_review_api,node_review_output,node_legal_knowledge toneRose
class node_tenant,node_external_firebase toneIndigo
```

## Components

### Tenant web app

- [Public interface](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/app/(public)/page.tsx): `Development/frontend/app/(public)/page.tsx`
- [Auth forms](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/components/auth/LoginForm.tsx): `Development/frontend/components/auth/LoginForm.tsx`
- [Dashboard](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/frontend/app/(protected)/dashboard/page.tsx): `Development/frontend/app/(protected)/dashboard/page.tsx`

### Identity API

- [API application](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/main.py): `Development/backend/app/main.py`
- [Versioned routes](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/router.py): `Development/backend/app/api/v1/router.py`
- [Auth endpoints](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/auth.py): `Development/backend/app/api/v1/endpoints/auth.py`
- [Account endpoints](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/v1/endpoints/account.py): `Development/backend/app/api/v1/endpoints/account.py`

### Identity and persistence

- [User authorization](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/api/deps.py): `Development/backend/app/api/deps.py`
- [Firebase identity](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/core/firebase.py): `Development/backend/app/core/firebase.py`
- [User and audit records](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/models/user.py): `Development/backend/app/models/user.py`
- [Database sessions](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/database.py): `Development/backend/app/database.py`
- [User schemas](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/app/schemas/user.py): `Development/backend/app/schemas/user.py`

### Lease review

- [Lease upload and review](https://github.com/siddharth-varma-raja/clauseguard/tree/main/Development/backend/document_checker): `Development/backend/document_checker`
- [Template comparison](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/diff_engine.py): `Development/backend/document_checker/diff_engine.py`
- [Checker API](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/api.py): `Development/backend/document_checker/api.py`
- [Flags and explanations](https://github.com/siddharth-varma-raja/clauseguard/blob/main/Development/backend/document_checker/schemas.py): `Development/backend/document_checker/schemas.py`
- **Legal citations and Q&A**

### Other components

- **Tenant**
- **Firebase service**

## Connections

- Tenant → Public interface: opens (evidence: `Development/frontend/app/(public)/page.tsx`)
- Tenant → Auth forms: signs in
- Tenant → Lease upload and review: submits lease
- Lease upload and review → Flags and explanations: returns findings (evidence: `Development/backend/document_checker/api.py`)
- Flags and explanations → Legal citations and Q&A: cites guidance
- Dashboard → Legal citations and Q&A: asks grounded questions
- API application → Versioned routes: mounts routes (evidence: `Development/backend/app/main.py`)
- API application → Firebase identity: initializes (evidence: `Development/backend/app/main.py`)
- Versioned routes → Auth endpoints: registers (evidence: `Development/backend/app/api/v1/router.py`)
- Versioned routes → Account endpoints: registers (evidence: `Development/backend/app/api/v1/router.py`)
- Auth endpoints → User authorization: requires user (evidence: `Development/backend/app/api/v1/endpoints/auth.py`)
- Account endpoints → User authorization: requires user (evidence: `Development/backend/app/api/v1/endpoints/account.py`)
- User authorization → Firebase identity: verifies token (evidence: `Development/backend/app/api/deps.py`)
- User authorization → Database sessions: queries users (evidence: `Development/backend/app/api/deps.py`)
- Auth endpoints → Firebase identity: manages identity (evidence: `Development/backend/app/api/v1/endpoints/auth.py`)
- Account endpoints → Firebase identity: revokes sessions (evidence: `Development/backend/app/api/v1/endpoints/account.py`)
- Auth endpoints → Database sessions: reads and writes (evidence: `Development/backend/app/api/v1/endpoints/auth.py`)
- Account endpoints → Database sessions: reads and writes (evidence: `Development/backend/app/api/v1/endpoints/account.py`)
- User and audit records → Database sessions: uses model base (evidence: `Development/backend/app/models/user.py`)
- Auth endpoints → User schemas: validates responses (evidence: `Development/backend/app/api/v1/endpoints/auth.py`)
- Account endpoints → User schemas: validates responses (evidence: `Development/backend/app/api/v1/endpoints/account.py`)
- Firebase identity → Firebase service: calls (evidence: `Development/backend/app/core/firebase.py`)
- Checker API → Template comparison: uses comparison (evidence: `Development/backend/document_checker/api.py`)
- Checker API → Flags and explanations: uses schemas (evidence: `Development/backend/document_checker/api.py`)
- Lease upload and review → Checker API: routes requests (evidence: `Development/backend/document_checker/api.py`)
