# arjunjayakrishnan-codes/suraksha-ai architecture

> Architecture diagram of the GitHub repository arjunjayakrishnan-codes/suraksha-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arjunjayakrishnan-codes/suraksha-ai
- Repository: https://github.com/arjunjayakrishnan-codes/suraksha-ai

## Overview

Secure Gig Guardian combines worker/insurer dashboards for income protection with a FastAPI service for identity, policies, claims and payouts. Users authenticate and enter role-protected dashboards; workers can review coverage, claims and payout status, while admins manage workers and claims. The README also describes pricing, risk, telemetry and ledger capabilities. Backend storage and some feature wiring are not shown in the sampled excerpts, so those links are limited to documented behavior or explicit API calls.

Main entry points: [`api_server.py`](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/api_server.py) (FastAPI service), [`src/pages/Index.tsx`](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/Index.tsx) (Protection overview), [`src/hooks/useAuth.tsx`](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/hooks/useAuth.tsx) (Auth and roles), [`src/App.tsx`](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/App.tsx) (Routes and auth provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and dashboards"]
  node_bootstrap["App bootstrap<br/>[main.tsx]"]
  node_app["Routes and auth provider<br/>[App.tsx]"]
  node_authpage["Sign-in and signup<br/>[Auth.tsx]"]
  node_auth["Auth and roles<br/>[useAuth.tsx]"]
  node_workerui["Worker dashboard"]
  node_insurerui["Insurer dashboard"]
end

subgraph group_protection["Worker protection"]
  node_overview["Protection overview<br/>[Index.tsx]"]
  node_pricingui["Dynamic pricing<br/>[DynamicPricing.tsx]"]
  node_riskui["Risk pulse<br/>[RiskPulse.tsx]"]
  node_telemetry["Telemetry insights<br/>[TelemetryCard.tsx]"]
  node_ledger["Micro ledger<br/>[MicroLedger.tsx]"]
  node_policyui["Policy management"]
  node_claimsui["Claims management"]
  node_adminworkers["Worker and claim review"]
end

subgraph group_service["API and domain services"]
  node_apiclient["Authenticated API client<br/>[api-client.ts]"]
  node_api["FastAPI service<br/>[api_server.py]"]
  node_roles["Role authorization<br/>[user_roles.py]"]
  node_policies["Policy service"]
  node_claims["Claims service"]
  node_fraud["Fraud analysis<br/>[fraud_detection.py]"]
  node_advancedfraud["Advanced fraud analysis"]
  node_pricing["Pricing engine<br/>[dynamic_pricing.py]"]
  node_payouts["Instant payout system"]
  node_payments["Payment simulator"]
end

subgraph group_external["External services"]
  node_supabase["Supabase Auth<br/>[client.ts]"]
  node_mongo[("MongoDB or memory store")]
end

node_worker(("Gig worker"))
node_admin(("Insurer admin"))

node_worker -->|"signs in"| node_authpage
node_admin -->|"signs in"| node_authpage
node_bootstrap -->|"fetches config"| node_api
node_bootstrap -->|"renders"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"routes"| node_authpage
node_app -->|"role routes"| node_workerui
node_app -->|"role routes"| node_insurerui
node_authpage -->|"signs up/in"| node_auth
node_auth -.->|"authenticates"| node_supabase
node_auth -->|"fetches profile"| node_api
node_auth -->|"provides session"| node_workerui
node_auth -->|"provides session"| node_insurerui
node_workerui -->|"fetches dashboard data"| node_apiclient
node_insurerui -->|"manages workers"| node_adminworkers
node_overview -->|"renders"| node_riskui
node_overview -->|"renders"| node_pricingui
node_overview -->|"renders"| node_telemetry
node_overview -->|"renders"| node_ledger
node_overview -->|"renders"| node_policyui
node_overview -->|"renders"| node_claimsui
node_policyui -->|"requests policies"| node_apiclient
node_claimsui -->|"requests claims"| node_apiclient
node_adminworkers -->|"reviews workers/claims"| node_apiclient
node_apiclient -->|"sends authenticated requests"| node_api
node_api -->|"checks roles"| node_roles
node_api -->|"calls policy service"| node_policies
node_api -->|"calls claims service"| node_claims
node_api -->|"initiates payouts"| node_payouts
node_api -.->|"persists records"| node_mongo
node_api -->|"uses fraud analysis"| node_fraud
node_api -->|"uses enhanced analysis"| node_advancedfraud
node_api -->|"uses pricing engine"| node_pricing
node_payouts -->|"simulates payment"| node_payments

click node_bootstrap "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/main.tsx"
click node_app "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/App.tsx"
click node_authpage "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/Auth.tsx"
click node_auth "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/hooks/useAuth.tsx"
click node_workerui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/WorkerDashboard.tsx"
click node_insurerui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/InsurerDashboard.tsx"
click node_overview "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/Index.tsx"
click node_pricingui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/DynamicPricing.tsx"
click node_riskui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/RiskPulse.tsx"
click node_telemetry "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/TelemetryCard.tsx"
click node_ledger "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/MicroLedger.tsx"
click node_policyui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/PolicyManagement.tsx"
click node_claimsui "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/ClaimsManagement.tsx"
click node_adminworkers "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/AdminWorkerManagement.tsx"
click node_apiclient "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/lib/api-client.ts"
click node_api "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/api_server.py"
click node_roles "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/user_roles.py"
click node_policies "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/policy_management.py"
click node_claims "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/claims_management.py"
click node_fraud "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/fraud_detection.py"
click node_advancedfraud "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/advanced_fraud_detection.py"
click node_pricing "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/dynamic_pricing.py"
click node_payouts "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/instant_payout_system.py"
click node_payments "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/payment_simulator.py"
click node_supabase "https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/integrations/supabase/client.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_bootstrap,node_app,node_authpage,node_auth,node_workerui,node_insurerui toneBlue
class node_overview,node_pricingui,node_riskui,node_telemetry,node_ledger,node_policyui,node_claimsui,node_adminworkers toneAmber
class node_apiclient,node_api,node_roles,node_policies,node_claims,node_fraud,node_advancedfraud,node_pricing,node_payouts,node_payments toneMint
class node_supabase,node_mongo,node_worker toneRose
class node_admin toneIndigo
```

## Components

### Access and dashboards

- [App bootstrap](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/main.tsx): `src/main.tsx`
- [Routes and auth provider](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and signup](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/Auth.tsx): `src/pages/Auth.tsx`
- [Auth and roles](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/hooks/useAuth.tsx): `src/hooks/useAuth.tsx`
- [Worker dashboard](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/WorkerDashboard.tsx): `src/pages/WorkerDashboard.tsx`
- [Insurer dashboard](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/InsurerDashboard.tsx): `src/pages/InsurerDashboard.tsx`

### Worker protection

- [Protection overview](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [Dynamic pricing](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/DynamicPricing.tsx): `src/components/DynamicPricing.tsx`
- [Risk pulse](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/RiskPulse.tsx): `src/components/RiskPulse.tsx`
- [Telemetry insights](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/TelemetryCard.tsx): `src/components/TelemetryCard.tsx`
- [Micro ledger](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/MicroLedger.tsx): `src/components/MicroLedger.tsx`
- [Policy management](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/PolicyManagement.tsx): `src/components/PolicyManagement.tsx`
- [Claims management](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/ClaimsManagement.tsx): `src/components/ClaimsManagement.tsx`
- [Worker and claim review](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/components/AdminWorkerManagement.tsx): `src/components/AdminWorkerManagement.tsx`

### API and domain services

- [Authenticated API client](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/lib/api-client.ts): `src/lib/api-client.ts`
- [FastAPI service](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/api_server.py): `api_server.py`
- [Role authorization](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/user_roles.py): `user_roles.py`
- [Policy service](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/policy_management.py): `policy_management.py`
- [Claims service](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/claims_management.py): `claims_management.py`
- [Fraud analysis](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/fraud_detection.py): `fraud_detection.py`
- [Advanced fraud analysis](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/advanced_fraud_detection.py): `advanced_fraud_detection.py`
- [Pricing engine](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/dynamic_pricing.py): `dynamic_pricing.py`
- [Instant payout system](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/instant_payout_system.py): `instant_payout_system.py`
- [Payment simulator](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/payment_simulator.py): `payment_simulator.py`

### External services

- [Supabase Auth](https://github.com/arjunjayakrishnan-codes/suraksha-ai/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- **MongoDB or memory store**

### Other components

- **Gig worker**
- **Insurer admin**

## Connections

- Gig worker → Sign-in and signup: signs in
- Insurer admin → Sign-in and signup: signs in
- App bootstrap → FastAPI service: fetches config
- App bootstrap → Routes and auth provider: renders
- Routes and auth provider → Auth and roles: provides auth
- Routes and auth provider → Sign-in and signup: routes
- Routes and auth provider → Worker dashboard: role routes
- Routes and auth provider → Insurer dashboard: role routes
- Sign-in and signup → Auth and roles: signs up/in
- Auth and roles → Supabase Auth: authenticates
- Auth and roles → FastAPI service: fetches profile
- Auth and roles → Worker dashboard: provides session
- Auth and roles → Insurer dashboard: provides session
- Worker dashboard → Authenticated API client: fetches dashboard data
- Insurer dashboard → Worker and claim review: manages workers
- Protection overview → Risk pulse: renders
- Protection overview → Dynamic pricing: renders
- Protection overview → Telemetry insights: renders
- Protection overview → Micro ledger: renders
- Protection overview → Policy management: renders
- Protection overview → Claims management: renders
- Policy management → Authenticated API client: requests policies
- Claims management → Authenticated API client: requests claims
- Worker and claim review → Authenticated API client: reviews workers/claims
- Authenticated API client → FastAPI service: sends authenticated requests
- FastAPI service → Role authorization: checks roles
- FastAPI service → Policy service: calls policy service
- FastAPI service → Claims service: calls claims service
- FastAPI service → Instant payout system: initiates payouts
- FastAPI service → MongoDB or memory store: persists records
- FastAPI service → Fraud analysis: uses fraud analysis
- FastAPI service → Advanced fraud analysis: uses enhanced analysis
- FastAPI service → Pricing engine: uses pricing engine
- Instant payout system → Payment simulator: simulates payment
