# thegravityfalls-11/legal_aid_advisor architecture

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

- Interactive diagram: https://gitdiagram.com/thegravityfalls-11/legal_aid_advisor
- Repository: https://github.com/thegravityfalls-11/legal_aid_advisor

## Overview

#### Purpose and Runtime
AI Legal Agent is a Python/Django legal-assistance application combining a browser UI, legal-chat capability, lawyer/booking and knowledge pages, and a separate document-summarization service. The main operational entry point is `chatbot_project/manage.py`; Django process configuration is in `chatbot_project/chatbot_project/settings.py`, with ASGI/WSGI deployment entry points at `chatbot_project/chatbot_project/asgi.py` and `chatbot_project/chatbot_project/wsgi.py`.

#### HTTP Routing and Application Composition
The Django project routes requests through `chatbot_project/chatbot_project/urls.py` into two apps:
- `chatbot_project/chatbot/urls.py`: chatbot-specific endpoints backed by `chatbot_project/chatbot/views.py`.
- `chatbot_project/frontend/urls.py`: page-oriented UI endpoints backed by `chatbot_project/frontend/views.py`.

This separates conversational/API behavior from the broader legal portal interface, though both run within one Django deployment.

#### Legal Portal Frontend
The `frontend` Django app serves the primary user journeys: dashboard, chat, lawyer directory, booking, case/court, knowledge, and authentication-oriented pages. Server-rendered page contracts live under `chatbot_project/frontend/templates/`, including `chat.html`, `booking.html`, and `knowledge.html`. Browser behavior and styling are separately delivered from `chatbot_project/frontend/static/js/` and `chatbot_project/frontend/static/css/`.

Control flow is browser → Django frontend URL/view → HTML template → page JavaScript interactions and any associated backend calls.

#### Chatbot Boundary
The chatbot app is the backend boundary for legal question processing, represented by `chatbot_project/chatbot/views.py` and exposed by `chatbot_project/chatbot/urls.py`. The README identifies Groq as the cloud LLM provider and Phidata as the agent framework; credentials, model invocation, and response behavior should be expected at this boundary rather than in page templates. The associated rendered/static chatbot assets include `chatbot_project/staticfiles/chatbot/chat.js` and `chatbot_project/staticfiles/chatbot/chat.css`.

#### Document Summarization Subsystem
A distinct Legal Summarizer package is nested alongside the Django apps, with its own application entry point at `chatbot_project/Legal_summarizer/Legal_summarizer/app3.py` and dependency manifest at `chatbot_project/Legal_summarizer/Legal_summarizer/requirements.txt`. It provides static UI files at `chatbot_project/Legal_summarizer/Legal_summarizer/static/index.html` and accepts persisted uploads under `chatbot_project/Legal_summarizer/Legal_summarizer/uploads/`.

This is an architectural boundary: document upload, summarization, and follow-up Q&A may run independently from Django, requiring an explicit integration or separate process/deployment.

#### Persistence and Administration
Django models are defined per domain app in `chatbot_project/chatbot/models.py` and `chatbot_project/frontend/models.py`; the documented default database is SQLite. Django’s standard administration capability is represented by `chatbot_project/chatbot/admin.py` and `chatbot_project/frontend/admin.py`, supporting management of persisted application data through the Django admin runtime.

#### Delivery and External Dependencies
The project requires Python 3.10 and Python package installation from the repository-level `requirements.txt`; the summarizer may need its own requirements installation. Runtime infrastructure consists of a Django server, SQLite storage, filesystem-backed uploaded documents, and external Groq LLM access mediated through Phidata. `chatbot_project/staticfiles/` is collected/static output, including Django admin assets, rather than the primary source location for feature UI assets.

Main entry points: [`chatbot_project/Legal_summarizer/Legal_summarizer/app3.py`](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/Legal_summarizer/Legal_summarizer/app3.py) (Summarizer service), [`chatbot_project/frontend/models.py`](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/models.py) (Domain models), [`chatbot_project/chatbot_project/urls.py`](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/urls.py) (Project routes), [`chatbot_project/frontend/views.py`](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/views.py) (Portal views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_django["Django Legal Portal"]
  node_manage{{"Django entry point<br/>Python CLI<br/>[manage.py]"}}
  node_django_config["Django configuration<br/>settings<br/>[settings.py]"]
  node_project_routes["Project routes<br/>URL router<br/>[urls.py]"]
  node_frontend_routes["Portal routes<br/>URL router<br/>[urls.py]"]
  node_frontend_views["Portal views<br/>Django views<br/>[views.py]"]
  node_templates["Portal templates<br/>server-rendered HTML"]
  node_frontend_assets["Portal JS and CSS<br/>static assets"]
  node_chatbot_routes["Chatbot routes<br/>URL router<br/>[urls.py]"]
  node_chatbot_views["Legal chat boundary<br/>Django views<br/>[views.py]"]
  node_domain_models["Domain models<br/>Django models<br/>[models.py]"]
  node_django_admin["Django admin<br/>admin registration<br/>[admin.py]"]
  node_asgi["ASGI entry point<br/>deployment entry<br/>[asgi.py]"]
  node_wsgi["WSGI entry point<br/>deployment entry<br/>[wsgi.py]"]
end

subgraph group_summarizer["Legal Summarizer"]
  node_summarizer_app{{"Summarizer service<br/>Python application<br/>[app3.py]"}}
  node_summarizer_ui["Summarizer UI<br/>static HTML<br/>[index.html]"]
  node_uploads[("Uploaded documents<br/>filesystem storage")]
end

node_browser(("Browser<br/>client"))
node_llm_agent["Phidata agent<br/>agent framework"]
node_groq{{"Groq<br/>external LLM"}}
node_sqlite[("SQLite<br/>database")]

node_manage -->|"loads"| node_django_config
node_asgi -->|"loads"| node_django_config
node_wsgi -->|"loads"| node_django_config
node_browser -->|"HTTP requests"| node_project_routes
node_project_routes -->|"portal paths"| node_frontend_routes
node_project_routes -->|"chat paths"| node_chatbot_routes
node_frontend_routes -->|"dispatches"| node_frontend_views
node_frontend_views -->|"renders"| node_templates
node_templates -->|"loads"| node_frontend_assets
node_chatbot_routes -->|"dispatches"| node_chatbot_views
node_chatbot_views -->|"invokes"| node_llm_agent
node_llm_agent -->|"model calls"| node_groq
node_frontend_views -->|"uses"| node_domain_models
node_chatbot_views -->|"uses"| node_domain_models
node_domain_models -->|"persists"| node_sqlite
node_django_admin -->|"administers"| node_domain_models
node_browser -.->|"document requests"| node_summarizer_app
node_summarizer_app -->|"serves"| node_summarizer_ui
node_summarizer_app -->|"stores uploads"| node_uploads
node_summarizer_app -.->|"may use LLM"| node_groq

click node_manage "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/manage.py"
click node_django_config "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/settings.py"
click node_project_routes "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/urls.py"
click node_frontend_routes "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/urls.py"
click node_frontend_views "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/views.py"
click node_chatbot_routes "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/urls.py"
click node_chatbot_views "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/views.py"
click node_domain_models "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/models.py"
click node_django_admin "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/admin.py"
click node_summarizer_app "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/Legal_summarizer/Legal_summarizer/app3.py"
click node_summarizer_ui "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/Legal_summarizer/Legal_summarizer/static/index.html"
click node_asgi "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/asgi.py"
click node_wsgi "https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/wsgi.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_django_config,node_project_routes,node_frontend_routes,node_frontend_views,node_templates,node_frontend_assets,node_chatbot_routes,node_chatbot_views,node_domain_models,node_django_admin,node_asgi,node_wsgi toneBlue
class node_summarizer_app,node_summarizer_ui,node_uploads toneAmber
class node_browser,node_llm_agent,node_groq,node_sqlite toneNeutral
```

## Components

### Django Legal Portal

Single deployment serving portal pages and legal chat.

- [Django entry point](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/manage.py): Python CLI · `chatbot_project/manage.py`
- [Django configuration](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/settings.py): settings · `chatbot_project/chatbot_project/settings.py`
- [Project routes](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/urls.py): URL router · `chatbot_project/chatbot_project/urls.py`
- [Portal routes](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/urls.py): URL router · `chatbot_project/frontend/urls.py`
- [Portal views](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/views.py): Django views · Handles dashboard, lawyer, booking, case, knowledge, and auth pages. · `chatbot_project/frontend/views.py`
- **Portal templates**: server-rendered HTML
- **Portal JS and CSS**: static assets
- [Chatbot routes](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/urls.py): URL router · `chatbot_project/chatbot/urls.py`
- [Legal chat boundary](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/views.py): Django views · Owns legal-question processing and LLM response behavior. · `chatbot_project/chatbot/views.py`
- [Domain models](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/frontend/models.py): Django models · `chatbot_project/frontend/models.py`
- [Django admin](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot/admin.py): admin registration · Manages persisted chatbot and portal data. · `chatbot_project/chatbot/admin.py`
- [ASGI entry point](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/asgi.py): deployment entry · `chatbot_project/chatbot_project/asgi.py`
- [WSGI entry point](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/chatbot_project/wsgi.py): deployment entry · `chatbot_project/chatbot_project/wsgi.py`

### Legal Summarizer

Separately runnable document summarization package.

- [Summarizer service](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/Legal_summarizer/Legal_summarizer/app3.py): Python application · Independently runs document upload, summarization, and follow-up Q&A. · `chatbot_project/Legal_summarizer/Legal_summarizer/app3.py`
- [Summarizer UI](https://github.com/thegravityfalls-11/legal_aid_advisor/blob/main/chatbot_project/Legal_summarizer/Legal_summarizer/static/index.html): static HTML · `chatbot_project/Legal_summarizer/Legal_summarizer/static/index.html`
- **Uploaded documents**: filesystem storage

### Other components

- **Browser**: client
- **Phidata agent**: agent framework
- **Groq**: external LLM
- **SQLite**: database · Default persisted application-data store.

## Connections

- Django entry point → Django configuration: loads
- ASGI entry point → Django configuration: loads
- WSGI entry point → Django configuration: loads
- Browser → Project routes: HTTP requests
- Project routes → Portal routes: portal paths
- Project routes → Chatbot routes: chat paths
- Portal routes → Portal views: dispatches
- Portal views → Portal templates: renders
- Portal templates → Portal JS and CSS: loads
- Chatbot routes → Legal chat boundary: dispatches
- Legal chat boundary → Phidata agent: invokes
- Phidata agent → Groq: model calls
- Portal views → Domain models: uses
- Legal chat boundary → Domain models: uses
- Domain models → SQLite: persists
- Django admin → Domain models: administers
- Browser → Summarizer service: document requests · Separate service boundary.
- Summarizer service → Summarizer UI: serves
- Summarizer service → Uploaded documents: stores uploads
- Summarizer service → Groq: may use LLM
