How sadiqsh/block_chain_app works
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: credentials.py Credential routes · main.py FastAPI application · students.py Student routes · utils.js Browser API utilities
Components 17
Static browser app
- Admin workflows · Login, registration, records, and issuance pages.
frontend/admin.html - Student portal
frontend/student-portal.html - Public verification
frontend/verification.html - Browser API utilities
frontend/utils.js
Python API
- FastAPI application · Registers the route modules.
backend/app/main.py - Auth and admin routes
backend/app/routers/auth.py - Student routes
backend/app/routers/students.py - Credential routes · Issues, looks up, and verifies credentials.
backend/app/routers/credentials.py - API contracts
backend/app/schemas.py - Identity and hashing · Password, token, and deterministic credential hash handling.
backend/app/auth_utils.py - Blockchain integration
backend/app/blockchain.py
Persistence
- Domain models
backend/app/models.py - Relational database
backend/app/database.py - Schema migrations
backend/alembic/versions/b48444d5857d_create_initial_tables.py - Uploaded assets
backend/static/uploads
Blockchain runtime
- Credential registry · Immutable credential registration and verification.
contracts/contracts/CredentialRegistry.sol - Contract deployment
contracts/ignition/modules/CredentialRegistry.ts
Connections 20
- 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