# kirubhananths/aimnest_backend architecture

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

- Interactive diagram: https://gitdiagram.com/kirubhananths/aimnest_backend
- Repository: https://github.com/kirubhananths/aimnest_backend

## Overview

AImNest is a FastAPI backend for user accounts, workspaces, goals, tickets, notifications, settings, dashboards, and an AI chat assistant. The main workflow is a client request entering the API, passing authentication when required, then reaching a domain router that reads or updates persisted data. For chat, the conversation router delegates reply generation to an assistant service, which can assemble user-scoped context and use an AI provider. The README is a GitLab template and documents no product capabilities; connections reflect the supplied source index and excerpts, not uninspected implementation details.

Main entry points: [`app/db/session.py`](https://github.com/kirubhananths/aimnest_backend/blob/main/app/db/session.py) (Application database), [`app/main.py`](https://github.com/kirubhananths/aimnest_backend/blob/main/app/main.py) (FastAPI app), [`app/dependencies/auth.py`](https://github.com/kirubhananths/aimnest_backend/blob/main/app/dependencies/auth.py) (Auth dependency), [`app/services/ai_service.py`](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai_service.py) (Assistant service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_api_app["FastAPI app<br/>[main.py]"]
end

subgraph group_identity["Identity"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
  node_auth_service["Auth service<br/>[auth_service.py]"]
  node_jwt["JWT service<br/>[jwt_service.py]"]
  node_auth_guard["Auth dependency<br/>[auth.py]"]
  node_email["Email service<br/>[email_service.py]"]
end

subgraph group_domains["Product domains"]
  node_workspace_routes["Workspace routes<br/>[workspace.py]"]
  node_goal_routes["Goal routes<br/>[goal.py]"]
  node_ticket_routes["Ticket routes<br/>[ticket.py]"]
  node_dashboard_routes["Dashboard routes<br/>[dashboard.py]"]
  node_notification_routes["Notification routes<br/>[notification.py]"]
  node_settings_routes["Settings routes<br/>[settings.py]"]
end

subgraph group_assistant["AI assistant"]
  node_conversation_routes["Conversation routes<br/>[conversation.py]"]
  node_assistant_service["Assistant service<br/>[ai_service.py]"]
  node_context_service["Context retrieval<br/>[context.py]"]
  node_prompt_builder["Prompt builder<br/>[prompt_builder.py]"]
  node_provider_factory["Provider factory"]
  node_ollama["Ollama provider<br/>[ollama_provider.py]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Application database<br/>[session.py]")]
end

node_client(("Client"))

node_client -->|"sends requests"| node_api_app
node_api_app -->|"registers routes"| node_auth_routes
node_api_app -->|"registers routes"| node_workspace_routes
node_api_app -->|"registers routes"| node_goal_routes
node_api_app -->|"registers routes"| node_conversation_routes
node_api_app -->|"registers routes"| node_dashboard_routes
node_api_app -->|"registers routes"| node_notification_routes
node_api_app -->|"registers routes"| node_settings_routes
node_api_app -->|"registers routes"| node_ticket_routes
node_auth_routes -->|"delegates auth"| node_auth_service
node_auth_routes -->|"creates tokens"| node_jwt
node_auth_routes -->|"uses session"| node_database
node_auth_service -->|"sends email"| node_email
node_auth_service -->|"persists auth data"| node_database
node_auth_guard -->|"validates token"| node_jwt
node_auth_guard -->|"loads user"| node_database
node_workspace_routes -->|"requires identity"| node_auth_guard
node_workspace_routes -->|"reads and writes"| node_database
node_goal_routes -->|"requires identity"| node_auth_guard
node_goal_routes -->|"reads and writes"| node_database
node_ticket_routes -->|"requires identity"| node_auth_guard
node_ticket_routes -->|"reads and writes"| node_database
node_dashboard_routes -->|"requires identity"| node_auth_guard
node_dashboard_routes -->|"queries data"| node_database
node_notification_routes -->|"requires identity"| node_auth_guard
node_notification_routes -->|"reads and writes"| node_database
node_settings_routes -->|"requires identity"| node_auth_guard
node_settings_routes -->|"reads and writes"| node_database
node_conversation_routes -->|"requires identity"| node_auth_guard
node_conversation_routes -->|"reads and writes"| node_database
node_conversation_routes -->|"requests reply"| node_assistant_service
node_assistant_service -->|"builds context"| node_context_service
node_assistant_service -->|"assembles prompt"| node_prompt_builder
node_assistant_service -->|"selects provider"| node_provider_factory
node_assistant_service -->|"loads history"| node_database
node_context_service -->|"retrieves user data"| node_database
node_provider_factory -.->|"creates provider"| node_ollama

click node_api_app "https://github.com/kirubhananths/aimnest_backend/blob/main/app/main.py"
click node_auth_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/auth.py"
click node_auth_service "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/auth_service.py"
click node_jwt "https://github.com/kirubhananths/aimnest_backend/blob/main/app/core/jwt_service.py"
click node_auth_guard "https://github.com/kirubhananths/aimnest_backend/blob/main/app/dependencies/auth.py"
click node_workspace_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/workspace.py"
click node_goal_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/goal.py"
click node_ticket_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/ticket.py"
click node_dashboard_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/dashboard.py"
click node_notification_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/notification.py"
click node_settings_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/settings.py"
click node_conversation_routes "https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/conversation.py"
click node_assistant_service "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai_service.py"
click node_context_service "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/context.py"
click node_prompt_builder "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/prompt_builder.py"
click node_provider_factory "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/provider_factory.py"
click node_ollama "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/ollama_provider.py"
click node_database "https://github.com/kirubhananths/aimnest_backend/blob/main/app/db/session.py"
click node_email "https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/email_service.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_api_app,node_client toneBlue
class node_auth_routes,node_auth_service,node_jwt,node_auth_guard,node_email toneAmber
class node_workspace_routes,node_goal_routes,node_ticket_routes,node_dashboard_routes,node_notification_routes,node_settings_routes toneMint
class node_conversation_routes,node_assistant_service,node_context_service,node_prompt_builder,node_provider_factory,node_ollama toneRose
class node_database toneIndigo
```

## Components

### API surface

- [FastAPI app](https://github.com/kirubhananths/aimnest_backend/blob/main/app/main.py): `app/main.py`

### Identity

- [Auth routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/auth.py): `app/routers/auth.py`
- [Auth service](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/auth_service.py): `app/services/auth_service.py`
- [JWT service](https://github.com/kirubhananths/aimnest_backend/blob/main/app/core/jwt_service.py): `app/core/jwt_service.py`
- [Auth dependency](https://github.com/kirubhananths/aimnest_backend/blob/main/app/dependencies/auth.py): `app/dependencies/auth.py`
- [Email service](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/email_service.py): `app/services/email_service.py`

### Product domains

- [Workspace routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/workspace.py): `app/routers/workspace.py`
- [Goal routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/goal.py): `app/routers/goal.py`
- [Ticket routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/ticket.py): `app/routers/ticket.py`
- [Dashboard routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/dashboard.py): `app/routers/dashboard.py`
- [Notification routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/notification.py): `app/routers/notification.py`
- [Settings routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/settings.py): `app/routers/settings.py`

### AI assistant

- [Conversation routes](https://github.com/kirubhananths/aimnest_backend/blob/main/app/routers/conversation.py): `app/routers/conversation.py`
- [Assistant service](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai_service.py): `app/services/ai_service.py`
- [Context retrieval](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/context.py): `app/services/ai/context.py`
- [Prompt builder](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/prompt_builder.py): `app/services/ai/prompt_builder.py`
- [Provider factory](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/provider_factory.py): `app/services/ai/provider_factory.py`
- [Ollama provider](https://github.com/kirubhananths/aimnest_backend/blob/main/app/services/ai/ollama_provider.py): `app/services/ai/ollama_provider.py`

### Persistence

- [Application database](https://github.com/kirubhananths/aimnest_backend/blob/main/app/db/session.py): `app/db/session.py`

### Other components

- **Client**

## Connections

- Client → FastAPI app: sends requests (evidence: `app/main.py`)
- FastAPI app → Auth routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Workspace routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Goal routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Conversation routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Dashboard routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Notification routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Settings routes: registers routes (evidence: `app/main.py`)
- FastAPI app → Ticket routes: registers routes (evidence: `app/main.py`)
- Auth routes → Auth service: delegates auth (evidence: `app/routers/auth.py`)
- Auth routes → JWT service: creates tokens (evidence: `app/routers/auth.py`)
- Auth routes → Application database: uses session (evidence: `app/routers/auth.py`)
- Auth service → Email service: sends email (evidence: `app/services/auth_service.py`)
- Auth service → Application database: persists auth data (evidence: `app/services/auth_service.py`)
- Auth dependency → JWT service: validates token (evidence: `app/dependencies/auth.py`)
- Auth dependency → Application database: loads user (evidence: `app/dependencies/auth.py`)
- Workspace routes → Auth dependency: requires identity (evidence: `app/routers/workspace.py`)
- Workspace routes → Application database: reads and writes (evidence: `app/routers/workspace.py`)
- Goal routes → Auth dependency: requires identity (evidence: `app/routers/goal.py`)
- Goal routes → Application database: reads and writes (evidence: `app/routers/goal.py`)
- Ticket routes → Auth dependency: requires identity (evidence: `app/routers/ticket.py`)
- Ticket routes → Application database: reads and writes (evidence: `app/routers/ticket.py`)
- Dashboard routes → Auth dependency: requires identity (evidence: `app/routers/dashboard.py`)
- Dashboard routes → Application database: queries data (evidence: `app/routers/dashboard.py`)
- Notification routes → Auth dependency: requires identity (evidence: `app/routers/notification.py`)
- Notification routes → Application database: reads and writes (evidence: `app/routers/notification.py`)
- Settings routes → Auth dependency: requires identity (evidence: `app/routers/settings.py`)
- Settings routes → Application database: reads and writes (evidence: `app/routers/settings.py`)
- Conversation routes → Auth dependency: requires identity (evidence: `app/routers/conversation.py`)
- Conversation routes → Application database: reads and writes (evidence: `app/routers/conversation.py`)
- Conversation routes → Assistant service: requests reply (evidence: `app/routers/conversation.py`)
- Assistant service → Context retrieval: builds context (evidence: `app/services/ai_service.py`)
- Assistant service → Prompt builder: assembles prompt (evidence: `app/services/ai_service.py`)
- Assistant service → Provider factory: selects provider (evidence: `app/services/ai_service.py`)
- Assistant service → Application database: loads history (evidence: `app/services/ai_service.py`)
- Context retrieval → Application database: retrieves user data (evidence: `app/services/ai/context.py`)
- Provider factory → Ollama provider: creates provider
