# codinghub27/ai_assistant architecture

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

- Interactive diagram: https://gitdiagram.com/codinghub27/ai_assistant
- Repository: https://github.com/codinghub27/ai_assistant

## Overview

AI Research Assistant is a Django application where authenticated users submit questions, receive agent-produced answers with source links, and can review or clear saved research history. The research view loads recent conversation context, invokes the LangChain agent, extracts sources, and stores the result. Documented agent tools cover web search, page reading, Wikipedia summaries, and text summarization. The README also describes JWT-protected APIs and template-based pages. Agent, model, and routing details are represented from the README and tree where their source was not sampled.

Main entry points: [`agent/views.py`](https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py) (Research API), [`agent/agent.py`](https://github.com/codinghub27/ai_assistant/blob/main/agent/agent.py) (ReAct Agent), [`agent/models.py`](https://github.com/codinghub27/ai_assistant/blob/main/agent/models.py) (Saved Queries), [`agent/urls.py`](https://github.com/codinghub27/ai_assistant/blob/main/agent/urls.py) (Research Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_research["Research Workflow"]
  node_research_api["Research API<br/>[views.py]"]
  node_agent_runtime["ReAct Agent<br/>[agent.py]"]
  node_source_extract["Source Extraction<br/>[views.py]"]
  node_history_api["History API<br/>[views.py]"]
  node_delete_api["Delete History<br/>[views.py]"]
  node_agent_routes["Research Routes<br/>[urls.py]"]
  node_project_routes["Project Routing<br/>[urls.py]"]
end

subgraph group_tools["Research Tools"]
  node_search["Web Search<br/>[tools.py]"]
  node_page_reader["Page Reader<br/>[tools.py]"]
  node_wiki["Wikipedia Lookup<br/>[tools.py]"]
  node_summarizer["Text Summarizer<br/>[tools.py]"]
end

subgraph group_persistence["History Storage"]
  node_session_store[("Research Sessions<br/>[models.py]")]
  node_query_store[("Saved Queries<br/>[models.py]")]
end

subgraph group_identity["Accounts and UI"]
  node_auth_views["Account Views<br/>[views.py]"]
  node_auth_routes["Login Routes<br/>[urls.py]"]
  node_chat_ui["Chat and History UI"]
  node_user_ui["Account UI"]
end

node_user(("User"))
node_tavily["Tavily"]
node_web_pages["Web Pages"]
node_wikipedia_service["Wikipedia API"]
node_llm["Groq LLM"]
node_postgres[("PostgreSQL")]

node_user -->|"submits question"| node_research_api
node_research_api -->|"gets session"| node_session_store
node_research_api -->|"loads context"| node_query_store
node_research_api -->|"invokes agent"| node_agent_runtime
node_agent_runtime -->|"calls tool"| node_search
node_agent_runtime -->|"calls tool"| node_page_reader
node_agent_runtime -->|"calls tool"| node_wiki
node_agent_runtime -->|"calls tool"| node_summarizer
node_search -->|"searches"| node_tavily
node_page_reader -->|"fetches content"| node_web_pages
node_wiki -->|"requests summary"| node_wikipedia_service
node_summarizer -->|"summarizes text"| node_llm
node_research_api -->|"extracts sources"| node_source_extract
node_research_api -->|"saves answer"| node_query_store
node_research_api -->|"returns answer"| node_user
node_history_api -->|"finds session"| node_session_store
node_history_api -->|"reads history"| node_query_store
node_delete_api -->|"finds session"| node_session_store
node_delete_api -->|"deletes queries"| node_query_store
node_user -->|"requests history"| node_history_api
node_user -->|"clears history"| node_delete_api
node_user -->|"opens account"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_views
node_user -->|"opens research"| node_agent_routes
node_agent_routes -->|"dispatches"| node_research_api
node_project_routes -->|"includes routes"| node_agent_routes
node_project_routes -->|"includes routes"| node_auth_routes
node_user -->|"uses chat"| node_chat_ui
node_user -->|"uses account pages"| node_user_ui
node_research_api -->|"renders pages"| node_chat_ui
node_history_api -->|"renders history"| node_chat_ui
node_session_store -->|"persists records"| node_postgres
node_query_store -->|"persists records"| node_postgres

click node_research_api "https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py"
click node_agent_runtime "https://github.com/codinghub27/ai_assistant/blob/main/agent/agent.py"
click node_source_extract "https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py"
click node_search "https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py"
click node_page_reader "https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py"
click node_wiki "https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py"
click node_summarizer "https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py"
click node_session_store "https://github.com/codinghub27/ai_assistant/blob/main/agent/models.py"
click node_query_store "https://github.com/codinghub27/ai_assistant/blob/main/agent/models.py"
click node_history_api "https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py"
click node_delete_api "https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py"
click node_auth_views "https://github.com/codinghub27/ai_assistant/blob/main/users/views.py"
click node_auth_routes "https://github.com/codinghub27/ai_assistant/blob/main/users/urls.py"
click node_agent_routes "https://github.com/codinghub27/ai_assistant/blob/main/agent/urls.py"
click node_chat_ui "https://github.com/codinghub27/ai_assistant/tree/main/agent/templates/agent"
click node_user_ui "https://github.com/codinghub27/ai_assistant/tree/main/users/templates/users"
click node_project_routes "https://github.com/codinghub27/ai_assistant/blob/main/research/urls.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_research_api,node_agent_runtime,node_source_extract,node_history_api,node_delete_api,node_agent_routes,node_project_routes,node_user toneBlue
class node_search,node_page_reader,node_wiki,node_summarizer,node_postgres toneAmber
class node_session_store,node_query_store,node_wikipedia_service toneMint
class node_auth_views,node_auth_routes,node_chat_ui,node_user_ui toneRose
class node_tavily,node_web_pages,node_llm toneIndigo
```

## Components

### Research Workflow

- [Research API](https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py): `agent/views.py`
- [ReAct Agent](https://github.com/codinghub27/ai_assistant/blob/main/agent/agent.py): `agent/agent.py`
- [Source Extraction](https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py): `agent/views.py`
- [History API](https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py): `agent/views.py`
- [Delete History](https://github.com/codinghub27/ai_assistant/blob/main/agent/views.py): `agent/views.py`
- [Research Routes](https://github.com/codinghub27/ai_assistant/blob/main/agent/urls.py): `agent/urls.py`
- [Project Routing](https://github.com/codinghub27/ai_assistant/blob/main/research/urls.py): `research/urls.py`

### Research Tools

- [Web Search](https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py): `agent/tools.py`
- [Page Reader](https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py): `agent/tools.py`
- [Wikipedia Lookup](https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py): `agent/tools.py`
- [Text Summarizer](https://github.com/codinghub27/ai_assistant/blob/main/agent/tools.py): `agent/tools.py`

### History Storage

- [Research Sessions](https://github.com/codinghub27/ai_assistant/blob/main/agent/models.py): `agent/models.py`
- [Saved Queries](https://github.com/codinghub27/ai_assistant/blob/main/agent/models.py): `agent/models.py`

### Accounts and UI

- [Account Views](https://github.com/codinghub27/ai_assistant/blob/main/users/views.py): `users/views.py`
- [Login Routes](https://github.com/codinghub27/ai_assistant/blob/main/users/urls.py): `users/urls.py`
- [Chat and History UI](https://github.com/codinghub27/ai_assistant/tree/main/agent/templates/agent): `agent/templates/agent`
- [Account UI](https://github.com/codinghub27/ai_assistant/tree/main/users/templates/users): `users/templates/users`

### Other components

- **User**
- **Tavily**
- **Web Pages**
- **Wikipedia API**
- **Groq LLM**
- **PostgreSQL**

## Connections

- User → Research API: submits question
- Research API → Research Sessions: gets session
- Research API → Saved Queries: loads context
- Research API → ReAct Agent: invokes agent
- ReAct Agent → Web Search: calls tool
- ReAct Agent → Page Reader: calls tool
- ReAct Agent → Wikipedia Lookup: calls tool
- ReAct Agent → Text Summarizer: calls tool
- Web Search → Tavily: searches
- Page Reader → Web Pages: fetches content
- Wikipedia Lookup → Wikipedia API: requests summary
- Text Summarizer → Groq LLM: summarizes text
- Research API → Source Extraction: extracts sources
- Research API → Saved Queries: saves answer
- Research API → User: returns answer
- History API → Research Sessions: finds session
- History API → Saved Queries: reads history
- Delete History → Research Sessions: finds session
- Delete History → Saved Queries: deletes queries
- User → History API: requests history
- User → Delete History: clears history
- User → Login Routes: opens account
- Login Routes → Account Views: dispatches
- User → Research Routes: opens research
- Research Routes → Research API: dispatches
- Project Routing → Research Routes: includes routes
- Project Routing → Login Routes: includes routes
- User → Chat and History UI: uses chat
- User → Account UI: uses account pages
- Research API → Chat and History UI: renders pages
- History API → Chat and History UI: renders history
- Research Sessions → PostgreSQL: persists records
- Saved Queries → PostgreSQL: persists records
