System Architecture

Backend infrastructure, database schema, edge functions, and security policies

3-Tier Architecture
🖥️

Frontend

React 18 + TypeScript + Vite

• File complaint form

• Police dashboard

• Verification page

• Blockchain visualizer

Client-side (Browser)
⚙️

Backend (Edge Functions)

Deno Runtime (TypeScript)

SHA-256 hashing

Proof-of-Work mining

Chain verification

• Block creation & linking

Server-side
🗄️

Database (PostgreSQL)

Row Level Security (RLS)

• complaints table

• blocks table (blockchain)

• evidence_files table

• user_roles (RBAC)

Persistent Storage
┌─────────────┐ POST /create-block ┌──────────────────┐ │ Frontend │ ──────────────────────────► │ Edge Function │ │ (React UI) │ │ (Deno Server) │ │ │ ◄────────────────────────── │ │ │ │ { blockHash, nonce } │ • SHA-256 hash │ └─────────────┘ │ • Proof-of-Work │ │ • Chain linking │ GET /verify-chain?complaintNumber= └────────┬─────────┘ ──────────────────────────────────► │ ◄─── { chainValid, verificationSteps } ▼ ┌──────────────────┐ │ PostgreSQL DB │ │ • complaints │ │ • blocks │ │ • user_roles │ │ (RLS protected) │ └──────────────────┘