# jainmokshit1-byte/specid architecture

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

- Interactive diagram: https://gitdiagram.com/jainmokshit1-byte/specid
- Repository: https://github.com/jainmokshit1-byte/specid

## Overview

SpecID is a prototype for governing a shared national material registry: it aims to turn CPSE ERP records into canonical specifications, compare them with explicit verdicts, and issue CNMCs with legacy-code crosswalks. The documented material workflow is present alongside an API and a currently small set of implemented web screens; the route table describes broader registry, review, evaluation, and rulebook screens, many of which render placeholders. The CLI references the decision-engine modules, but the sampled excerpts do not establish a complete runtime material-ingestion pipeline. The graph shows documented stages and evidenced application wiring without claiming that unsampled capabilities are implemented.

Main entry points: [`backend/app/core/decide.py`](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/decide.py) (Verdict decision), [`backend/app/main.py`](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/main.py) (API application), [`backend/app/core/extract.py`](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/extract.py) (Attribute extraction), [`frontend/src/api/client.ts`](https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/api/client.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web routing<br/>[App.tsx]"]
  node_webpages["Product screens"]
  node_webclient["API client<br/>[client.ts]"]
  node_session["Web session<br/>[session.ts]"]
end

subgraph group_api["API and identity"]
  node_apiapp["API application<br/>[main.py]"]
  node_authroutes["Login routes<br/>[auth.py]"]
  node_userflows["User services<br/>[users.py]"]
  node_authsecurity["Token security<br/>[auth.py]"]
  node_auditapi["Audit routes<br/>[audit.py]"]
  node_auditservice["Audit service<br/>[audit.py]"]
end

subgraph group_engine["Specification engine"]
  node_decision["Verdict decision<br/>[decide.py]"]
  node_extraction["Attribute extraction<br/>[extract.py]"]
  node_normalise["Specification normalisation<br/>[normalise.py]"]
  node_templates["Category rule templates<br/>[templates.py]"]
  node_units["Unit conversion<br/>[units.py]"]
  node_sharedtypes["Specification and evidence types<br/>[types.py]"]
  node_cli["Engine CLI<br/>[cli.py]"]
end

subgraph group_state["Persistence and evaluation"]
  node_evaluation["Synthetic evaluation data<br/>[generator.py]"]
  node_database[("Application database<br/>[models.py]")]
  node_dbsession["Database sessions<br/>[session.py]"]
  node_registry[("CNMC registry and crosswalk")]
end

node_cpse(("CPSE ERP user"))

node_cpse -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_webpages
node_webpages -->|"requests data"| node_webclient
node_webclient -->|"reads token"| node_session
node_webclient -->|"sends API requests"| node_apiapp
node_apiapp -->|"registers router"| node_authroutes
node_apiapp -->|"registers router"| node_auditapi
node_authroutes -->|"delegates login"| node_userflows
node_userflows -->|"creates tokens"| node_authsecurity
node_authroutes -->|"gets session"| node_dbsession
node_userflows -->|"reads and updates users"| node_database
node_auditapi -->|"uses audit service"| node_auditservice
node_auditservice -->|"records events"| node_database
node_apiapp -->|"loads templates"| node_templates
node_cpse -->|"provides ERP records"| node_extraction
node_extraction -->|"canonicalises attributes"| node_normalise
node_extraction -->|"uses unit rules"| node_units
node_normalise -->|"prepares specifications"| node_decision
node_decision -->|"applies rules"| node_templates
node_decision -->|"returns verdict and evidence"| node_sharedtypes
node_cli -->|"references engine"| node_decision
node_cli -->|"references engine"| node_extraction
node_decision -->|"issues CNMC"| node_registry
node_registry -.->|"stores registry records"| node_database
node_evaluation -->|"uses unit rules"| node_units

click node_webapp "https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/App.tsx"
click node_webpages "https://github.com/jainmokshit1-byte/specid/tree/main/frontend/src/pages"
click node_webclient "https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/api/client.ts"
click node_session "https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/auth/session.ts"
click node_apiapp "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/main.py"
click node_authroutes "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/api/auth.py"
click node_userflows "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/services/users.py"
click node_authsecurity "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/security/auth.py"
click node_auditapi "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/api/audit.py"
click node_auditservice "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/services/audit.py"
click node_decision "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/decide.py"
click node_extraction "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/extract.py"
click node_normalise "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/normalise.py"
click node_templates "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/templates.py"
click node_units "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/units.py"
click node_sharedtypes "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/types.py"
click node_cli "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/cli.py"
click node_evaluation "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/eval/generator.py"
click node_database "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/db/models.py"
click node_dbsession "https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/db/session.py"
click node_registry "https://github.com/jainmokshit1-byte/specid/tree/main/backend/app/db"

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_webapp,node_webpages,node_webclient,node_session,node_cpse toneBlue
class node_apiapp,node_authroutes,node_userflows,node_authsecurity,node_auditapi,node_auditservice toneAmber
class node_decision,node_extraction,node_normalise,node_templates,node_units,node_sharedtypes,node_cli toneMint
class node_evaluation,node_database,node_dbsession,node_registry toneRose
```

## Components

### Web application

- [Web routing](https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Product screens](https://github.com/jainmokshit1-byte/specid/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Web session](https://github.com/jainmokshit1-byte/specid/blob/main/frontend/src/auth/session.ts): `frontend/src/auth/session.ts`

### API and identity

- [API application](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/main.py): `backend/app/main.py`
- [Login routes](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [User services](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/services/users.py): `backend/app/services/users.py`
- [Token security](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/security/auth.py): `backend/app/security/auth.py`
- [Audit routes](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/api/audit.py): `backend/app/api/audit.py`
- [Audit service](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`

### Specification engine

- [Verdict decision](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/decide.py): `backend/app/core/decide.py`
- [Attribute extraction](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/extract.py): `backend/app/core/extract.py`
- [Specification normalisation](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/normalise.py): `backend/app/core/normalise.py`
- [Category rule templates](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/templates.py): `backend/app/core/templates.py`
- [Unit conversion](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/units.py): `backend/app/core/units.py`
- [Specification and evidence types](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/core/types.py): `backend/app/core/types.py`
- [Engine CLI](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/cli.py): `backend/app/cli.py`

### Persistence and evaluation

- [Synthetic evaluation data](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/eval/generator.py): `backend/app/eval/generator.py`
- [Application database](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/db/models.py): `backend/app/db/models.py`
- [Database sessions](https://github.com/jainmokshit1-byte/specid/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [CNMC registry and crosswalk](https://github.com/jainmokshit1-byte/specid/tree/main/backend/app/db): `backend/app/db`

### Other components

- **CPSE ERP user**

## Connections

- CPSE ERP user → Web routing: uses (evidence: `README.md`)
- Web routing → Product screens: routes to (evidence: `frontend/src/App.tsx`)
- Product screens → API client: requests data (evidence: `frontend/src/pages/Users.tsx`)
- API client → Web session: reads token (evidence: `frontend/src/api/client.ts`)
- API client → API application: sends API requests (evidence: `README.md`)
- API application → Login routes: registers router (evidence: `backend/app/main.py`)
- API application → Audit routes: registers router (evidence: `backend/app/main.py`)
- Login routes → User services: delegates login (evidence: `backend/app/api/auth.py`)
- User services → Token security: creates tokens (evidence: `backend/app/services/users.py`)
- Login routes → Database sessions: gets session (evidence: `backend/app/api/auth.py`)
- User services → Application database: reads and updates users (evidence: `backend/app/services/users.py`)
- Audit routes → Audit service: uses audit service (evidence: `backend/app/api/audit.py`)
- Audit service → Application database: records events (evidence: `backend/app/services/audit.py`)
- API application → Category rule templates: loads templates (evidence: `backend/app/main.py`)
- CPSE ERP user → Attribute extraction: provides ERP records (evidence: `README.md`)
- Attribute extraction → Specification normalisation: canonicalises attributes (evidence: `backend/app/core/extract.py`)
- Attribute extraction → Unit conversion: uses unit rules (evidence: `backend/app/core/extract.py`)
- Specification normalisation → Verdict decision: prepares specifications (evidence: `README.md`)
- Verdict decision → Category rule templates: applies rules (evidence: `backend/app/core/decide.py`)
- Verdict decision → Specification and evidence types: returns verdict and evidence (evidence: `backend/app/core/decide.py`)
- Engine CLI → Verdict decision: references engine (evidence: `backend/app/cli.py`)
- Engine CLI → Attribute extraction: references engine (evidence: `backend/app/cli.py`)
- Verdict decision → CNMC registry and crosswalk: issues CNMC (evidence: `README.md`)
- CNMC registry and crosswalk → Application database: stores registry records
- Synthetic evaluation data → Unit conversion: uses unit rules (evidence: `backend/app/eval/generator.py`)
