# haaaarssssh/mis architecture

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

- Interactive diagram: https://gitdiagram.com/haaaarssssh/mis
- Repository: https://github.com/haaaarssssh/mis

## Overview

#### Purpose and entry points
Pariman Hub is a unified CRM and Income Tax Return (ITR) management system. It exposes a Flask API backed by PostgreSQL and a React/Vite single-page application. Backend startup is `backend/app.py`; frontend bootstraps at `frontend/src/main.jsx` and route composition is centered in `frontend/src/App.jsx`.

#### Runtime and deployment boundary
Docker Compose runs PostgreSQL, a Gunicorn-hosted Flask backend on port 5001, and an Nginx-served production frontend on port 3000. Local frontend development uses Vite and proxies `/api` to the backend. Primary deployment/runtime artifacts are `docker-compose.yml`, `backend/Dockerfile`, `frontend/Dockerfile`, and `.github/workflows/deploy.yml`.

#### Backend application composition
The Flask application initializes shared extensions and registers domain blueprints. `backend/app.py` is the HTTP composition root; `backend/extensions.py` holds cross-cutting application integrations; `backend/models.py` defines the persistence domain. API areas are split by business capability rather than a single controller layer.

#### Authentication, authorization, and protected access
Authentication endpoints and credential/session mechanics reside in `backend/auth_bp.py` and `backend/auth_helpers.py`. Client/staff access is guarded at backend boundaries, including document-specific access workflows in `backend/document_access_bp.py`. The frontend establishes client-side auth state and route protection through `frontend/src/context/AuthContext.jsx` and `frontend/src/components/layouts/ProtectedLayout.jsx`; server authorization remains the enforcement boundary.

#### CRM, staff, and work-management domains
Client lifecycle and CRM operations are served by `backend/client_bp.py`, with user-facing CRM/client views such as `frontend/src/pages/CrmDashboard.jsx`, `frontend/src/pages/Client360.jsx`, and `frontend/src/pages/ClientOnboarding.jsx`. Staff operations use `backend/staff_bp.py`; shared task/work queues use `backend/todo_bp.py` and `frontend/src/pages/UniversalTodoModule.jsx`. These domains converge around client records, staff allocations, and operational task status.

#### ITR workflow and document delivery
ITR-specific API operations are isolated in `backend/itr_bp.py`. The frontend provides upload, allocation, status, analytics, and staff/admin boards in `frontend/src/pages/ItrUpload.jsx`, `frontend/src/pages/ItrAllocations.jsx`, and `frontend/src/pages/ItrModule.jsx`. Document viewing and delivery are handled through client document UI components such as `frontend/src/components/ClientDocuments.jsx` and `frontend/src/components/SecurePdfViewer.jsx`, crossing the protected document-access API boundary.

#### Policy, library, notifications, and correspondence
Supporting operational modules are independently exposed: policies via `backend/policy_bp.py`, shared library content via `backend/library_bp.py`, and in-app notifications via `backend/notify_bp.py` plus `backend/notifications.py`. Letter generation spans backend templates in `backend/letter_templates/` and frontend composition/export paths in `frontend/src/components/LetterGenerator.jsx` and `frontend/src/utils/letterFill.js`.

#### Persistence and data movement
PostgreSQL schema evolution is managed by Alembic under `backend/migrations/`, while ORM entities live in `backend/models.py`. Existing-data ingestion/migration utilities are separate operational paths: `backend/etl_from_sql.py`, `backend/etl_migration.py`, and `backend/load_backup.py`. This keeps one-time or administrative data movement outside normal API request handling.

Main entry points: [`backend/app.py`](https://github.com/haaaarssssh/mis/blob/main/backend/app.py) (Flask composition root), [`frontend/src/App.jsx`](https://github.com/haaaarssssh/mis/blob/main/frontend/src/App.jsx) (Application routes), [`docker-compose.yml`](https://github.com/haaaarssssh/mis/blob/main/docker-compose.yml) (Docker Compose), [`backend/client_bp.py`](https://github.com/haaaarssssh/mis/blob/main/backend/client_bp.py) (CRM & staff APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime &amp; Delivery"]
  node_compose{{"Docker Compose<br/>orchestrator<br/>[docker-compose.yml]"}}
  node_deploy["Deploy workflow<br/>CI/CD<br/>[deploy.yml]"]
  node_frontend_container["Nginx frontend<br/>container build"]
  node_backend_container["Gunicorn API<br/>container build"]
end

subgraph group_frontend["React Frontend"]
  node_spa_bootstrap["SPA bootstrap &amp; routes<br/>React entry<br/>[main.jsx]"]
  node_app_routes["Application routes<br/>route composition<br/>[App.jsx]"]
  node_frontend_auth["Auth state &amp; protected routes<br/>access control UI<br/>[AuthContext.jsx]"]
  node_crm_ui["CRM client workspace<br/>frontend domain<br/>[Client360.jsx]"]
  node_itr_ui["ITR workflow UI<br/>frontend domain<br/>[ItrModule.jsx]"]
  node_documents_ui["Secure document viewer<br/>frontend domain"]
  node_work_ui["Work queue UI<br/>frontend domain"]
end

subgraph group_backend["Flask API"]
  node_flask_app["Flask composition root<br/>HTTP API<br/>[app.py]"]
  node_extensions["Shared extensions<br/>application integrations<br/>[extensions.py]"]
  node_auth_api["Authentication &amp; access<br/>API blueprint<br/>[auth_bp.py]"]
  node_crm_api["CRM &amp; staff APIs<br/>API blueprints<br/>[client_bp.py]"]
  node_itr_api["ITR API<br/>API blueprint<br/>[itr_bp.py]"]
  node_document_api["Document access API<br/>API blueprint"]
  node_operations_api["Operational content APIs<br/>API blueprints<br/>[notify_bp.py]"]
end

subgraph group_data["Data &amp; Operations"]
  node_models["ORM domain models<br/>persistence model<br/>[models.py]"]
  node_postgres[("PostgreSQL<br/>database")]
  node_migrations["Alembic migrations<br/>schema evolution<br/>[env.py]"]
  node_etl["Data ingestion utilities<br/>administrative ETL<br/>[etl_migration.py]"]
end

node_deploy -->|"deploys"| node_compose
node_compose -->|"runs"| node_frontend_container
node_compose -->|"runs"| node_backend_container
node_compose -->|"runs"| node_postgres
node_frontend_container -->|"serves"| node_spa_bootstrap
node_backend_container -->|"hosts"| node_flask_app
node_spa_bootstrap -->|"boots"| node_app_routes
node_app_routes -->|"guards routes with"| node_frontend_auth
node_app_routes -->|"renders"| node_crm_ui
node_app_routes -->|"renders"| node_itr_ui
node_app_routes -->|"renders"| node_documents_ui
node_app_routes -->|"renders"| node_work_ui
node_frontend_auth -->|"authenticates via"| node_auth_api
node_crm_ui -->|"uses"| node_crm_api
node_itr_ui -->|"uses"| node_itr_api
node_documents_ui -->|"uses"| node_document_api
node_work_ui -->|"uses"| node_crm_api
node_flask_app -->|"initializes"| node_extensions
node_flask_app -->|"registers"| node_auth_api
node_flask_app -->|"registers"| node_crm_api
node_flask_app -->|"registers"| node_itr_api
node_flask_app -->|"registers"| node_document_api
node_flask_app -->|"registers"| node_operations_api
node_crm_api -->|"uses"| node_models
node_itr_api -->|"uses"| node_models
node_document_api -->|"uses"| node_models
node_models -->|"persists to"| node_postgres
node_migrations -->|"evolves schema"| node_postgres
node_etl -.->|"imports administrative data"| node_postgres

click node_compose "https://github.com/haaaarssssh/mis/blob/main/docker-compose.yml"
click node_deploy "https://github.com/haaaarssssh/mis/blob/main/.github/workflows/deploy.yml"
click node_frontend_container "https://github.com/haaaarssssh/mis/tree/main/frontend/Dockerfile"
click node_backend_container "https://github.com/haaaarssssh/mis/tree/main/backend/Dockerfile"
click node_spa_bootstrap "https://github.com/haaaarssssh/mis/blob/main/frontend/src/main.jsx"
click node_app_routes "https://github.com/haaaarssssh/mis/blob/main/frontend/src/App.jsx"
click node_frontend_auth "https://github.com/haaaarssssh/mis/blob/main/frontend/src/context/AuthContext.jsx"
click node_crm_ui "https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/Client360.jsx"
click node_itr_ui "https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/ItrModule.jsx"
click node_documents_ui "https://github.com/haaaarssssh/mis/blob/main/frontend/src/components/SecurePdfViewer.jsx"
click node_work_ui "https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/UniversalTodoModule.jsx"
click node_flask_app "https://github.com/haaaarssssh/mis/blob/main/backend/app.py"
click node_extensions "https://github.com/haaaarssssh/mis/blob/main/backend/extensions.py"
click node_auth_api "https://github.com/haaaarssssh/mis/blob/main/backend/auth_bp.py"
click node_crm_api "https://github.com/haaaarssssh/mis/blob/main/backend/client_bp.py"
click node_itr_api "https://github.com/haaaarssssh/mis/blob/main/backend/itr_bp.py"
click node_document_api "https://github.com/haaaarssssh/mis/blob/main/backend/document_access_bp.py"
click node_operations_api "https://github.com/haaaarssssh/mis/blob/main/backend/notify_bp.py"
click node_models "https://github.com/haaaarssssh/mis/blob/main/backend/models.py"
click node_migrations "https://github.com/haaaarssssh/mis/blob/main/backend/migrations/env.py"
click node_etl "https://github.com/haaaarssssh/mis/blob/main/backend/etl_migration.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_compose,node_deploy,node_frontend_container,node_backend_container toneBlue
class node_spa_bootstrap,node_app_routes,node_frontend_auth,node_crm_ui,node_itr_ui,node_documents_ui,node_work_ui toneAmber
class node_flask_app,node_extensions,node_auth_api,node_crm_api,node_itr_api,node_document_api,node_operations_api toneMint
class node_models,node_postgres,node_migrations,node_etl toneRose
```

## Components

### Runtime & Delivery

- [Docker Compose](https://github.com/haaaarssssh/mis/blob/main/docker-compose.yml): orchestrator · Runs database, API, and production frontend. · `docker-compose.yml`
- [Deploy workflow](https://github.com/haaaarssssh/mis/blob/main/.github/workflows/deploy.yml): CI/CD · `.github/workflows/deploy.yml`
- [Nginx frontend](https://github.com/haaaarssssh/mis/tree/main/frontend/Dockerfile): container build · `frontend/Dockerfile`
- [Gunicorn API](https://github.com/haaaarssssh/mis/tree/main/backend/Dockerfile): container build · `backend/Dockerfile`

### React Frontend

- [SPA bootstrap & routes](https://github.com/haaaarssssh/mis/blob/main/frontend/src/main.jsx): React entry · `frontend/src/main.jsx`
- [Application routes](https://github.com/haaaarssssh/mis/blob/main/frontend/src/App.jsx): route composition · `frontend/src/App.jsx`
- [Auth state & protected routes](https://github.com/haaaarssssh/mis/blob/main/frontend/src/context/AuthContext.jsx): access control UI · Client-side state and route gating; API remains authoritative. · `frontend/src/context/AuthContext.jsx`
- [CRM client workspace](https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/Client360.jsx): frontend domain · `frontend/src/pages/Client360.jsx`
- [ITR workflow UI](https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/ItrModule.jsx): frontend domain · `frontend/src/pages/ItrModule.jsx`
- [Secure document viewer](https://github.com/haaaarssssh/mis/blob/main/frontend/src/components/SecurePdfViewer.jsx): frontend domain · `frontend/src/components/SecurePdfViewer.jsx`
- [Work queue UI](https://github.com/haaaarssssh/mis/blob/main/frontend/src/pages/UniversalTodoModule.jsx): frontend domain · `frontend/src/pages/UniversalTodoModule.jsx`

### Flask API

- [Flask composition root](https://github.com/haaaarssssh/mis/blob/main/backend/app.py): HTTP API · Initializes extensions and registers domain blueprints. · `backend/app.py`
- [Shared extensions](https://github.com/haaaarssssh/mis/blob/main/backend/extensions.py): application integrations · `backend/extensions.py`
- [Authentication & access](https://github.com/haaaarssssh/mis/blob/main/backend/auth_bp.py): API blueprint · Credentials, sessions, and protected access boundaries. · `backend/auth_bp.py`
- [CRM & staff APIs](https://github.com/haaaarssssh/mis/blob/main/backend/client_bp.py): API blueprints · Client lifecycle, staff operations, and task management. · `backend/client_bp.py`
- [ITR API](https://github.com/haaaarssssh/mis/blob/main/backend/itr_bp.py): API blueprint · `backend/itr_bp.py`
- [Document access API](https://github.com/haaaarssssh/mis/blob/main/backend/document_access_bp.py): API blueprint · Enforces document-specific access workflows. · `backend/document_access_bp.py`
- [Operational content APIs](https://github.com/haaaarssssh/mis/blob/main/backend/notify_bp.py): API blueprints · Policy, library, notifications, and correspondence support. · `backend/notify_bp.py`

### Data & Operations

- [ORM domain models](https://github.com/haaaarssssh/mis/blob/main/backend/models.py): persistence model · `backend/models.py`
- **PostgreSQL**: database
- [Alembic migrations](https://github.com/haaaarssssh/mis/blob/main/backend/migrations/env.py): schema evolution · `backend/migrations/env.py`
- [Data ingestion utilities](https://github.com/haaaarssssh/mis/blob/main/backend/etl_migration.py): administrative ETL · Separate from normal API request handling. · `backend/etl_migration.py`

## Connections

- Deploy workflow → Docker Compose: deploys
- Docker Compose → Nginx frontend: runs
- Docker Compose → Gunicorn API: runs
- Docker Compose → PostgreSQL: runs
- Nginx frontend → SPA bootstrap & routes: serves
- Gunicorn API → Flask composition root: hosts
- SPA bootstrap & routes → Application routes: boots
- Application routes → Auth state & protected routes: guards routes with
- Application routes → CRM client workspace: renders
- Application routes → ITR workflow UI: renders
- Application routes → Secure document viewer: renders
- Application routes → Work queue UI: renders
- Auth state & protected routes → Authentication & access: authenticates via
- CRM client workspace → CRM & staff APIs: uses
- ITR workflow UI → ITR API: uses
- Secure document viewer → Document access API: uses
- Work queue UI → CRM & staff APIs: uses
- Flask composition root → Shared extensions: initializes
- Flask composition root → Authentication & access: registers
- Flask composition root → CRM & staff APIs: registers
- Flask composition root → ITR API: registers
- Flask composition root → Document access API: registers
- Flask composition root → Operational content APIs: registers
- CRM & staff APIs → ORM domain models: uses
- ITR API → ORM domain models: uses
- Document access API → ORM domain models: uses
- ORM domain models → PostgreSQL: persists to
- Alembic migrations → PostgreSQL: evolves schema
- Data ingestion utilities → PostgreSQL: imports administrative data
