The voting system now uses three separate Excel files for better organization and data management.
Purpose: Store voter registration information
Columns:
VoterID- Unique voter identification (e.g., V001, V002)Name- Full name of the voterDOB- Date of birth (YYYY-MM-DD format)Email- Email addressPhone- Phone numberAddress- Physical addressHasVoted- Boolean (True/False) indicating if voter has cast their vote
Usage:
- Used for voter authentication during login
- Updated when voter casts a vote (HasVoted = True)
- Read by:
auth_service.py,excel_manager.py
Purpose: Store detailed records of all votes cast
Columns:
VoterID- ID of the voter who cast the voteVoterName- Name of the voterCandidateVoted- Name of the candidate voted forTimestamp- Date and time when vote was castIPAddress- IP address from which vote was submittedGeolocationCity- City location (can be enhanced)GeolocationCountry- Country location (can be enhanced)VotedStatus- Always True (indicates vote was successfully cast)KYCImageHash- Hash of the KYC image for verificationBlockHash- Blockchain hash for tamper evidenceVoteHash- Hash of the vote for verification
Usage:
- New record added each time a vote is cast
- Provides complete audit trail
- Can be used for analysis and reporting
- Updated by:
excel_manager.add_vote_record()
Purpose: Store candidate information and vote counts
Columns:
CandidateID- Unique candidate ID (e.g., C001, C002)CandidateName- Name shown to voters (e.g., Candidate A, Candidate B)PoliticalParty- Political party affiliationPartySymbol- Symbol/emoji for the partyVoteCount- Running count of votes received (starts at 0)Slogan- Campaign slogan
Usage:
- Loaded dynamically in the voting page
- Vote count incremented when vote is cast
- Used for displaying results
- Read/Updated by:
excel_manager.py
- User enters credentials
- System checks
voter_registry.xlsx - If valid, session created
- User takes KYC photo
- System loads candidates from
candidates.xlsx - User selects candidate and submits
- System:
- Updates
HasVotedinvoter_registry.xlsx - Adds record to
vote_records.xlsx - Increments
VoteCountincandidates.xlsx - Creates blockchain entry
- Updates
load_voter_registry()
- Loads voter_registry.xlsx
- Initializes voter database
load_candidates()
- Loads candidates.xlsx
- Returns candidate information
get_candidates()
- Returns list of all candidates
- Used by API endpoint
load_vote_records()
- Loads existing vote records
- Creates file if doesn't exist
add_vote_record(voter_id, voter_name, candidate_voted, ...)
- Adds new vote to vote_records.xlsx
- Includes all voting metadata
mark_voter_as_voted(voter_id)
- Updates HasVoted to True in voter_registry.xlsx
- Prevents duplicate voting
update_candidate_vote_count(candidate_name)
- Increments VoteCount in candidates.xlsx
- Tracks election results
-
Run the setup script:
python create_excel_files.py
-
This creates:
- ✅ voter_registry.xlsx (5 sample voters)
- ✅ vote_records.xlsx (empty, will be populated)
- ✅ candidates.xlsx (3 sample candidates)
-
Start the Flask server:
python app.py
-
The system will automatically:
- Load all three Excel files
- Display candidates dynamically
- Track all votes in real-time
- Separation of Concerns: Each file has a specific purpose
- Better Organization: Easy to understand and maintain
- Audit Trail: Complete record of all transactions
- Real-time Results: Vote counts updated automatically
- Scalability: Easy to add more voters or candidates
- Data Integrity: Multiple backups of voting data
- Always close Excel files before running the application
- Files are updated with retry logic to handle locks
- Vote is recorded in blockchain even if Excel update fails
- All three files work together to maintain data consistency
Sample Voter:
- Voter ID: V001
- DOB: 1990-01-15
- Email: john.doe@example.com
Candidates:
- Candidate A (Democratic Party)
- Candidate B (Republican Party)
- Candidate C (Independent)