How ramesh-adhikari/e-voting-system-using-blockchain-and-python works
Main Components
• Frontend Web Application: Represented by “app.py” and the “app” folder containing HTML templates (base.html, index.html) and “views.py” for handling routes and UI logic. This component is responsible for rendering the voting interface and accepting user input (voter ID and selected party).
• Blockchain Node Service: Represented by “service.py” which runs a Flask application that serves as the blockchain node (listening on configurable ports, e.g. 8000, 8001, 8002). This service manages the blockchain ledger, processes new transactions (votes), and handles mining (Proof of Work) and chain synchronization.
• Core Blockchain Logic: Within the blockchain code (class Block, compute_hash method, mining routines, and chain validation), this part encapsulates how blocks are created, chained (through previous_hash), and mined via the nonce to satisfy the hash constraints.
• Network of Nodes: Although it may be started on different ports and even different hosts, conceptually several nodes interact via endpoints such as /register_with and /chain. This forms a distributed network that maintains a synchronized and tamper-proof ledger.
• External References / Documentation: The “reference-paper” folder (with the research paper PDF) supports the design rationale and security choices of the system. While not part of the runtime architecture, it underpins the system’s concepts.
Out Relationships and Interactions
• The blockchain node service receives transactions (typically in JSON format) and queues them. It then initiates the mining process which involves computing hashes and updating the blockchain.
• The design must capture that each node functions independently (and in parallel) but uses a consensus algorithm (Proof of Work) to maintain integrity.
Architectural Patterns and Design Principles
• Separation of Concerns: The system divides responsibilities between the user interface (voting frontend) and the blockchain ledger management (backend service).
• Decentralization: The distributed nature of the nodes (running on different ports) emphasizes decentralization and fault tolerance.
• Immutable Ledger: The blockchain design illustrates immutability; once a block is mined and linked (via previous_hash), it cannot be altered without invalidating the chain.
• Proof of Work: Indicate the “mining” flow where the nonce is incremented until a hash with the required number of leading zeroes is found, ensuring the block’s validity.
Relevant Technologies & Architectural Choices
• Programming Language: Python.
• Framework: Flask (used for both the web frontend and backend service).
• Data Format: JSON (used to store and transmit blockchain transactions).
• Cryptographic Hash: SHA-256 for creating digital fingerprints of blocks.