# pravinsingh1109/sahakarseva architecture

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

- Interactive diagram: https://gitdiagram.com/pravinsingh1109/sahakarseva
- Repository: https://github.com/pravinsingh1109/sahakarseva

## Overview

SahakarSeva is a cooperative household-services marketplace. Customers discover local workers, book and track a job, then complete payment and review; workers onboard, receive and complete jobs, and view earnings, while administrators oversee workers, tariffs, disputes, and platform activity. The backend owns API routing, matching, cooperative business rules, persistence, and realtime events. The README documents welfare funding, fee collection, and integrations, but sampled excerpts do not establish all of their implementation links; those capabilities are represented without speculative call paths.

Main entry points: [`backend/main.py`](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/main.py) (API entry point), [`backend/core/database.py`](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/database.py) (Relational data), [`backend/routers/worker.py`](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/worker.py) (Worker operations), [`backend/socket/tracking.py`](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/tracking.py) (Live tracking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User applications"]
  node_customer["Customer app"]
  node_worker["Worker app"]
  node_admin["Admin portal<br/>[App.tsx]"]
end

subgraph group_api["API and domain"]
  node_api_entry["API entry point<br/>[main.py]"]
  node_auth_routes["Authentication<br/>[auth.py]"]
  node_catalogue["Service discovery<br/>[services.py]"]
  node_customer_routes["Customer bookings<br/>[customer.py]"]
  node_worker_routes["Worker operations<br/>[worker.py]"]
  node_admin_routes["Cooperative administration<br/>[admin.py]"]
  node_payments["Payments<br/>[payments.py]"]
  node_matching["Fair worker matching<br/>[matching.py]"]
  node_fees["Daily access fees<br/>[access_fee.py]"]
  node_invoices["Fare invoices<br/>[invoice.py]"]
  node_notifications["Notifications<br/>[notifications.py]"]
  node_otp["OTP service<br/>[otp.py]"]
end

subgraph group_realtime["Realtime dispatch"]
  node_tracking["Live tracking<br/>[tracking.py]"]
  node_chat["Realtime chat<br/>[chat.py]"]
  node_socket_server["Socket.IO server<br/>[sio.py]"]
end

subgraph group_platform["Platform foundations"]
  node_database[("Relational data<br/>[database.py]")]
  node_models["Marketplace records<br/>[models.py]"]
  node_redis[("Ephemeral state<br/>[redis.py]")]
  node_security["Token security<br/>[security.py]"]
  node_auth_middleware["Role authorization<br/>[auth.py]"]
end

node_worker_actor(("Worker"))
node_customer_actor(("Customer"))
node_admin_actor(("Administrator"))

node_customer_actor -->|"uses"| node_customer
node_worker_actor -->|"uses"| node_worker
node_admin_actor -->|"uses"| node_admin
node_customer -->|"calls API"| node_api_entry
node_worker -->|"calls API"| node_api_entry
node_admin -->|"calls API"| node_api_entry
node_api_entry -->|"mounts"| node_auth_routes
node_api_entry -->|"mounts"| node_catalogue
node_api_entry -->|"mounts"| node_customer_routes
node_api_entry -->|"mounts"| node_worker_routes
node_api_entry -->|"mounts"| node_admin_routes
node_api_entry -->|"mounts"| node_payments
node_api_entry -->|"wraps"| node_socket_server
node_api_entry -->|"registers"| node_tracking
node_api_entry -->|"registers"| node_chat
node_catalogue -->|"requests matches"| node_matching
node_catalogue -->|"queries"| node_database
node_customer_routes -->|"reads/writes"| node_database
node_customer_routes -->|"uses invoices"| node_invoices
node_customer_routes -->|"uses notifications"| node_notifications
node_customer_routes -->|"uses tracking"| node_tracking
node_worker_routes -->|"reads/writes"| node_database
node_worker_routes -->|"uses fees"| node_fees
node_worker_routes -->|"uses notifications"| node_notifications
node_worker_routes -->|"uses tracking"| node_tracking
node_worker_routes -->|"uses Redis"| node_redis
node_auth_routes -->|"uses OTP"| node_otp
node_auth_routes -->|"uses tokens"| node_security
node_auth_routes -->|"reads/writes"| node_database
node_admin_routes -->|"reads/writes"| node_database
node_admin_routes -->|"uses notifications"| node_notifications
node_payments -.->|"uses database"| node_database
node_matching -->|"queries records"| node_models
node_tracking -->|"stores locations"| node_redis
node_tracking -->|"emits events"| node_socket_server
node_tracking -->|"decodes tokens"| node_security
node_chat -->|"uses server"| node_socket_server
node_auth_middleware -->|"decodes token"| node_security
node_auth_middleware -->|"loads user"| node_database
node_auth_middleware -->|"queries user"| node_models
node_database -.->|"defines records"| node_models

click node_customer "https://github.com/pravinsingh1109/sahakarseva/tree/main/apps/customer/app"
click node_worker "https://github.com/pravinsingh1109/sahakarseva/tree/main/apps/worker/app"
click node_admin "https://github.com/pravinsingh1109/sahakarseva/blob/main/apps/admin/src/App.tsx"
click node_api_entry "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/main.py"
click node_auth_routes "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/auth.py"
click node_catalogue "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/services.py"
click node_customer_routes "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/customer.py"
click node_worker_routes "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/worker.py"
click node_admin_routes "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/admin.py"
click node_payments "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/payments.py"
click node_matching "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/matching.py"
click node_fees "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/access_fee.py"
click node_invoices "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/invoice.py"
click node_notifications "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/notifications.py"
click node_otp "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/otp.py"
click node_tracking "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/tracking.py"
click node_chat "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/chat.py"
click node_socket_server "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/sio.py"
click node_database "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/database.py"
click node_models "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/models/models.py"
click node_redis "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/redis.py"
click node_security "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/security.py"
click node_auth_middleware "https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/middleware/auth.py"

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_customer,node_worker,node_admin toneBlue
class node_api_entry,node_auth_routes,node_catalogue,node_customer_routes,node_worker_routes,node_admin_routes,node_payments,node_matching,node_fees,node_invoices,node_notifications,node_otp toneAmber
class node_tracking,node_chat,node_socket_server toneMint
class node_database,node_models,node_redis,node_security,node_auth_middleware,node_worker_actor toneRose
class node_customer_actor,node_admin_actor toneIndigo
```

## Components

### User applications

- [Customer app](https://github.com/pravinsingh1109/sahakarseva/tree/main/apps/customer/app): `apps/customer/app`
- [Worker app](https://github.com/pravinsingh1109/sahakarseva/tree/main/apps/worker/app): `apps/worker/app`
- [Admin portal](https://github.com/pravinsingh1109/sahakarseva/blob/main/apps/admin/src/App.tsx): `apps/admin/src/App.tsx`

### API and domain

- [API entry point](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/main.py): `backend/main.py`
- [Authentication](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Service discovery](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/services.py): `backend/routers/services.py`
- [Customer bookings](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/customer.py): `backend/routers/customer.py`
- [Worker operations](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/worker.py): `backend/routers/worker.py`
- [Cooperative administration](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/admin.py): `backend/routers/admin.py`
- [Payments](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/routers/payments.py): `backend/routers/payments.py`
- [Fair worker matching](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/matching.py): `backend/services/matching.py`
- [Daily access fees](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/access_fee.py): `backend/services/access_fee.py`
- [Fare invoices](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/invoice.py): `backend/services/invoice.py`
- [Notifications](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/notifications.py): `backend/services/notifications.py`
- [OTP service](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/services/otp.py): `backend/services/otp.py`

### Realtime dispatch

- [Live tracking](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/tracking.py): `backend/socket/tracking.py`
- [Realtime chat](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/chat.py): `backend/socket/chat.py`
- [Socket.IO server](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/socket/sio.py): `backend/socket/sio.py`

### Platform foundations

- [Relational data](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/database.py): `backend/core/database.py`
- [Marketplace records](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/models/models.py): `backend/models/models.py`
- [Ephemeral state](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/redis.py): `backend/core/redis.py`
- [Token security](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/core/security.py): `backend/core/security.py`
- [Role authorization](https://github.com/pravinsingh1109/sahakarseva/blob/main/backend/middleware/auth.py): `backend/middleware/auth.py`

### Other components

- **Worker**
- **Customer**
- **Administrator**

## Connections

- Customer → Customer app: uses
- Worker → Worker app: uses
- Administrator → Admin portal: uses
- Customer app → API entry point: calls API
- Worker app → API entry point: calls API
- Admin portal → API entry point: calls API
- API entry point → Authentication: mounts (evidence: `backend/main.py`)
- API entry point → Service discovery: mounts (evidence: `backend/main.py`)
- API entry point → Customer bookings: mounts (evidence: `backend/main.py`)
- API entry point → Worker operations: mounts (evidence: `backend/main.py`)
- API entry point → Cooperative administration: mounts (evidence: `backend/main.py`)
- API entry point → Payments: mounts (evidence: `backend/main.py`)
- API entry point → Socket.IO server: wraps (evidence: `backend/main.py`)
- API entry point → Live tracking: registers (evidence: `backend/main.py`)
- API entry point → Realtime chat: registers (evidence: `backend/main.py`)
- Service discovery → Fair worker matching: requests matches (evidence: `backend/routers/services.py`)
- Service discovery → Relational data: queries (evidence: `backend/routers/services.py`)
- Customer bookings → Relational data: reads/writes (evidence: `backend/routers/customer.py`)
- Customer bookings → Fare invoices: uses invoices (evidence: `backend/routers/customer.py`)
- Customer bookings → Notifications: uses notifications (evidence: `backend/routers/customer.py`)
- Customer bookings → Live tracking: uses tracking (evidence: `backend/routers/customer.py`)
- Worker operations → Relational data: reads/writes (evidence: `backend/routers/worker.py`)
- Worker operations → Daily access fees: uses fees (evidence: `backend/routers/worker.py`)
- Worker operations → Notifications: uses notifications (evidence: `backend/routers/worker.py`)
- Worker operations → Live tracking: uses tracking (evidence: `backend/routers/worker.py`)
- Worker operations → Ephemeral state: uses Redis (evidence: `backend/routers/worker.py`)
- Authentication → OTP service: uses OTP (evidence: `backend/routers/auth.py`)
- Authentication → Token security: uses tokens (evidence: `backend/routers/auth.py`)
- Authentication → Relational data: reads/writes (evidence: `backend/routers/auth.py`)
- Cooperative administration → Relational data: reads/writes (evidence: `backend/routers/admin.py`)
- Cooperative administration → Notifications: uses notifications (evidence: `backend/routers/admin.py`)
- Payments → Relational data: uses database
- Fair worker matching → Marketplace records: queries records (evidence: `backend/services/matching.py`)
- Live tracking → Ephemeral state: stores locations (evidence: `backend/socket/tracking.py`)
- Live tracking → Socket.IO server: emits events (evidence: `backend/socket/tracking.py`)
- Live tracking → Token security: decodes tokens (evidence: `backend/socket/tracking.py`)
- Realtime chat → Socket.IO server: uses server (evidence: `backend/socket/chat.py`)
- Role authorization → Token security: decodes token (evidence: `backend/middleware/auth.py`)
- Role authorization → Relational data: loads user (evidence: `backend/middleware/auth.py`)
- Role authorization → Marketplace records: queries user (evidence: `backend/middleware/auth.py`)
- Relational data → Marketplace records: defines records (evidence: `backend/models/models.py`)
