# anisharaz/devote architecture

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

- Interactive diagram: https://gitdiagram.com/anisharaz/devote
- Repository: https://github.com/anisharaz/devote

## Overview

##### Main Components

a) Frontend Layer:
- Next.js Application (apps/votingsystem)
- UI Components (packages/ui)
- Authentication Flows
- Voter Interface
- Admin/Registrar Interface

b) Backend Layer:
- API Routes (/app/api)
- Database Operations
- Identity Management System
- Blockchain Integration

c) External Services:
- Solana Blockchain
- AWS Services
- MailGun Email Service
- Kinde Authentication
- Docker Container
- Prisma Database

##### Overall System Architecture
**[Frontend Layer] ←→ [API Layer] ←→ [Backend Services]**
- ↕               ↕                    ↕
**[User Interface] ←→ [Auth Flow] ←→ [External Services]**

##### Identity System Flow (as shown in README)
- Verification process
- Email verification flow
- Digital certificate generation
- Identity storage mechanism

##### Voting System Flow (as shown in README)
- Token-based voting mechanism
- Blockchain integration
- Vote recording and verification

##### Specific Implementation Details

a) Frontend Structure:
**[Next.js App]**
- ↓
**[Pages/Routes]**
- Home
- Voting
- Registration
- Verification
- ↓
**[Components]**
- UI Elements
- Forms
- Wallet Integration

b) Backend Services:
**[API Routes]**
- ↓
**[Service Layer]**
- Database Operations
- Blockchain Integration
- Email Services
- ↓
**[External Services]**
- Solana
- AWS
- MailGun

##### Key Relationships to Highlight

- User Authentication Flow (Kinde Auth)
- Wallet Connection (Solana)
- Database Interactions (Prisma)
- Email Verification System
- Digital Certificate Management
- Vote Token Management

##### Technical Stack Indicators

- Next.js
- Prisma
- Solana
- Docker
- TypeScript
- TailwindCSS
- Turbo Repo

##### Important Notes

- Clear separation between the identity system and voting system
- Security checkpoints
- Error handling paths
- Scalability points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js Application"]
        UI["UI Components"]
        VoterUI["Voter Interface"]
        AdminUI["Admin/Registrar Interface"]
        WalletBtn["Wallet Button"]
        VerifyUI["Verification Interface"]
    end

    subgraph Backend
        API["API Layer"]
        DB["Database Operations"]
        PrismaLayer["Prisma Database"]
        IdManagement["Identity Management"]
        AuthPipe["Authentication Pipeline"]
        EmailTemp["Email Templates"]
    end

    subgraph ExternalServices
        Solana["Solana Blockchain"]
        AWS["AWS Services"]
        MailGun["MailGun Email"]
        KindeAuth["Kinde Authentication"]
    end

    %% Frontend Relationships
    NextApp --> UI
    NextApp --> VoterUI
    NextApp --> AdminUI
    NextApp --> WalletBtn
    NextApp --> VerifyUI

    %% Backend Relationships
    API --> DB
    DB --> PrismaLayer
    API --> IdManagement
    API --> AuthPipe
    AuthPipe --> EmailTemp

    %% External Service Relationships
    IdManagement --> AWS
    IdManagement --> MailGun
    API --> KindeAuth
    WalletBtn --> Solana

    %% Cross-layer Relationships
    VoterUI --> API
    AdminUI --> API
    VerifyUI --> IdManagement

    %% Styling
    classDef frontend fill:#3498db
    classDef backend fill:#2ecc71
    classDef external fill:#e67e22
    classDef database fill:#9b59b6

    class NextApp,UI,VoterUI,AdminUI,WalletBtn,VerifyUI frontend
    class API,DB,IdManagement,AuthPipe,EmailTemp backend
    class Solana,AWS,MailGun,KindeAuth external
    class PrismaLayer database

    %% Click Events
    click NextApp "https://github.com/anisharaz/devote/tree/main/apps/votingsystem"
    click UI "https://github.com/anisharaz/devote/tree/main/packages/ui"
    click AuthPipe "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/pipes/AuthonticationPipe.tsx"
    click DB "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/actions/database.ts"
    click PrismaLayer "https://github.com/anisharaz/devote/tree/main/packages/prismadb"
    click Solana "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/lib/solana.ts"
    click AWS "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/lib/AWS.ts"
    click MailGun "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/lib/MailGun.ts"
    click AdminUI "https://github.com/anisharaz/devote/tree/main/apps/votingsystem/app/registrar"
    click IdManagement "https://github.com/anisharaz/devote/tree/main/apps/votingsystem/app/voteridentity"
    click VoterUI "https://github.com/anisharaz/devote/tree/main/apps/votingsystem/app/voting"
    click VerifyUI "https://github.com/anisharaz/devote/tree/main/apps/votingsystem/app/verify"
    click WalletBtn "https://github.com/anisharaz/devote/blob/main/apps/votingsystem/app/components/Walletbutton.tsx"
    click EmailTemp "https://github.com/anisharaz/devote/tree/main/apps/votingsystem/app/lib/emails"
```
