# om-suman/cryptovote architecture

> Architecture diagram of the GitHub repository om-suman/cryptovote, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/om-suman/cryptovote
- Repository: https://github.com/om-suman/cryptovote

## Overview

##### Project Type and Purpose
- CryptoVote is a monolithic, server-rendered full-stack web application built with Django (Python).
- Purpose: Provide secure online voting for institutions, with role-based access, real-time results, profile management, and an admin panel.

##### File Structure
- Top-Level:
- manage.py – Django management entry point
- cryptovote/ – Django project settings (asgi.py, wsgi.py, settings.py, urls.py)
- main/ – core “main” app (models, views, urls, admin, migrations, signals, tests)
- templates/ – HTML templates for Django’s server-rendered UI
- static/ & media/ – CSS and user upload storage
- db.sqlite3 – local relational database
- Patterns & Configuration:
- MTV pattern (Model-Template-View)
- Signals used for OTP/email (main/signals.py)
- URL routing in two layers: project-level and app-level
- Admin app for managing elections/users
- render.yml for deployment

##### README for Additional Insights
- Auth: Role-based login (voter vs. admin)
- OTP verification for signup/login
- Features: real-time result updates, profile pics, timezone customization
- Future: Blockchain integration, analytics export

##### Main Components
a. Client Layer
– Web Browser
– Static Assets (CSS under /static)
– Media Assets (profile pictures under /media)
b. Web/Application Layer
– Django Project (“cryptovote”): URL dispatcher, settings, WSGI/ASGI
– Django App (“main”): Views, Templates, Signals, Forms
c. Data Layer
– SQLite database (models.py in main/)
– File storage on local filesystem for media
d. External Services & Future Extensions
– Email/OTP provider (SMTP or external API)
– Potential Blockchain node/API for immutable vote logs

##### Relationships & Interactions
- Browser → Django URL Router → Views
- Views ↔ Models (read/write votes, users, elections)
- Views → Templates → Browser (HTML)
- Views → Signals → Email/OTP service
- Views → Media/Static file handlers
- Admin Panel → Models → Database
- Future: Views/API → Blockchain service

##### Architectural Patterns & Principles
- Django’s MTV pattern: separate concerns into models, templates, and views
- Layered architecture: presentation, application logic, persistence
- Use of signals to decouple OTP/email logic from core view code
- Role-based access control baked into Django auth

##### Technology Stack
- Python 3.8+, Django 3.2+
- SQLite (RDBMS)
- HTML/CSS, Django templating
- SMTP or external Email API for OTP
- Docker/Render (render.yml) or other PaaS for deployment

##### Essential Details to Capture
- URL routing split (project vs. app)
- Authentication & OTP flow
- Real-time result mechanism (could be simple polling vs. WebSocket via ASGI)
- File upload/download endpoints
- Admin management interfaces

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Browser["Web Browser"]:::presentation
        StaticAssets["Static Assets"]:::presentation
        MediaAssets["Media Assets"]:::presentation
        Templates["Templates"]:::presentation
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        Settings["Settings & Config"]:::application
        ASGI["ASGI Entry Point"]:::application
        WSGI["WSGI Entry Point"]:::application
        URLDispatcher["URL Dispatcher"]:::application
        Views["Views & Business Logic"]:::application
        Models["Data Models"]:::application
        Signals["Signals (OTP/Email)"]:::application
        AdminPanel["Admin Panel"]:::application
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["SQLite Database"]:::data
        FileStorage["File Storage"]:::data
    end

    %% External/Future Services
    subgraph "External & Future"
        direction TB
        EmailService["Email/OTP Service"]:::external
        Blockchain["Blockchain Service (Future)"]:::external
    end

    %% Interactions
    Browser -->|"HTTP Request"| ASGI
    Browser -->|"HTTP Request"| WSGI
    ASGI -->|"/"*| URLDispatcher
    WSGI -->|"/"*| URLDispatcher
    URLDispatcher -->|"routes to"| Views
    Views -->|"reads/writes"| Models
    Views -->|"renders via"| Templates
    Templates -->|"HTML Response"| Browser
    Views -->|"triggers"| Signals
    Signals -->|"sends OTP"| EmailService
    Views -->|"serves files"| StaticAssets
    Views -->|"serves files"| MediaAssets
    Views -->|"stores uploads"| FileStorage
    AdminPanel -->|"manages"| Models
    Views -->|"future API calls"| Blockchain

    %% Click Events
    click StaticAssets "https://github.com/om-suman/cryptovote/blob/master/static/style.css"
    click MediaAssets "https://github.com/om-suman/cryptovote/tree/master/media/profile_pics/"
    click Settings "https://github.com/om-suman/cryptovote/blob/master/cryptovote/settings.py"
    click ASGI "https://github.com/om-suman/cryptovote/blob/master/cryptovote/asgi.py"
    click WSGI "https://github.com/om-suman/cryptovote/blob/master/cryptovote/wsgi.py"
    click URLDispatcher "https://github.com/om-suman/cryptovote/blob/master/cryptovote/urls.py"
    click Views "https://github.com/om-suman/cryptovote/blob/master/main/views.py"
    click Models "https://github.com/om-suman/cryptovote/blob/master/main/models.py"
    click Signals "https://github.com/om-suman/cryptovote/blob/master/main/signals.py"
    click AdminPanel "https://github.com/om-suman/cryptovote/blob/master/main/admin.py"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/home.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/login.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/signup.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/verify_otp.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/dashboard.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/profile.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/change_password.html"
    click Templates "https://github.com/om-suman/cryptovote/blob/master/templates/vote.html"
    click Database "https://github.com/om-suman/cryptovote/blob/master/db.sqlite3"
    click FileStorage "https://github.com/om-suman/cryptovote/tree/master/media/profile_pics/"
    click Blockchain "https://github.com/om-suman/cryptovote/blob/master/render.yml"

    %% Styles
    classDef presentation fill:#E0F7FA,stroke:#006064,color:#000;
    classDef application fill:#E8F5E9,stroke:#2E7D32,color:#000;
    classDef data fill:#FFF3E0,stroke:#EF6C00,color:#000;
    classDef external fill:#ECEFF1,stroke:#37474F,color:#000;
```
