# ghouma-workspace/agent-api architecture

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

- Interactive diagram: https://gitdiagram.com/ghouma-workspace/agent-api
- Repository: https://github.com/ghouma-workspace/agent-api

## Overview

AI API Assistant is a full-stack conversational agent: users authenticate, manage conversations, and send messages through a React chat UI; the FastAPI backend persists the turn, runs a LangGraph agent that may call tools, and returns the response with trace details. The README documents tool integrations, prompt management, summarization, caching, rate limiting, circuit breaking, and observability. Several backend modules were not excerpted, so their internal links are shown only where documented; otherwise the graph avoids asserting unverified calls.

Main entry points: [`backend/app/application/services/chat_service.py`](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/chat_service.py) (Chat service), [`frontend/src/App.tsx`](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/App.tsx) (Frontend routing), [`backend/app/api/deps/services.py`](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/api/deps/services.py) (Service dependencies), [`backend/app/application/agent/nodes`](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/application/agent/nodes) (Agent nodes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_app["Frontend routing<br/>[App.tsx]"]
  node_chatui["Chat page<br/>[ChatPage.tsx]"]
  node_loginui["Login page<br/>[LoginPage.tsx]"]
  node_adminui["Admin page<br/>[AdminPage.tsx]"]
  node_chatcomponents["Chat components"]
  node_usechat["Chat hooks<br/>[useChat.ts]"]
  node_client["API client<br/>[client.ts]"]
end

subgraph group_api["API and application"]
  node_api["FastAPI app<br/>[main.py]"]
  node_routers["API routers"]
  node_dependencies["Service dependencies<br/>[services.py]"]
  node_auth["Authentication<br/>[auth_service.py]"]
  node_chatservice["Chat service<br/>[chat_service.py]"]
  node_prompt["Prompt management<br/>[prompt_service.py]"]
  node_adminservice["Admin service<br/>[admin_service.py]"]
end

subgraph group_agent["Agent and tools"]
  node_graph["Agent graph<br/>[graph.py]"]
  node_agentstate["Agent state<br/>[state.py]"]
  node_agentnodes["Agent nodes"]
  node_registry["Tool registry<br/>[registry.py]"]
  node_toolplugins["Tool plugins"]
  node_llm["Groq provider<br/>[groq_provider.py]"]
end

subgraph group_persistence["Persistence and cache"]
  node_repos["DB repositories"]
  node_cache["Redis cache and limits"]
end

subgraph group_operations["Observability and tasks"]
  node_observability["Tracing and metrics"]
  node_summarization["Summarization task<br/>[summarization.py]"]
end

node_user(("User"))
node_groq["GroqCloud"]
node_database[("Postgres")]
node_redis[("Redis")]
node_langfuse["Langfuse"]
node_celery["Celery queue"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_chatui
node_app -->|"routes to"| node_loginui
node_app -->|"routes to"| node_adminui
node_chatui -->|"renders"| node_chatcomponents
node_chatui -->|"uses"| node_usechat
node_usechat -->|"calls"| node_client
node_loginui -->|"calls"| node_client
node_adminui -->|"calls"| node_client
node_client -.->|"HTTP requests"| node_routers
node_api -->|"registers"| node_routers
node_routers -.->|"resolves services"| node_dependencies
node_dependencies -->|"provides"| node_auth
node_dependencies -->|"provides"| node_chatservice
node_dependencies -->|"provides"| node_adminservice
node_auth -->|"uses interfaces"| node_repos
node_auth -.->|"persists sessions"| node_database
node_chatservice -->|"reads and writes"| node_repos
node_repos -->|"persists"| node_database
node_chatservice -->|"invokes"| node_graph
node_chatservice -->|"creates"| node_agentstate
node_graph -->|"dispatches"| node_agentnodes
node_graph -->|"flows state"| node_agentstate
node_agentnodes -.->|"fetch prompts"| node_prompt
node_agentnodes -.->|"requests completions"| node_llm
node_llm -->|"calls"| node_groq
node_agentnodes -.->|"selects tools"| node_registry
node_registry -->|"registers plugins"| node_toolplugins
node_toolplugins -.->|"checks cached results"| node_cache
node_toolplugins -.->|"rate limits"| node_redis
node_toolplugins -.->|"calls external APIs"| node_groq
node_chatservice -->|"records chat telemetry"| node_observability
node_chatservice -->|"starts and flushes trace"| node_langfuse
node_observability -.->|"exports traces"| node_langfuse
node_chatservice -->|"dispatches periodically"| node_summarization
node_summarization -->|"queued by"| node_celery
node_summarization -->|"compacts history"| node_database
node_summarization -->|"invalidates cache"| node_redis

click node_app "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/App.tsx"
click node_chatui "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/ChatPage.tsx"
click node_loginui "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/LoginPage.tsx"
click node_adminui "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/AdminPage.tsx"
click node_chatcomponents "https://github.com/ghouma-workspace/agent-api/tree/main/frontend/src/components/chat"
click node_usechat "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/hooks/useChat.ts"
click node_client "https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/api/client.ts"
click node_api "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/main.py"
click node_routers "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/api/v1/routers"
click node_dependencies "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/api/deps/services.py"
click node_auth "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/auth_service.py"
click node_chatservice "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/chat_service.py"
click node_prompt "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/prompt_service.py"
click node_adminservice "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/admin_service.py"
click node_graph "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/agent/graph.py"
click node_agentstate "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/agent/state.py"
click node_agentnodes "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/application/agent/nodes"
click node_registry "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/tools/registry.py"
click node_toolplugins "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/tools"
click node_llm "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/llm/groq_provider.py"
click node_repos "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/db/repositories"
click node_cache "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/cache"
click node_observability "https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/observability"
click node_summarization "https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/tasks/summarization.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_app,node_chatui,node_loginui,node_adminui,node_chatcomponents,node_usechat,node_client,node_user toneBlue
class node_api,node_routers,node_dependencies,node_auth,node_chatservice,node_prompt,node_adminservice,node_database,node_redis toneAmber
class node_graph,node_agentstate,node_agentnodes,node_registry,node_toolplugins,node_llm toneMint
class node_repos,node_cache,node_celery toneRose
class node_observability,node_summarization,node_groq,node_langfuse toneIndigo
```

## Components

### React frontend

- [Frontend routing](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat page](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/ChatPage.tsx): `frontend/src/pages/ChatPage.tsx`
- [Login page](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/LoginPage.tsx): `frontend/src/pages/LoginPage.tsx`
- [Admin page](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/pages/AdminPage.tsx): `frontend/src/pages/AdminPage.tsx`
- [Chat components](https://github.com/ghouma-workspace/agent-api/tree/main/frontend/src/components/chat): `frontend/src/components/chat`
- [Chat hooks](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/hooks/useChat.ts): `frontend/src/hooks/useChat.ts`
- [API client](https://github.com/ghouma-workspace/agent-api/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### API and application

- [FastAPI app](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/main.py): `backend/app/main.py`
- [API routers](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/api/v1/routers): `backend/app/api/v1/routers`
- [Service dependencies](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/api/deps/services.py): `backend/app/api/deps/services.py`
- [Authentication](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/auth_service.py): `backend/app/application/services/auth_service.py`
- [Chat service](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/chat_service.py): `backend/app/application/services/chat_service.py`
- [Prompt management](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/prompt_service.py): `backend/app/application/services/prompt_service.py`
- [Admin service](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/services/admin_service.py): `backend/app/application/services/admin_service.py`

### Agent and tools

- [Agent graph](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/agent/graph.py): `backend/app/application/agent/graph.py`
- [Agent state](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/application/agent/state.py): `backend/app/application/agent/state.py`
- [Agent nodes](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/application/agent/nodes): `backend/app/application/agent/nodes`
- [Tool registry](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/tools/registry.py): `backend/app/infrastructure/tools/registry.py`
- [Tool plugins](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/tools): `backend/app/infrastructure/tools`
- [Groq provider](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/llm/groq_provider.py): `backend/app/infrastructure/llm/groq_provider.py`

### Persistence and cache

- [DB repositories](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/db/repositories): `backend/app/infrastructure/db/repositories`
- [Redis cache and limits](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/cache): `backend/app/infrastructure/cache`

### Observability and tasks

- [Tracing and metrics](https://github.com/ghouma-workspace/agent-api/tree/main/backend/app/infrastructure/observability): `backend/app/infrastructure/observability`
- [Summarization task](https://github.com/ghouma-workspace/agent-api/blob/main/backend/app/infrastructure/tasks/summarization.py): `backend/app/infrastructure/tasks/summarization.py`

### Other components

- **User**
- **GroqCloud**
- **Postgres**
- **Redis**
- **Langfuse**
- **Celery queue**

## Connections

- User → Frontend routing: uses (evidence: `frontend/src/App.tsx`)
- Frontend routing → Chat page: routes to (evidence: `frontend/src/App.tsx`)
- Frontend routing → Login page: routes to (evidence: `frontend/src/App.tsx`)
- Frontend routing → Admin page: routes to (evidence: `frontend/src/App.tsx`)
- Chat page → Chat components: renders (evidence: `frontend/src/pages/ChatPage.tsx`)
- Chat page → Chat hooks: uses (evidence: `frontend/src/pages/ChatPage.tsx`)
- Chat hooks → API client: calls (evidence: `frontend/src/hooks/useChat.ts`)
- Login page → API client: calls (evidence: `frontend/src/pages/LoginPage.tsx`)
- Admin page → API client: calls (evidence: `frontend/src/pages/AdminPage.tsx`)
- API client → API routers: HTTP requests
- FastAPI app → API routers: registers (evidence: `backend/app/main.py`)
- API routers → Service dependencies: resolves services (evidence: `backend/app/api/v1/routers/auth.py`)
- Service dependencies → Authentication: provides (evidence: `backend/app/api/deps/services.py`)
- Service dependencies → Chat service: provides (evidence: `backend/app/api/deps/services.py`)
- Service dependencies → Admin service: provides (evidence: `backend/app/api/deps/services.py`)
- Authentication → DB repositories: uses interfaces (evidence: `backend/app/application/services/auth_service.py`)
- Authentication → Postgres: persists sessions
- Chat service → DB repositories: reads and writes (evidence: `backend/app/application/services/chat_service.py`)
- DB repositories → Postgres: persists (evidence: `backend/app/infrastructure/db/repositories/chat_repository.py`)
- Chat service → Agent graph: invokes (evidence: `backend/app/application/services/chat_service.py`)
- Chat service → Agent state: creates (evidence: `backend/app/application/services/chat_service.py`)
- Agent graph → Agent nodes: dispatches (evidence: `README.md`)
- Agent graph → Agent state: flows state (evidence: `backend/app/application/agent/state.py`)
- Agent nodes → Prompt management: fetch prompts
- Agent nodes → Groq provider: requests completions
- Groq provider → GroqCloud: calls (evidence: `README.md`)
- Agent nodes → Tool registry: selects tools
- Tool registry → Tool plugins: registers plugins (evidence: `README.md`)
- Tool plugins → Redis cache and limits: checks cached results (evidence: `README.md`)
- Tool plugins → Redis: rate limits (evidence: `README.md`)
- Tool plugins → GroqCloud: calls external APIs (evidence: `README.md`)
- Chat service → Tracing and metrics: records chat telemetry (evidence: `backend/app/application/services/chat_service.py`)
- Chat service → Langfuse: starts and flushes trace (evidence: `backend/app/application/services/chat_service.py`)
- Tracing and metrics → Langfuse: exports traces (evidence: `README.md`)
- Chat service → Summarization task: dispatches periodically (evidence: `backend/app/application/services/chat_service.py`)
- Summarization task → Celery queue: queued by (evidence: `README.md`)
- Summarization task → Postgres: compacts history (evidence: `README.md`)
- Summarization task → Redis: invalidates cache (evidence: `README.md`)
