Overview
The domain model represents the core business concepts of the e-voting system. All entities are implemented as TypeScript classes with encapsulated state and business logic.Entity Relationships
VoteConfirmation records prove a voter participated without revealing their choices.
Core Entities
Voter
Location:src/domain/entities/Voter.ts
Purpose: Represents a registered user who can cast votes
Key Attributes:
PENDING- Awaiting admin approvalAPPROVED- Can participate in electionsREJECTED- Registration deniedSUSPENDED- Temporarily blocked
Election
Location:src/domain/entities/Election.ts
Purpose: Represents a voting event with candidates and configuration
Key Attributes:
FPTP- First Past The Post (single choice)STV- Single Transferable Vote (ranked choice)AV- Alternative Vote (ranked choice, single winner)PREFERENTIAL- Generic preferential voting
Candidate
Location:src/domain/entities/Candidate.ts
Purpose: Represents a person/option on an election ballot
Key Attributes:
Ballot
Location:src/domain/entities/Ballot.ts
Purpose: An anonymous vote record with no voter linkage
Key Attributes:
- Immutable (readonly fields) - ballots cannot be changed after casting
- No voterID field - ensures vote anonymity
preferencesarray supports both single-choice (FPTP) and ranked-choice (STV/AV) voting
VoteConfirmation
Location:src/domain/entities/VoteConfirmation.ts
Purpose: Proves a voter participated in an election without revealing their vote
Key Attributes:
- Prove to voters they successfully voted
- Prevent double voting (one confirmation per voter per election)
- Maintain anonymity - no information about vote choices
Admin
Location:src/domain/entities/Admin.ts
Purpose: System administrator with elevated privileges
Key Attributes:
- Create and manage elections
- Approve/reject voter registrations
- View results and audit logs
- Resolve tied elections
- Configure system settings
Supporting Entities
VoterEligibility
Purpose: Tracks which voters are eligible and have voted in each election Relationship: Junction table between Voter and Election with voting statusElectionEvent
Location:src/domain/entities/ElectionEvent.ts
Purpose: Represents a state change event for Observer pattern
Attributes:
AuditEntry
Purpose: Immutable log record of election state changes Attributes:- Election details
- Status transition
- Timestamp
Enumerations
RegistrationStatus
ElectionStatus
ElectionType
Business Rules
Vote Casting Rules
-
Voter Eligibility:
- Must have
APPROVEDregistration status - Cannot be
SUSPENDED - Implemented in
Voter.canVote():78-89
- Must have
-
Election State:
- Election must be
ACTIVE - Current time must be within
startDateandendDate - Validated in
VotingService.castVote()
- Election must be
-
One Vote Per Election:
- Enforced via
VoterEligibilitytable - Checked before allowing vote submission
- Enforced via
Election Lifecycle Rules
-
Draft State:
- Can add/remove candidates
- Can modify settings
- Cannot accept votes
-
Activation Requirements:
- Must have at least 2 candidates
- Enforced in
ElectionService.activateElection():168-171
-
Closed State:
- Immutable - no further votes
- Results become available
Data Validation
All entities enforce validation through setters:Next Steps
- Design Patterns - How patterns organize domain logic
- Data Layer - How entities are persisted