# niteshkrverma/life-insurance architecture

> Architecture diagram of the GitHub repository niteshkrverma/life-insurance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/niteshkrverma/life-insurance
- Repository: https://github.com/niteshkrverma/life-insurance

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack web application (“Life-Insurance Portal”) built with Django (Python).
- It follows Django’s MTV (Model-Template-View) pattern and provides two main user-facing domains:
- “customer” app – lets end users register, login, apply for policies, ask questions, view history.
- “insurance” app – lets admin users manage policies, categories, questions; view policy holders; handle contact inquiries.

##### Top-Level Components
- Client (Web Browser)
- Load Balancer / Web Server (e.g., Nginx)
- Application Server (Gunicorn/uWSGI running Django)
- Django Project (“insurancemanagement”)
- customer app
- insurance app
- shared settings, URL routing, ASGI/WSGI entrypoints
- Relational Database (PostgreSQL/MySQL/SQLite)
- Static File Server (for CSS/JS/docs/images)
- (Optional) External Services – e-mail/SMS gateway for notifications, third-party authentication, etc.

##### Relationships & Data-Flows
- 1) Browser → HTTP(S) → Nginx → Gunicorn → Django URL dispatcher
- 2) URL dispatcher → appropriate view function/class in customer/insurance app
- 3) View uses Forms and Models (Django ORM) → issues SQL queries → Database
- 4) ORM returns model instances → view renders Template → HTML response
- 5) Nginx (or WhiteNoise) serves static assets directly to browser
- 6) Admin actions (via Django admin site) follow same backend→DB flow
- 7) Contact form or policy notifications may invoke external email/SMS APIs

##### Architectural Patterns & Design Principles
- MTV (separation of Models, Templates, Views)
- App Modularization – customer vs. insurance concerns kept in separate Django apps
- Use of Django migrations to evolve database schema
- Shared settings.py configures middleware, installed apps, static/media routing

## Diagram (Mermaid)

```mermaid
graph TB
    %% Web Layer
    subgraph "Web Layer"
        Browser["Web Browser"]:::frontend
        Nginx["Nginx (Load Balancer/Web Server)"]:::backend
        StaticServer["Static File Server"]:::static
    end

    %% Application Layer
    subgraph "App Layer"
        Gunicorn["Gunicorn/uWSGI"]:::backend

        subgraph "Django Application" 
            Manage["manage.py"]:::backend
            subgraph "insurancemanagement"
                Settings["settings.py"]:::backend
                URLs["urls.py"]:::backend
                ASGI["asgi.py"]:::backend
                WSGI["wsgi.py"]:::backend
            end

            subgraph "customer app"
                CustModels["models.py"]:::backend
                CustViews["views.py"]:::backend
                CustForms["forms.py"]:::backend
                CustURLs["urls.py"]:::backend
                CustAdmin["admin.py"]:::backend
                CustMigrations["migrations/"]:::backend
                CustTemplates["templates/customer/"]:::backend
            end

            subgraph "insurance app"
                InsModels["models.py"]:::backend
                InsViews["views.py"]:::backend
                InsForms["forms.py"]:::backend
                InsAdmin["admin.py"]:::backend
                InsMigrations["migrations/"]:::backend
                InsTemplates["templates/insurance/"]:::backend
            end

            subgraph "Shared Templates"
                CustBase["customerbase.html"]:::backend
                AdminBase["adminbase.html"]:::backend
            end
        end
    end

    %% Database & External
    Database[(Database)]:::db
    External["External Services (Email/SMS)"]:::external

    %% Requirements & Config
    Requirements["requirements.txt"]:::backend
    VSCode[".vscode/"]:::backend
    GitIgnore[".gitignore"]:::backend
    GitAttr[".gitattributes"]:::backend

    %% Flows
    Browser -->|"HTTP(S) Request"| Nginx
    Nginx -->|"WSGI Call"| Gunicorn
    Gunicorn -->|"Route"| URLs
    URLs -->|"invoke view"| CustViews
    URLs -->|"invoke view"| InsViews
    CustViews -->|"ORM Query"| Database
    InsViews -->|"ORM Query"| Database
    CustViews -->|"render Template"| CustTemplates
    InsViews -->|"render Template"| InsTemplates
    Browser -->|"Static GET"| StaticServer
    CustViews -->|"send notification"| External
    InsViews -->|"send notification"| External

    %% Click Events
    click Manage "https://github.com/niteshkrverma/life-insurance/blob/main/manage.py"
    click Settings "https://github.com/niteshkrverma/life-insurance/blob/main/insurancemanagement/settings.py"
    click URLs "https://github.com/niteshkrverma/life-insurance/blob/main/insurancemanagement/urls.py"
    click ASGI "https://github.com/niteshkrverma/life-insurance/blob/main/insurancemanagement/asgi.py"
    click WSGI "https://github.com/niteshkrverma/life-insurance/blob/main/insurancemanagement/wsgi.py"
    click CustModels "https://github.com/niteshkrverma/life-insurance/blob/main/customer/models.py"
    click CustViews "https://github.com/niteshkrverma/life-insurance/blob/main/customer/views.py"
    click CustForms "https://github.com/niteshkrverma/life-insurance/blob/main/customer/forms.py"
    click CustURLs "https://github.com/niteshkrverma/life-insurance/blob/main/customer/urls.py"
    click CustAdmin "https://github.com/niteshkrverma/life-insurance/blob/main/customer/admin.py"
    click CustMigrations "https://github.com/niteshkrverma/life-insurance/tree/main/customer/migrations/"
    click CustTemplates "https://github.com/niteshkrverma/life-insurance/tree/main/templates/customer/"
    click InsModels "https://github.com/niteshkrverma/life-insurance/blob/main/insurance/models.py"
    click InsViews "https://github.com/niteshkrverma/life-insurance/blob/main/insurance/views.py"
    click InsForms "https://github.com/niteshkrverma/life-insurance/blob/main/insurance/forms.py"
    click InsAdmin "https://github.com/niteshkrverma/life-insurance/blob/main/insurance/admin.py"
    click InsMigrations "https://github.com/niteshkrverma/life-insurance/tree/main/insurance/migrations/"
    click InsTemplates "https://github.com/niteshkrverma/life-insurance/tree/main/templates/insurance/"
    click StaticServer "https://github.com/niteshkrverma/life-insurance/tree/main/static/"
    click Requirements "https://github.com/niteshkrverma/life-insurance/blob/main/requirements.txt"
    click VSCode "https://github.com/niteshkrverma/life-insurance/tree/main/.vscode/"
    click GitIgnore "https://github.com/niteshkrverma/life-insurance/blob/main/.gitignore"
    click GitAttr "https://github.com/niteshkrverma/life-insurance/blob/main/.gitattributes"

    %% Styles
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:1px
    classDef backend fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef db fill:#98FB98,stroke:#333,stroke-width:1px
    classDef static fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external stroke-dasharray: 5 5,stroke:#666,fill:none
```
