# sadiqsh/block_chain_app architecture

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

- Interactive diagram: https://gitdiagram.com/sadiqsh/block_chain_app
- Repository: https://github.com/sadiqsh/block_chain_app

## Overview

#### Purpose and entry points
This is a credential-management system for an educational institution: administrators authenticate, register students, issue certificates, and expose records for student access and public verification. It combines a static browser frontend, a Python backend API, relational persistence, and an Ethereum credential registry.

Primary entry points:
- Backend application: `backend/app/main.py`
- Static user/admin pages: `frontend/index.html`, `frontend/admin.html`, `frontend/student-portal.html`
- Smart-contract project and deployment configuration: `contracts/contracts/CredentialRegistry.sol`, `contracts/ignition/modules/CredentialRegistry.ts`
- Local demo launcher: `start_demo.bat`

#### Backend API composition
The backend is a FastAPI-style application centered on route modules registered from `backend/app/main.py`. Its API surface is separated by business boundary:
- Authentication and admin authorization: `backend/app/routers/auth.py`
- Student registration and retrieval: `backend/app/routers/students.py`
- Certificate/credential issuance, lookup, and verification: `backend/app/routers/credentials.py`

Request and response contracts are defined in `backend/app/schemas.py`; the router layer should be the boundary between browser/API payloads and persistence/blockchain operations.

#### Identity and authorization
Authentication utilities, password hashing, and token-related concerns are isolated from domain routes:
- `backend/app/auth_utils.py`
- `backend/app/hashing.py`
- `backend/app/routers/auth.py`

Administrative workflows in the frontend—login, student registration, record viewing, and certificate issuance—depend on this boundary. Credentials and authorization state should not leak into student-facing or verification flows.

#### Relational domain persistence
Database setup and ORM models form the system of record for operational data:
- `backend/app/database.py`
- `backend/app/models.py`
- `backend/alembic/versions/b48444d5857d_create_initial_tables.py`

Alembic manages schema evolution, including later student roll-number and missing-field changes (`backend/alembic/versions/783a0d4dc5f0_add_student_roll_number.py`, `backend/alembic/versions/6881ea96c81d_add_missing_fields.py`). Routes use this persistence layer for student and credential lifecycle data before or alongside blockchain anchoring.

#### Credential integrity and blockchain boundary
The credential registry contract provides immutable on-chain registration/verification capability:
- `contracts/contracts/CredentialRegistry.sol`
- `contracts/ignition/modules/CredentialRegistry.ts`
- `contracts/hardhat.config.ts`

Backend blockchain integration is isolated in `backend/app/blockchain.py`, while deterministic credential/hash handling is in `backend/app/hashing.py`. The key control flow is: credential data is issued through the API, persisted in the database, hashed/anchored through the registry integration, then later checked through verification endpoints. Contract deployment and tests run in the Node/Hardhat runtime; API integration runs in Python.

#### Browser application flows
The frontend is a multi-page static application using page-specific JavaScript rather than a SPA framework:
- Admin access: `frontend/admin.html`, `frontend/admin-login.js`
- Student registration: `frontend/regi-student.html`, `frontend/register-student.js`
- Certificate issuance: `frontend/issue-certificate.html`, `frontend/issue-certificate.js`
- Student records/portal: `frontend/student-portal.html`, `frontend/student-portal.js`
- Public verification: `frontend/verification.html`, `frontend/verification.js`

Shared browser-side API or utility behavior is likely centralized in `frontend/utils.js`. Frontend code is an API consumer; it should not directly own database or contract state.

#### Runtime and infrastructure boundaries
Python backend dependencies are declared in `backend/requirements.txt`; configuration is centralized in `backend/app/config.py`. Database migration execution is configured by `backend/alembic.ini` and `backend/alembic/env.py`. The blockchain subsystem uses Node.js, TypeScript, Hardhat, and Ignition (`contracts/package.json`, `contracts/tsconfig.json`). Uploaded static assets are stored under `backend/static/uploads`, making file storage a backend-managed concern rather than a frontend concern.

Main entry points: [`backend/app/routers/credentials.py`](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/credentials.py) (Credential routes), [`backend/app/main.py`](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/main.py) (FastAPI application), [`backend/app/routers/students.py`](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/students.py) (Student routes), [`frontend/utils.js`](https://github.com/sadiqsh/block_chain_app/blob/master/frontend/utils.js) (Browser API utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Static browser app"]
  node_admin_ui["Admin workflows<br/>static pages<br/>[admin.html]"]
  node_student_ui["Student portal<br/>static page"]
  node_verify_ui["Public verification<br/>static page<br/>[verification.html]"]
  node_browser_utils["Browser API utilities<br/>JavaScript<br/>[utils.js]"]
end

subgraph group_api["Python API"]
  node_api_app["FastAPI application<br/>Python entry point<br/>[main.py]"]
  node_auth_routes["Auth and admin routes<br/>router<br/>[auth.py]"]
  node_student_routes["Student routes<br/>router<br/>[students.py]"]
  node_credential_routes["Credential routes<br/>router<br/>[credentials.py]"]
  node_api_schemas["API contracts<br/>schemas<br/>[schemas.py]"]
  node_identity["Identity and hashing<br/>auth utilities<br/>[auth_utils.py]"]
  node_blockchain_adapter["Blockchain integration<br/>Python adapter<br/>[blockchain.py]"]
end

subgraph group_data["Persistence"]
  node_orm_models["Domain models<br/>ORM models<br/>[models.py]"]
  node_database[("Relational database<br/>operational system of record<br/>[database.py]")]
  node_migrations["Schema migrations<br/>Alembic"]
  node_uploads["Uploaded assets<br/>backend file storage"]
end

subgraph group_chain["Blockchain runtime"]
  node_registry_contract{{"Credential registry<br/>Ethereum smart contract"}}
  node_deployment["Contract deployment<br/>Hardhat Ignition"]
end

node_admin_ui -->|"uses"| node_browser_utils
node_student_ui -->|"uses"| node_browser_utils
node_verify_ui -->|"uses"| node_browser_utils
node_browser_utils -->|"API requests"| node_api_app
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_student_routes
node_api_app -->|"registers"| node_credential_routes
node_auth_routes -->|"validates"| node_api_schemas
node_student_routes -->|"validates"| node_api_schemas
node_credential_routes -->|"validates"| node_api_schemas
node_auth_routes -->|"authenticates"| node_identity
node_student_routes -->|"manages students"| node_orm_models
node_credential_routes -->|"persists credentials"| node_orm_models
node_credential_routes -->|"hashes credential data"| node_identity
node_orm_models -->|"stores operational data"| node_database
node_migrations -->|"evolves schema"| node_database
node_credential_routes -->|"anchors and checks"| node_blockchain_adapter
node_blockchain_adapter -->|"calls"| node_registry_contract
node_deployment -->|"deploys"| node_registry_contract
node_student_routes -->|"manages files"| node_uploads

click node_admin_ui "https://github.com/sadiqsh/block_chain_app/blob/master/frontend/admin.html"
click node_student_ui "https://github.com/sadiqsh/block_chain_app/blob/master/frontend/student-portal.html"
click node_verify_ui "https://github.com/sadiqsh/block_chain_app/blob/master/frontend/verification.html"
click node_browser_utils "https://github.com/sadiqsh/block_chain_app/blob/master/frontend/utils.js"
click node_api_app "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/main.py"
click node_auth_routes "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/auth.py"
click node_student_routes "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/students.py"
click node_credential_routes "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/credentials.py"
click node_api_schemas "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/schemas.py"
click node_identity "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/auth_utils.py"
click node_blockchain_adapter "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/blockchain.py"
click node_orm_models "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/models.py"
click node_database "https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/database.py"
click node_migrations "https://github.com/sadiqsh/block_chain_app/blob/master/backend/alembic/versions/b48444d5857d_create_initial_tables.py"
click node_uploads "https://github.com/sadiqsh/block_chain_app/tree/master/backend/static/uploads"
click node_registry_contract "https://github.com/sadiqsh/block_chain_app/blob/master/contracts/contracts/CredentialRegistry.sol"
click node_deployment "https://github.com/sadiqsh/block_chain_app/blob/master/contracts/ignition/modules/CredentialRegistry.ts"

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_admin_ui,node_student_ui,node_verify_ui,node_browser_utils toneBlue
class node_api_app,node_auth_routes,node_student_routes,node_credential_routes,node_api_schemas,node_identity,node_blockchain_adapter toneAmber
class node_orm_models,node_database,node_migrations,node_uploads toneMint
class node_registry_contract,node_deployment toneRose
```

## Components

### Static browser app

- [Admin workflows](https://github.com/sadiqsh/block_chain_app/blob/master/frontend/admin.html): static pages · Login, registration, records, and issuance pages. · `frontend/admin.html`
- [Student portal](https://github.com/sadiqsh/block_chain_app/blob/master/frontend/student-portal.html): static page · `frontend/student-portal.html`
- [Public verification](https://github.com/sadiqsh/block_chain_app/blob/master/frontend/verification.html): static page · `frontend/verification.html`
- [Browser API utilities](https://github.com/sadiqsh/block_chain_app/blob/master/frontend/utils.js): JavaScript · `frontend/utils.js`

### Python API

- [FastAPI application](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/main.py): Python entry point · Registers the route modules. · `backend/app/main.py`
- [Auth and admin routes](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/auth.py): router · `backend/app/routers/auth.py`
- [Student routes](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/students.py): router · `backend/app/routers/students.py`
- [Credential routes](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/routers/credentials.py): router · Issues, looks up, and verifies credentials. · `backend/app/routers/credentials.py`
- [API contracts](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/schemas.py): schemas · `backend/app/schemas.py`
- [Identity and hashing](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/auth_utils.py): auth utilities · Password, token, and deterministic credential hash handling. · `backend/app/auth_utils.py`
- [Blockchain integration](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/blockchain.py): Python adapter · `backend/app/blockchain.py`

### Persistence

- [Domain models](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/models.py): ORM models · `backend/app/models.py`
- [Relational database](https://github.com/sadiqsh/block_chain_app/blob/master/backend/app/database.py): operational system of record · `backend/app/database.py`
- [Schema migrations](https://github.com/sadiqsh/block_chain_app/blob/master/backend/alembic/versions/b48444d5857d_create_initial_tables.py): Alembic · `backend/alembic/versions/b48444d5857d_create_initial_tables.py`
- [Uploaded assets](https://github.com/sadiqsh/block_chain_app/tree/master/backend/static/uploads): backend file storage · `backend/static/uploads`

### Blockchain runtime

- [Credential registry](https://github.com/sadiqsh/block_chain_app/blob/master/contracts/contracts/CredentialRegistry.sol): Ethereum smart contract · Immutable credential registration and verification. · `contracts/contracts/CredentialRegistry.sol`
- [Contract deployment](https://github.com/sadiqsh/block_chain_app/blob/master/contracts/ignition/modules/CredentialRegistry.ts): Hardhat Ignition · `contracts/ignition/modules/CredentialRegistry.ts`

## Connections

- Admin workflows → Browser API utilities: uses
- Student portal → Browser API utilities: uses
- Public verification → Browser API utilities: uses
- Browser API utilities → FastAPI application: API requests
- FastAPI application → Auth and admin routes: registers
- FastAPI application → Student routes: registers
- FastAPI application → Credential routes: registers
- Auth and admin routes → API contracts: validates
- Student routes → API contracts: validates
- Credential routes → API contracts: validates
- Auth and admin routes → Identity and hashing: authenticates
- Student routes → Domain models: manages students
- Credential routes → Domain models: persists credentials
- Credential routes → Identity and hashing: hashes credential data
- Domain models → Relational database: stores operational data
- Schema migrations → Relational database: evolves schema
- Credential routes → Blockchain integration: anchors and checks
- Blockchain integration → Credential registry: calls
- Contract deployment → Credential registry: deploys
- Student routes → Uploaded assets: manages files
