# himanshukumar8/e-voting-system architecture

> Architecture diagram of the GitHub repository himanshukumar8/e-voting-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/himanshukumar8/e-voting-system
- Repository: https://github.com/himanshukumar8/e-voting-system

## Overview

##### Main Components
- User Interface Components – These are implied by the screenshots:
- Voter Login Page
- Candidate Login & Confirmation Pages
- Admin Login and Administration Pages
- Poll pages (start, current, and previous poll views)
- Application’s Business Logic – This is primarily implemented in vote.cpp and includes:
- Authentication/Authorization mechanism (distinguishing between regular voters, candidates, and admin)
- Voting process logic (casting/voting and poll management)
- Use of OOP techniques (classes for Voter, Candidate, Admin, etc.) that interact via inheritance, polymorphism, and abstract interfaces.
- Data Management/Storage Component – Represented by file handling with the CSV files:
- Candidate.csv, Polls.csv, and Voter.csv, storing and updating representative data.

##### Relationships and Interactions
- The User Interface interacts with the Business Logic to send user inputs such as login credentials, vote selections, and administrative commands.
- The Business Logic uses OOP classes (with inheritance and polymorphism) to manage application state and implements the voting and authentication processes.
- The Data Management component acts as the persistence layer. It reads from and writes to the CSV files to save voter, candidate, and poll data.
- Flows (through the UI) reflect system state changes, particularly in the admin and confirmation screens.

##### Architectural Patterns and Design Principles
- Presentation Layer (UI Screens and User Interaction)
- Business Logic Layer (Core voting and authentication logic implemented via classes)
- Data Persistence Layer (File handling with CSVs)
- Inheritance: Showcase how the Admin may inherit from a User base class, or how the Voter and Candidate classes share common operations.
- Polymorphism: Indicate functions that exhibit overloading and overriding.
- Abstract Classes/Interfaces: Point out any abstract definitions that guide different implementations.
- File Handling Integration – Represent the CSV files as external data stores.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% User Interface Layer
    subgraph "User Interface"
        VoterUI["Voter Login Page"]:::ui
        CandidateUI["Candidate Login & Confirmation Page"]:::ui
        AdminUI["Admin Login & Administration Page"]:::ui
        PollUI["Poll Views (Start, Current, Previous)"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        VoteCPP["vote.cpp (Core Voting Logic)"]:::logic
        Auth["Authentication/Authorization Module"]:::logic
        Voting["Voting Process Handler"]:::logic
        subgraph "OOP Classes"
            VoterClass["Voter (inherits from User)"]:::logic
            CandidateClass["Candidate (inherits from User)"]:::logic
            AdminClass["Admin (inherits from User)"]:::logic
        end
    end

    %% Data Persistence Layer
    subgraph "Data Persistence"
        DataStore["CSV Data Store<br/>(Candidate.csv, Polls.csv, Voter.csv)"]:::data
    end

    %% Connections from UI to Business Logic
    VoterUI -->|"send credentials/vote"| VoteCPP
    CandidateUI -->|"send credentials/vote"| VoteCPP
    AdminUI -->|"send admin commands"| VoteCPP
    PollUI -->|"request poll data"| VoteCPP

    %% Internal Business Logic Flow
    VoteCPP -->|"authenticates"| Auth
    VoteCPP -->|"processes vote"| Voting
    Auth -->|"utilizes OOP"| VoterClass
    Auth -->|"utilizes OOP"| CandidateClass
    Auth -->|"utilizes OOP"| AdminClass

    %% Business Logic to Data Persistence Connections
    VoteCPP -->|"read/write data"| DataStore
    DataStore -->|"data feedback"| VoteCPP

    %% Click Events for Component Mapping
    click VoterUI "https://github.com/himanshukumar8/e-voting-system/tree/main/ScreenShot"
    click CandidateUI "https://github.com/himanshukumar8/e-voting-system/tree/main/ScreenShot"
    click AdminUI "https://github.com/himanshukumar8/e-voting-system/tree/main/ScreenShot"
    click PollUI "https://github.com/himanshukumar8/e-voting-system/tree/main/ScreenShot"
    click VoteCPP "https://github.com/himanshukumar8/e-voting-system/blob/main/vote.cpp"
    click DataStore "https://github.com/himanshukumar8/e-voting-system/tree/main/Data"

    %% Style Classes
    classDef ui fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef logic fill:#ccffcc,stroke:#336600,stroke-width:2px;
    classDef data fill:#fff2cc,stroke:#b38f00,stroke-width:2px;
```
