# s-harish2005/sih_backend_voxnova architecture

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

- Interactive diagram: https://gitdiagram.com/s-harish2005/sih_backend_voxnova
- Repository: https://github.com/s-harish2005/sih_backend_voxnova

## Overview

#### Purpose and entry points
This repository implements a Django backend organized around accounts, complaint handling, and rewards, plus a separate Python AI service for complaint classification and duplicate detection. Primary server entry points are `backend/manage.py`, `backend/backend/asgi.py`, and `backend/backend/wsgi.py`; the AI process is rooted at `ai_services/main.py`.

#### Django application boundary
The Django project configuration and top-level URL composition live in `backend/backend/settings.py` and `backend/backend/urls.py`. Feature modules follow Django’s app structure, exposing HTTP behavior through app views and, where present, app URL modules. The backend can run under synchronous WSGI or asynchronous ASGI deployment.

#### Accounts domain
The accounts app owns user/account persistence and request/response representation:
- `backend/accounts/models.py`
- `backend/accounts/serializers.py`
- `backend/accounts/views.py`
- `backend/accounts/urls.py`

Schema evolution is captured in `backend/accounts/migrations/`, including multiple migrations that modify user-related fields. This app is the likely identity/profile boundary consumed by complaint and reward workflows.

#### Complaint lifecycle and AI integration
The complaints app is the central workflow domain, with persistence, API serialization, and HTTP handlers in:
- `backend/complaints/models.py`
- `backend/complaints/serializers.py`
- `backend/complaints/views.py`

`backend/complaints/ai_clients.py` forms the integration boundary between Django complaint operations and the separate AI service. Complaint creation or processing can therefore remain in Django while model-oriented classification and duplicate analysis are delegated over a client boundary rather than embedded in request handlers.

#### AI service
The standalone AI service separates inference/analysis concerns from the Django runtime:
- `ai_services/main.py`
- `ai_services/classifier.py`
- `ai_services/duplicate.py`

`classifier.py` represents complaint categorization logic, while `duplicate.py` represents similarity or duplicate-complaint analysis. Its independently declared dependencies in `ai_services/requirements.txt` indicate it is deployable and scalable separately from the backend, with `backend/complaints/ai_clients.py` as its expected consumer.

#### Rewards domain
Rewards is an independent Django app responsible for reward-related state and operations:
- `backend/rewards/models.py`
- `backend/rewards/views.py`
- `backend/rewards/migrations/0001_initial.py`

Its separation from complaints suggests rewards are a downstream or adjacent business capability rather than part of the AI service. Any coupling to account or complaint events should cross Django app model/view boundaries rather than the AI-service boundary.

#### Persistence and operational flow
The checked-in development database is `backend/db.sqlite3`; Django models and migrations define the durable schema for accounts, complaints, and rewards. The primary control flow is: client request → project URL routing → app view → serializer/model persistence; complaint-specific paths may additionally call `ai_clients.py` → AI service → classifier/duplicate result → complaint workflow response or stored update. Production infrastructure is not specified beyond Django’s ASGI/WSGI interfaces, SQLite development storage, and the separately runnable AI Python service.

Main entry points: [`backend/backend/urls.py`](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/urls.py) (Root URL routing), [`ai_services/main.py`](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/main.py) (AI service process), [`backend/complaints/views.py`](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/views.py) (Complaints API), [`backend/complaints/ai_clients.py`](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/ai_clients.py) (AI client boundary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django Backend"]
  node_manage["Django management<br/>entry point<br/>[manage.py]"]
  node_asgi["ASGI server<br/>deployment entry<br/>[asgi.py]"]
  node_wsgi["WSGI server<br/>deployment entry<br/>[wsgi.py]"]
  node_project_config["Project config<br/>Django settings<br/>[settings.py]"]
  node_root_urls["Root URL routing<br/>Django URLs<br/>[urls.py]"]
  node_accounts_api["Accounts API<br/>Django app layer<br/>[views.py]"]
  node_accounts_schema["Accounts schema<br/>Django models<br/>[models.py]"]
  node_accounts_migrations["Account migrations<br/>schema evolution"]
  node_complaints_api["Complaints API<br/>Django app layer<br/>[views.py]"]
  node_complaints_schema["Complaints schema<br/>Django models<br/>[models.py]"]
  node_ai_client{{"AI client boundary<br/>service client<br/>[ai_clients.py]"}}
  node_rewards_api["Rewards API<br/>Django app layer<br/>[views.py]"]
  node_rewards_schema["Rewards schema<br/>Django models<br/>[models.py]"]
  node_rewards_migration["Rewards initial schema<br/>schema evolution<br/>[0001_initial.py]"]
  node_sqlite[("Development database<br/>SQLite<br/>[db.sqlite3]")]
end

subgraph group_ai["AI Service"]
  node_ai_main["AI service process<br/>Python entry point<br/>[main.py]"]
  node_classifier["Complaint classifier<br/>inference module<br/>[classifier.py]"]
  node_duplicate["Duplicate detector<br/>similarity module<br/>[duplicate.py]"]
end

node_manage -->|"loads"| node_project_config
node_asgi -->|"loads"| node_project_config
node_wsgi -->|"loads"| node_project_config
node_project_config -->|"configures"| node_root_urls
node_root_urls -->|"routes account requests"| node_accounts_api
node_root_urls -->|"routes complaint requests"| node_complaints_api
node_root_urls -->|"routes reward requests"| node_rewards_api
node_accounts_api -->|"reads and writes"| node_accounts_schema
node_complaints_api -->|"reads and writes"| node_complaints_schema
node_rewards_api -->|"reads and writes"| node_rewards_schema
node_accounts_migrations -.->|"evolves"| node_accounts_schema
node_rewards_migration -.->|"creates"| node_rewards_schema
node_accounts_schema -->|"persists"| node_sqlite
node_complaints_schema -->|"persists"| node_sqlite
node_rewards_schema -->|"persists"| node_sqlite
node_complaints_api -->|"requests analysis"| node_ai_client
node_ai_client -->|"calls"| node_ai_main
node_ai_main -->|"categorizes complaints"| node_classifier
node_ai_main -->|"detects duplicates"| node_duplicate
node_ai_main -.->|"returns analysis"| node_ai_client
node_ai_client -.->|"returns result"| node_complaints_api

click node_manage "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/manage.py"
click node_asgi "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/asgi.py"
click node_wsgi "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/wsgi.py"
click node_project_config "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/settings.py"
click node_root_urls "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/urls.py"
click node_accounts_api "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/accounts/views.py"
click node_accounts_schema "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/accounts/models.py"
click node_complaints_api "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/views.py"
click node_complaints_schema "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/models.py"
click node_ai_client "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/ai_clients.py"
click node_rewards_api "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/views.py"
click node_rewards_schema "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/models.py"
click node_rewards_migration "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/migrations/0001_initial.py"
click node_sqlite "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/db.sqlite3"
click node_ai_main "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/main.py"
click node_classifier "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/classifier.py"
click node_duplicate "https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/duplicate.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_manage,node_asgi,node_wsgi,node_project_config,node_root_urls,node_accounts_api,node_accounts_schema,node_accounts_migrations,node_complaints_api,node_complaints_schema,node_ai_client,node_rewards_api,node_rewards_schema,node_rewards_migration,node_sqlite toneBlue
class node_ai_main,node_classifier,node_duplicate toneAmber
```

## Components

### Django Backend

HTTP API, workflow domains, and SQLite persistence.

- [Django management](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/manage.py): entry point · `backend/manage.py`
- [ASGI server](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/asgi.py): deployment entry · `backend/backend/asgi.py`
- [WSGI server](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/wsgi.py): deployment entry · `backend/backend/wsgi.py`
- [Project config](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/settings.py): Django settings · `backend/backend/settings.py`
- [Root URL routing](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/backend/urls.py): Django URLs · `backend/backend/urls.py`
- [Accounts API](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/accounts/views.py): Django app layer · Account views and request representations. · `backend/accounts/views.py`
- [Accounts schema](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/accounts/models.py): Django models · User and profile persistence. · `backend/accounts/models.py`
- **Account migrations**: schema evolution
- [Complaints API](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/views.py): Django app layer · Central complaint lifecycle handlers. · `backend/complaints/views.py`
- [Complaints schema](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/models.py): Django models · `backend/complaints/models.py`
- [AI client boundary](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/complaints/ai_clients.py): service client · Delegates complaint analysis outside Django. · `backend/complaints/ai_clients.py`
- [Rewards API](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/views.py): Django app layer · Reward operations and state handling. · `backend/rewards/views.py`
- [Rewards schema](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/models.py): Django models · `backend/rewards/models.py`
- [Rewards initial schema](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/rewards/migrations/0001_initial.py): schema evolution · `backend/rewards/migrations/0001_initial.py`
- [Development database](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/backend/db.sqlite3): SQLite · Durable Django application data. · `backend/db.sqlite3`

### AI Service

Separately runnable complaint analysis process.

- [AI service process](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/main.py): Python entry point · `ai_services/main.py`
- [Complaint classifier](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/classifier.py): inference module · `ai_services/classifier.py`
- [Duplicate detector](https://github.com/s-harish2005/sih_backend_voxnova/blob/main/ai_services/duplicate.py): similarity module · `ai_services/duplicate.py`

## Connections

- Django management → Project config: loads
- ASGI server → Project config: loads
- WSGI server → Project config: loads
- Project config → Root URL routing: configures
- Root URL routing → Accounts API: routes account requests
- Root URL routing → Complaints API: routes complaint requests
- Root URL routing → Rewards API: routes reward requests
- Accounts API → Accounts schema: reads and writes
- Complaints API → Complaints schema: reads and writes
- Rewards API → Rewards schema: reads and writes
- Account migrations → Accounts schema: evolves
- Rewards initial schema → Rewards schema: creates
- Accounts schema → Development database: persists
- Complaints schema → Development database: persists
- Rewards schema → Development database: persists
- Complaints API → AI client boundary: requests analysis
- AI client boundary → AI service process: calls
- AI service process → Complaint classifier: categorizes complaints
- AI service process → Duplicate detector: detects duplicates
- AI service process → AI client boundary: returns analysis
- AI client boundary → Complaints API: returns result
