# chretien527/rwanda-drive architecture

> Architecture diagram of the GitHub repository chretien527/rwanda-drive, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chretien527/rwanda-drive
- Repository: https://github.com/chretien527/rwanda-drive

## Overview

Rwanda Drive is a digital driving-credentials platform: drivers and officers use a web application backed by a Go HTTP API and MongoDB. The user-facing flow includes account registration and email verification, then role-specific dashboard use for managing credentials and vehicles or checking credentials at a checkpoint. The repository also contains blockchain anchoring and a standalone zero-knowledge proof toolchain. The README documents the service boundaries; source evidence is partial, so internal API routing and some backend relationships are not inferred.

Main entry points: [`src/app/(main)/dashboard/page.tsx`](https://github.com/chretien527/rwanda-drive/blob/main/src/app/(main)/dashboard/page.tsx) (Role dashboard), [`backend/internal/chain/service.go`](https://github.com/chretien527/rwanda-drive/blob/main/backend/internal/chain/service.go) (Credential chain service), [`zk/cmd/zkcli/main.go`](https://github.com/chretien527/rwanda-drive/blob/main/zk/cmd/zkcli/main.go) (Proof CLI), [`src/components/DriverDashboard.tsx`](https://github.com/chretien527/rwanda-drive/blob/main/src/components/DriverDashboard.tsx) (Driver credentials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_site["Public information site<br/>[page.tsx]"]
  node_site_sections["Site content sections"]
  node_api_client["API client<br/>[api.ts]"]
  node_dashboard["Role dashboard<br/>[page.tsx]"]
  node_driver_dashboard["Driver credentials"]
  node_wallet["Digital wallet<br/>[DigitalWallet.tsx]"]
  node_officer_dashboard["Officer verification"]
  node_qr["QR credential display<br/>[QrModal.tsx]"]
  node_demo_data["Demo credential data<br/>[mockData.ts]"]
end

subgraph group_identity["Identity"]
  node_registration["Registration and verification<br/>[page.tsx]"]
  node_login["Login<br/>[page.tsx]"]
  node_auth["Authentication services"]
end

subgraph group_api["Backend API"]
  node_api_service["Go HTTP API<br/>[main.go]"]
  node_vehicles["Vehicle services"]
  node_mongo[("MongoDB<br/>[mongo.go]")]
end

subgraph group_chain["Blockchain credentials"]
  node_chain_service["Credential chain service<br/>[service.go]"]
  node_chain_client["Chain RPC client<br/>[client.go]"]
  node_contract_bindings["Contract bindings"]
end

subgraph group_zk["Zero-knowledge proofs"]
  node_zk_cli["Proof CLI<br/>[main.go]"]
  node_zk_setup["Proof setup<br/>[setup.go]"]
  node_zk_prover["Proof generation<br/>[prover.go]"]
  node_zk_circuit["License proof circuit<br/>[circuit.go]"]
  node_merkle["Merkle gadget<br/>[merkle.go]"]
  node_zk_verifier["Proof verification<br/>[verifier.go]"]
end

node_driver(("Driver"))
node_officer(("Officer"))
node_go_api_external["Go API service"]

node_driver -->|"views information"| node_site
node_officer -->|"views information"| node_site
node_site -->|"renders sections"| node_site_sections
node_driver -.->|"registers"| node_registration
node_officer -.->|"registers"| node_registration
node_registration -->|"calls"| node_api_client
node_driver -.->|"signs in"| node_login
node_officer -.->|"signs in"| node_login
node_login -->|"calls"| node_api_client
node_api_client -->|"sends HTTP requests"| node_go_api_external
node_go_api_external -.->|"is implemented by"| node_api_service
node_dashboard -->|"renders"| node_driver_dashboard
node_dashboard -->|"renders"| node_officer_dashboard
node_dashboard -->|"renders"| node_qr
node_driver_dashboard -->|"uses"| node_wallet
node_driver_dashboard -->|"reads"| node_demo_data
node_officer_dashboard -->|"reads"| node_demo_data
node_qr -->|"reads"| node_demo_data
node_api_service -.->|"uses database integration"| node_mongo
node_chain_service -->|"creates and calls"| node_chain_client
node_chain_service -->|"reads and writes"| node_mongo
node_chain_service -->|"uses bindings"| node_contract_bindings
node_zk_cli -->|"runs setup"| node_zk_setup
node_zk_cli -->|"generates proofs"| node_zk_prover
node_zk_cli -->|"verifies and exports"| node_zk_verifier
node_zk_setup -->|"sets up"| node_zk_circuit
node_zk_prover -->|"builds witness for"| node_zk_circuit
node_zk_prover -->|"uses path structure"| node_merkle
node_zk_circuit -->|"uses gadget"| node_merkle

click node_site "https://github.com/chretien527/rwanda-drive/blob/main/src/app/page.tsx"
click node_site_sections "https://github.com/chretien527/rwanda-drive/tree/main/src/app/(site)"
click node_registration "https://github.com/chretien527/rwanda-drive/blob/main/src/app/(auth)/register/page.tsx"
click node_login "https://github.com/chretien527/rwanda-drive/blob/main/src/app/(auth)/login/page.tsx"
click node_api_client "https://github.com/chretien527/rwanda-drive/blob/main/src/lib/api.ts"
click node_dashboard "https://github.com/chretien527/rwanda-drive/blob/main/src/app/(main)/dashboard/page.tsx"
click node_driver_dashboard "https://github.com/chretien527/rwanda-drive/blob/main/src/components/DriverDashboard.tsx"
click node_wallet "https://github.com/chretien527/rwanda-drive/blob/main/src/components/DigitalWallet.tsx"
click node_officer_dashboard "https://github.com/chretien527/rwanda-drive/blob/main/src/components/PoliceDashboard.tsx"
click node_qr "https://github.com/chretien527/rwanda-drive/blob/main/src/components/QrModal.tsx"
click node_demo_data "https://github.com/chretien527/rwanda-drive/blob/main/src/lib/mockData.ts"
click node_api_service "https://github.com/chretien527/rwanda-drive/blob/main/backend/cmd/api/main.go"
click node_auth "https://github.com/chretien527/rwanda-drive/tree/main/backend/internal/auth"
click node_vehicles "https://github.com/chretien527/rwanda-drive/tree/main/backend/internal/vehicle"
click node_mongo "https://github.com/chretien527/rwanda-drive/blob/main/backend/pkg/database/mongo.go"
click node_chain_service "https://github.com/chretien527/rwanda-drive/blob/main/backend/internal/chain/service.go"
click node_chain_client "https://github.com/chretien527/rwanda-drive/blob/main/backend/internal/chain/client.go"
click node_contract_bindings "https://github.com/chretien527/rwanda-drive/tree/main/backend/pkg/bindings"
click node_zk_cli "https://github.com/chretien527/rwanda-drive/blob/main/zk/cmd/zkcli/main.go"
click node_zk_setup "https://github.com/chretien527/rwanda-drive/blob/main/zk/setup/setup.go"
click node_zk_prover "https://github.com/chretien527/rwanda-drive/blob/main/zk/prover/prover.go"
click node_zk_circuit "https://github.com/chretien527/rwanda-drive/blob/main/zk/circuits/licenseproof/circuit.go"
click node_merkle "https://github.com/chretien527/rwanda-drive/blob/main/zk/gadgets/merkle/merkle.go"
click node_zk_verifier "https://github.com/chretien527/rwanda-drive/blob/main/zk/verifier/verifier.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_site,node_site_sections,node_api_client,node_dashboard,node_driver_dashboard,node_wallet,node_officer_dashboard,node_qr,node_demo_data toneBlue
class node_registration,node_login,node_auth toneAmber
class node_api_service,node_vehicles,node_mongo,node_go_api_external toneMint
class node_chain_service,node_chain_client,node_contract_bindings toneRose
class node_zk_cli,node_zk_setup,node_zk_prover,node_zk_circuit,node_merkle,node_zk_verifier,node_driver,node_officer toneIndigo
```

## Components

### Web application

- [Public information site](https://github.com/chretien527/rwanda-drive/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Site content sections](https://github.com/chretien527/rwanda-drive/tree/main/src/app/(site)): `src/app/(site)`
- [API client](https://github.com/chretien527/rwanda-drive/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Role dashboard](https://github.com/chretien527/rwanda-drive/blob/main/src/app/(main)/dashboard/page.tsx): `src/app/(main)/dashboard/page.tsx`
- [Driver credentials](https://github.com/chretien527/rwanda-drive/blob/main/src/components/DriverDashboard.tsx): `src/components/DriverDashboard.tsx`
- [Digital wallet](https://github.com/chretien527/rwanda-drive/blob/main/src/components/DigitalWallet.tsx): `src/components/DigitalWallet.tsx`
- [Officer verification](https://github.com/chretien527/rwanda-drive/blob/main/src/components/PoliceDashboard.tsx): `src/components/PoliceDashboard.tsx`
- [QR credential display](https://github.com/chretien527/rwanda-drive/blob/main/src/components/QrModal.tsx): `src/components/QrModal.tsx`
- [Demo credential data](https://github.com/chretien527/rwanda-drive/blob/main/src/lib/mockData.ts): `src/lib/mockData.ts`

### Identity

- [Registration and verification](https://github.com/chretien527/rwanda-drive/blob/main/src/app/(auth)/register/page.tsx): `src/app/(auth)/register/page.tsx`
- [Login](https://github.com/chretien527/rwanda-drive/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Authentication services](https://github.com/chretien527/rwanda-drive/tree/main/backend/internal/auth): `backend/internal/auth`

### Backend API

- [Go HTTP API](https://github.com/chretien527/rwanda-drive/blob/main/backend/cmd/api/main.go): `backend/cmd/api/main.go`
- [Vehicle services](https://github.com/chretien527/rwanda-drive/tree/main/backend/internal/vehicle): `backend/internal/vehicle`
- [MongoDB](https://github.com/chretien527/rwanda-drive/blob/main/backend/pkg/database/mongo.go): `backend/pkg/database/mongo.go`

### Blockchain credentials

- [Credential chain service](https://github.com/chretien527/rwanda-drive/blob/main/backend/internal/chain/service.go): `backend/internal/chain/service.go`
- [Chain RPC client](https://github.com/chretien527/rwanda-drive/blob/main/backend/internal/chain/client.go): `backend/internal/chain/client.go`
- [Contract bindings](https://github.com/chretien527/rwanda-drive/tree/main/backend/pkg/bindings): `backend/pkg/bindings`

### Zero-knowledge proofs

- [Proof CLI](https://github.com/chretien527/rwanda-drive/blob/main/zk/cmd/zkcli/main.go): `zk/cmd/zkcli/main.go`
- [Proof setup](https://github.com/chretien527/rwanda-drive/blob/main/zk/setup/setup.go): `zk/setup/setup.go`
- [Proof generation](https://github.com/chretien527/rwanda-drive/blob/main/zk/prover/prover.go): `zk/prover/prover.go`
- [License proof circuit](https://github.com/chretien527/rwanda-drive/blob/main/zk/circuits/licenseproof/circuit.go): `zk/circuits/licenseproof/circuit.go`
- [Merkle gadget](https://github.com/chretien527/rwanda-drive/blob/main/zk/gadgets/merkle/merkle.go): `zk/gadgets/merkle/merkle.go`
- [Proof verification](https://github.com/chretien527/rwanda-drive/blob/main/zk/verifier/verifier.go): `zk/verifier/verifier.go`

### Other components

- **Driver**
- **Officer**
- **Go API service**

## Connections

- Driver → Public information site: views information (evidence: `src/app/page.tsx`)
- Officer → Public information site: views information (evidence: `src/app/page.tsx`)
- Public information site → Site content sections: renders sections (evidence: `src/app/page.tsx`)
- Driver → Registration and verification: registers
- Officer → Registration and verification: registers
- Registration and verification → API client: calls (evidence: `src/app/(auth)/register/page.tsx`)
- Driver → Login: signs in
- Officer → Login: signs in
- Login → API client: calls (evidence: `src/app/(auth)/login/page.tsx`)
- API client → Go API service: sends HTTP requests (evidence: `src/lib/api.ts`)
- Go API service → Go HTTP API: is implemented by (evidence: `README.md`)
- Role dashboard → Driver credentials: renders (evidence: `src/app/(main)/dashboard/page.tsx`)
- Role dashboard → Officer verification: renders (evidence: `src/app/(main)/dashboard/page.tsx`)
- Role dashboard → QR credential display: renders (evidence: `src/app/(main)/dashboard/page.tsx`)
- Driver credentials → Digital wallet: uses (evidence: `src/components/DriverDashboard.tsx`)
- Driver credentials → Demo credential data: reads (evidence: `src/components/DriverDashboard.tsx`)
- Officer verification → Demo credential data: reads (evidence: `src/components/PoliceDashboard.tsx`)
- QR credential display → Demo credential data: reads (evidence: `src/components/QrModal.tsx`)
- Go HTTP API → MongoDB: uses database integration (evidence: `README.md`)
- Credential chain service → Chain RPC client: creates and calls (evidence: `backend/internal/chain/service.go`)
- Credential chain service → MongoDB: reads and writes (evidence: `backend/internal/chain/service.go`)
- Credential chain service → Contract bindings: uses bindings (evidence: `backend/internal/chain/service.go`)
- Proof CLI → Proof setup: runs setup (evidence: `zk/cmd/zkcli/main.go`)
- Proof CLI → Proof generation: generates proofs (evidence: `zk/cmd/zkcli/main.go`)
- Proof CLI → Proof verification: verifies and exports (evidence: `zk/cmd/zkcli/main.go`)
- Proof setup → License proof circuit: sets up (evidence: `zk/setup/setup.go`)
- Proof generation → License proof circuit: builds witness for (evidence: `zk/prover/prover.go`)
- Proof generation → Merkle gadget: uses path structure (evidence: `zk/prover/prover.go`)
- License proof circuit → Merkle gadget: uses gadget (evidence: `zk/circuits/licenseproof/circuit.go`)
