How ninostephen/egov works
Project type and purpose
• This is a proof-of-concept full-stack web application (“Blockchain based E-Governance”) that demonstrates how a private blockchain can manage everyday governance workflows (user requests, official approvals, admin oversight).
File structure
• Top-level Python scripts:
• app.py – the Flask web server entry point and HTTP routing layer
• blockchain.py, blockCrypto.py – blockchain ledger and cryptographic utilities
• Persistence assets:
• chain/chain.json, chain/backup.json – the JSON-based blockchain ledger
• database.sql – schema for the relational user/role data store
• Key management:
• keys/ – PEM key pairs organized by admin, official, and user roles
• Frontend assets:
• static/ – CSS, JS, images for three role-based sub-directories (admin, official, user)
• templates/ – Jinja2 HTML templates, organized by role (admin, official, user) plus shared includes and layout
README
• Confirms PoC objective: leverage blockchain for e-governance transactions.
Main components and interactions
a. Components
• Web Client (Browser) – renders UI for admin, official, or user roles
• Flask App Server (app.py) – HTTP endpoints, authentication, view rendering
• Blockchain Service (blockchain.py, blockCrypto.py) – block creation/validation, cryptography
• Relational Database (database.sql) – stores user accounts, role data, request metadata
• Blockchain Ledger (chain/chain.json + backup.json) – stores the immutable chain of governance transactions
• Key Store (keys/) – holds private/public key pairs for signing and verification
b. Relationships and data flow
1. Browser sends HTTP(S) requests to Flask controllers
2. Flask routes invoke:
– Database layer for user/role/auth data
– Blockchain Service to record or verify a transaction
3. Blockchain Service
– Uses keys from Key Store to sign new blocks (blockCrypto.py)
– Appends blocks to chain.json, then backs up to backup.json
4. Flask returns HTML pages (via Jinja2 templates) or JSON responses to client
c. Architectural patterns and design principles
– Monolithic MVC style:
• Model: database.sql + JSON chain files
• View: Jinja2 templates in templates/ + static assets
• Controller: Flask app.py routes
– Layered separation: UI layer ↔ service layer (Flask+blockchain) ↔ persistence layers (DB, JSON ledger)
– Role-based access control enforced at controller layer
d. Key technologies and frameworks
– Python & Flask for web server and routing
– Jinja2 templating engine for HTML
– JSON file store as blockchain ledger
– SQL (SQLite/MySQL) for relational data
– Python cryptography for digital signatures
Detail
• Three role flows separately (user applies, official approves, admin oversees)
• Backup path from chain.json to backup.json
• Configuration files (e.g., database.sql) and where they load on startup