# michaelgichuki/hakiardhi architecture

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

- Interactive diagram: https://gitdiagram.com/michaelgichuki/hakiardhi
- Repository: https://github.com/michaelgichuki/hakiardhi

## Overview

Hakiardhi is a land-registry prototype combining a React portal, a NestJS API, PostgreSQL-backed records, and Hyperledger Fabric chaincode. The user-facing workflow spans parcel lookup and transfer, role-based authentication, and certificate, audit, and tamper views; the backend exposes parcel, command-center, auth, and ledger capabilities. The excerpts show the portal routes and selected API/service calls, but not every page’s data wiring or all controllers. Those capabilities are retained without guessing their internal connections.

Main entry points: [`frontend/src/App.tsx`](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/App.tsx) (Portal routes), [`backend/hakiardhi-api/src/app.module.ts`](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/app.module.ts) (NestJS API), [`backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts`](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts) (Parcel records), [`frontend/src/service/parcels.ts`](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/service/parcels.ts) (Parcel API service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Registry portal"]
  node_portal_app["Portal routes<br/>[App.tsx]"]
  node_portal_shell["Page structure<br/>[PageStructure.tsx]"]
  node_login["Login page<br/>[LoginPage.tsx]"]
  node_parcel_lookup["Parcel lookup<br/>[ParcelPage.tsx]"]
  node_transfer_ui["Transfer workflow<br/>[ParcelTransfer.tsx]"]
  node_workflow_ui["Workflow stages<br/>[WorkflowPage.tsx]"]
  node_landowner_ui["Owner consent<br/>[LandownerPage.tsx]"]
  node_ussd_ui["USSD view<br/>[UssdPage.tsx]"]
  node_tamper_ui["Tamper view<br/>[TamperPage.tsx]"]
  node_certificate_ui["Certificates"]
  node_audit_ui["Audit view<br/>[AuditPage.tsx]"]
  node_dashboard_ui["Dashboard<br/>[Dashboard.tsx]"]
  node_auth_state["Auth state<br/>[authslice.ts]"]
  node_api_client["HTTP client<br/>[axios.ts]"]
  node_auth_api["Auth API service<br/>[auth.ts]"]
  node_parcel_api["Parcel API service<br/>[parcels.ts]"]
end

subgraph group_backend["API domain"]
  node_api_server["NestJS API<br/>[app.module.ts]"]
  node_auth_domain["Authentication<br/>[auth.service.ts]"]
  node_parcel_domain["Parcel records"]
  node_command_center["Command center"]
  node_fabric_adapter["Fabric gateway<br/>[fabric.service.ts]"]
end

subgraph group_storage["Persistence and identity"]
  node_postgres[("PostgreSQL<br/>[prisma.service.ts]")]
end

subgraph group_ledger["Blockchain ledger"]
  node_chaincode["Land contract<br/>[landContract.ts]"]
end

node_land_user(("Registry user"))
node_fabric_network[("Fabric network")]

node_land_user -->|"uses"| node_portal_app
node_portal_app -->|"routes to"| node_login
node_portal_app -->|"routes to"| node_parcel_lookup
node_portal_app -->|"routes to"| node_transfer_ui
node_portal_app -->|"routes to"| node_workflow_ui
node_portal_app -->|"routes to"| node_landowner_ui
node_portal_app -->|"routes to"| node_ussd_ui
node_portal_app -->|"routes to"| node_tamper_ui
node_portal_app -->|"routes to"| node_certificate_ui
node_portal_app -->|"routes to"| node_audit_ui
node_portal_app -->|"routes to"| node_dashboard_ui
node_portal_app -->|"wraps pages"| node_portal_shell
node_parcel_lookup -->|"calls"| node_parcel_api
node_transfer_ui -->|"calls"| node_parcel_api
node_parcel_api -->|"sends requests"| node_api_client
node_auth_state -->|"dispatches"| node_auth_api
node_auth_api -->|"sends requests"| node_api_client
node_api_server -->|"registers module"| node_auth_domain
node_api_server -->|"registers module"| node_parcel_domain
node_api_server -->|"registers module"| node_command_center
node_api_server -->|"registers module"| node_fabric_adapter
node_auth_domain -->|"reads and writes"| node_postgres
node_parcel_domain -->|"reads and writes"| node_postgres
node_parcel_domain -->|"gets user ID"| node_auth_domain
node_parcel_domain -->|"requests title"| node_fabric_adapter
node_fabric_adapter -->|"submits transactions"| node_fabric_network
node_fabric_network -.->|"executes contract"| node_chaincode

click node_portal_app "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/App.tsx"
click node_portal_shell "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Components/PageStructure.tsx"
click node_login "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/LoginPage.tsx"
click node_parcel_lookup "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/ParcelPage.tsx"
click node_transfer_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/ParcelTransfer.tsx"
click node_workflow_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/WorkflowPage.tsx"
click node_landowner_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/LandownerPage.tsx"
click node_ussd_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/UssdPage.tsx"
click node_tamper_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/TamperPage.tsx"
click node_certificate_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/CertificatePage.tsx"
click node_audit_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/AuditPage.tsx"
click node_dashboard_ui "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/Dashboard.tsx"
click node_auth_state "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/app/slice/authslice.ts"
click node_api_client "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/api/axios.ts"
click node_auth_api "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/service/auth.ts"
click node_parcel_api "https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/service/parcels.ts"
click node_api_server "https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/app.module.ts"
click node_auth_domain "https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/auth/auth.service.ts"
click node_parcel_domain "https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts"
click node_command_center "https://github.com/michaelgichuki/hakiardhi/tree/main/backend/hakiardhi-api/src/commandCenter"
click node_fabric_adapter "https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/fabric/fabric.service.ts"
click node_postgres "https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/prisma/prisma.service.ts"
click node_chaincode "https://github.com/michaelgichuki/hakiardhi/blob/main/blockchain/chaincode/src/landContract.ts"

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_portal_app,node_portal_shell,node_login,node_parcel_lookup,node_transfer_ui,node_workflow_ui,node_landowner_ui,node_ussd_ui,node_tamper_ui,node_certificate_ui,node_audit_ui,node_dashboard_ui,node_auth_state,node_api_client,node_auth_api,node_parcel_api,node_land_user toneBlue
class node_api_server,node_auth_domain,node_parcel_domain,node_command_center,node_fabric_adapter,node_fabric_network toneAmber
class node_postgres toneMint
class node_chaincode toneRose
```

## Components

### Registry portal

- [Portal routes](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Page structure](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Components/PageStructure.tsx): `frontend/src/Components/PageStructure.tsx`
- [Login page](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/LoginPage.tsx): `frontend/src/Pages/LoginPage.tsx`
- [Parcel lookup](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/ParcelPage.tsx): `frontend/src/Pages/ParcelPage.tsx`
- [Transfer workflow](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/ParcelTransfer.tsx): `frontend/src/Pages/ParcelTransfer.tsx`
- [Workflow stages](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/WorkflowPage.tsx): `frontend/src/Pages/WorkflowPage.tsx`
- [Owner consent](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/LandownerPage.tsx): `frontend/src/Pages/LandownerPage.tsx`
- [USSD view](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/UssdPage.tsx): `frontend/src/Pages/UssdPage.tsx`
- [Tamper view](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/TamperPage.tsx): `frontend/src/Pages/TamperPage.tsx`
- [Certificates](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/CertificatePage.tsx): `frontend/src/Pages/CertificatePage.tsx`
- [Audit view](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/AuditPage.tsx): `frontend/src/Pages/AuditPage.tsx`
- [Dashboard](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/Pages/Dashboard.tsx): `frontend/src/Pages/Dashboard.tsx`
- [Auth state](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/app/slice/authslice.ts): `frontend/src/app/slice/authslice.ts`
- [HTTP client](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/api/axios.ts): `frontend/src/api/axios.ts`
- [Auth API service](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/service/auth.ts): `frontend/src/service/auth.ts`
- [Parcel API service](https://github.com/michaelgichuki/hakiardhi/blob/main/frontend/src/service/parcels.ts): `frontend/src/service/parcels.ts`

### API domain

- [NestJS API](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/app.module.ts): `backend/hakiardhi-api/src/app.module.ts`
- [Authentication](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/auth/auth.service.ts): `backend/hakiardhi-api/src/auth/auth.service.ts`
- [Parcel records](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts): `backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts`
- [Command center](https://github.com/michaelgichuki/hakiardhi/tree/main/backend/hakiardhi-api/src/commandCenter): `backend/hakiardhi-api/src/commandCenter`
- [Fabric gateway](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/fabric/fabric.service.ts): `backend/hakiardhi-api/src/fabric/fabric.service.ts`

### Persistence and identity

- [PostgreSQL](https://github.com/michaelgichuki/hakiardhi/blob/main/backend/hakiardhi-api/src/prisma/prisma.service.ts): `backend/hakiardhi-api/src/prisma/prisma.service.ts`

### Blockchain ledger

- [Land contract](https://github.com/michaelgichuki/hakiardhi/blob/main/blockchain/chaincode/src/landContract.ts): `blockchain/chaincode/src/landContract.ts`

### Other components

- **Registry user**
- **Fabric network**

## Connections

- Registry user → Portal routes: uses (evidence: `frontend/src/App.tsx`)
- Portal routes → Login page: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Parcel lookup: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Transfer workflow: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Workflow stages: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Owner consent: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → USSD view: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Tamper view: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Certificates: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Audit view: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Portal routes → Page structure: wraps pages (evidence: `frontend/src/App.tsx`)
- Parcel lookup → Parcel API service: calls (evidence: `frontend/src/Pages/ParcelPage.tsx`)
- Transfer workflow → Parcel API service: calls (evidence: `frontend/src/Pages/ParcelTransfer.tsx`)
- Parcel API service → HTTP client: sends requests (evidence: `frontend/src/service/parcels.ts`)
- Auth state → Auth API service: dispatches (evidence: `frontend/src/app/slice/authslice.ts`)
- Auth API service → HTTP client: sends requests (evidence: `frontend/src/service/auth.ts`)
- NestJS API → Authentication: registers module (evidence: `backend/hakiardhi-api/src/app.module.ts`)
- NestJS API → Parcel records: registers module (evidence: `backend/hakiardhi-api/src/app.module.ts`)
- NestJS API → Command center: registers module (evidence: `backend/hakiardhi-api/src/app.module.ts`)
- NestJS API → Fabric gateway: registers module (evidence: `backend/hakiardhi-api/src/app.module.ts`)
- Authentication → PostgreSQL: reads and writes (evidence: `backend/hakiardhi-api/src/auth/auth.service.ts`)
- Parcel records → PostgreSQL: reads and writes (evidence: `backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts`)
- Parcel records → Authentication: gets user ID (evidence: `backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts`)
- Parcel records → Fabric gateway: requests title (evidence: `backend/hakiardhi-api/src/parcelRecords/parcelRecords.service.ts`)
- Fabric gateway → Fabric network: submits transactions (evidence: `backend/hakiardhi-api/src/fabric/fabric.service.ts`)
- Fabric network → Land contract: executes contract
