# yaasiinaxmed/voting-dapp-solana architecture

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

- Interactive diagram: https://gitdiagram.com/yaasiinaxmed/voting-dapp-solana
- Repository: https://github.com/yaasiinaxmed/voting-dapp-solana

## Overview

##### Project type and purpose
- This is a full-stack blockchain dApp (“legacy-voting-dapp”) comprised of two halves:
a. An on-chain Solana program written in Rust using the Anchor framework (in the `anchor/` directory).
b. A Next.js React web client (in the project root under `src/`) that uses the Anchor‐generated TypeScript client to interact with that program.
- The purpose is to deploy a voting program on Solana and offer a web UI for account management, cluster selection, and voting functionality.

##### File structure
- Top-level directories and files:
- `anchor/` – Anchor project with `programs/voting` (Rust source), migrations, tests, and generated IDL/types in `target/`.
- `src/app/` – Next.js “App Router” folder containing pages and API routes.
- `src/components/` – Organized per domain (account, cluster, votingdapp) into UI/feature/data-access subfolders.
- Config/build files: `package.json`, `pnpm-lock.yaml`, `tsconfig.json`, `next.config.mjs`, Tailwind and PostCSS configs.
- Patterns:
- MVC-like separation in the React client: data-access → feature → UI.
- Next.js App Router conventions (`page.tsx`, `layout.tsx`).
- Anchor’s standard project layout (`migrations/`, `programs/`, `tests/`, `target/idl`, `target/types`).

##### README for additional insights
- Confirms two primary “apps”:
1. **anchor**: build, test, deploy commands for the on-chain program.
2. **web**: `pnpm dev` and `pnpm build` for the React/Next.js front end.
- Specifies required CLIs (Rust, Anchor CLI, Solana CLI) and sync steps for program IDs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Off-chain Web Client" 
        Layout["layout.tsx"]:::frontend
        HomePage["page.tsx (Home)"]:::frontend
        AccountListPage["account/page.tsx"]:::frontend
        AccountDetailPage["account/[address]/page.tsx"]:::frontend
        ClustersPage["clusters/page.tsx"]:::frontend
        VotingPage["votingdapp/page.tsx"]:::frontend
        APIRoute["api/hello/route.ts"]:::backend
        ReactQueryProvider["react-query-provider.tsx"]:::backend
        SolanaProvider["solana-provider.tsx"]:::backend
    end

    subgraph "Anchor TS Client"
        IDL["votingdapp.json"]:::idl
        Types["votingdapp.ts"]:::idl
        ClientExports["anchor/src/index.ts"]:::idl
    end

    subgraph "On-chain Program (Rust/Anchor)"
        Config["Anchor.toml"]:::config
        Program["lib.rs"]:::rust
        Migrations["deploy.ts"]:::scripts
        Tests["votingdapp.spec.ts"]:::tests
    end

    subgraph "Solana Network"
        Solana["Solana Network"]:::network
    end

    subgraph "CI/CD Pipelines"
        CIAnchor["test-anchor.yml"]:::ci
        CIWeb["test-web.yml"]:::ci
    end

    Layout -->|renders| HomePage
    HomePage -->|uses| ReactQueryProvider
    AccountListPage -->|uses| ReactQueryProvider
    AccountDetailPage -->|uses| ReactQueryProvider
    ClustersPage -->|uses| ReactQueryProvider
    VotingPage -->|uses| ReactQueryProvider
    ReactQueryProvider -->|provides data to| SolanaProvider
    SolanaProvider -->|sends RPC via| ClientExports
    ClientExports -->|reads IDL/types from| IDL
    ClientExports -->|reads IDL/types from| Types
    ClientExports -->|invokes| Program
    Program -->|deploys/contracts on| Solana
    Migrations -->|deploys/upgrades| Program
    Tests -->|deploys to localnet on| Solana
    CIAnchor -->|runs build/test| Program
    CIAnchor -->|runs migrations/tests| Tests
    CIWeb -->|runs build/test| Layout
    APIRoute -->|provides API to| ReactQueryProvider

    click Layout "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/layout.tsx"
    click HomePage "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/page.tsx"
    click AccountListPage "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/account/page.tsx"
    click AccountDetailPage "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/account/[address]/page.tsx"
    click ClustersPage "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/clusters/page.tsx"
    click VotingPage "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/votingdapp/page.tsx"
    click APIRoute "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/api/hello/route.ts"
    click ReactQueryProvider "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/app/react-query-provider.tsx"
    click SolanaProvider "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/src/components/solana/solana-provider.tsx"
    click IDL "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/target/idl/votingdapp.json"
    click Types "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/target/types/votingdapp.ts"
    click ClientExports "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/src/index.ts"
    click Config "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/Anchor.toml"
    click Program "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/programs/voting/src/lib.rs"
    click Migrations "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/migrations/deploy.ts"
    click Tests "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/anchor/tests/votingdapp.spec.ts"
    click CIAnchor "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/.github/workflows/test-anchor.yml"
    click CIWeb "https://github.com/yaasiinaxmed/voting-dapp-solana/blob/main/.github/workflows/test-web.yml"

    classDef frontend fill:#D5E8D4,stroke:#82B366
    classDef backend fill:#DAE8FC,stroke:#6C8EBF
    classDef idl fill:#FFF2CC,stroke:#D6B656
    classDef config fill:#E1E1E1,stroke:#A8A8A8
    classDef rust fill:#E6E0F8,stroke:#9673A6
    classDef scripts fill:#F5F5F5,stroke:#AAAAAA
    classDef tests fill:#F8CECC,stroke:#B85450
    classDef network fill:#CCCCCC,stroke:#888888,stroke-dasharray: 5 5
    classDef ci fill:#F8CECC,stroke:#B85450,stroke-width:2px
```
