# sahastrawin/ai-research-studio architecture

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

- Interactive diagram: https://gitdiagram.com/sahastrawin/ai-research-studio
- Repository: https://github.com/sahastrawin/ai-research-studio

## Overview

AI Research & Learning Studio is a browser-based research and learning product backed by a single Express application. Users authenticate, choose a learning tool, submit source material or a question, and receive generated or streamed results; summaries and conversations can be retained for later browsing. The frontend initializes feature modules and calls the API, whose routes dispatch to controllers, services, providers, and models. The README documents additional generators and capabilities beyond the sampled implementation; their paths are shown where supported by the tree, but unsampled internal wiring is kept conservative.

Main entry points: [`server/src/models`](https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/models) (Data models), [`public/js/app.js`](https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/app.js) (Studio UI), [`server/src/routes/index.js`](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/index.js) (API routes), [`server/src/controllers/summarizeController.js`](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/summarizeController.js) (Summary controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser app"]
  node_browser["Studio UI<br/>[app.js]"]
  node_router["View router<br/>[router.js]"]
  node_featureui["Learning modules"]
  node_api["API client<br/>[api.js]"]
  node_sse["SSE reader<br/>[sse.js]"]
end

subgraph group_http["HTTP application"]
  node_serverapp["Express app<br/>[app.js]"]
  node_routes["API routes<br/>[index.js]"]
  node_aihttp["AI routes<br/>[aiRoutes.js]"]
  node_aihttpctl["AI controller<br/>[aiController.js]"]
  node_sumroutes["Summary routes<br/>[summarizeRoutes.js]"]
  node_sumctl["Summary controller"]
  node_genroutes["Generator routes<br/>[generatorRoutes.js]"]
  node_genctl["Generator controllers"]
  node_codingctl["Coding controller"]
  node_auth["Auth endpoints<br/>[authController.js]"]
end

subgraph group_features["Feature services"]
  node_ai["AI service<br/>[aiService.js]"]
  node_summarizer["Summarizer"]
  node_coding["Coding assistant"]
  node_generators["Learning generators"]
end

subgraph group_integrations["Providers and sources"]
  node_sources["Content extraction"]
  node_registry["Provider registry"]
  node_providers["AI providers"]
end

subgraph group_data["Persistence"]
  node_models["Data models"]
  node_db[("SQLite database<br/>[db.js]")]
end

node_user(("Learner"))

node_user -->|"uses"| node_browser
node_browser -->|"initializes"| node_router
node_browser -->|"initializes"| node_featureui
node_browser -->|"requests"| node_api
node_featureui -->|"calls API"| node_api
node_featureui -->|"reads streams"| node_sse
node_api -->|"HTTP requests"| node_serverapp
node_sse -->|"reads stream"| node_serverapp
node_serverapp -->|"mounts"| node_routes
node_routes -->|"dispatches"| node_aihttp
node_routes -->|"dispatches"| node_sumroutes
node_routes -->|"dispatches"| node_genroutes
node_aihttp -->|"dispatches"| node_aihttpctl
node_sumroutes -->|"dispatches"| node_sumctl
node_genroutes -->|"dispatches"| node_genctl
node_aihttpctl -->|"calls"| node_ai
node_aihttpctl -->|"persists chat"| node_models
node_ai -->|"selects provider"| node_registry
node_registry -->|"dispatches"| node_providers
node_sumctl -->|"extracts input"| node_sources
node_sumctl -->|"summarizes text"| node_summarizer
node_sumctl -->|"saves artifact"| node_models
node_genctl -->|"generates content"| node_generators
node_genctl -->|"saves results"| node_models
node_codingctl -->|"requests help"| node_coding
node_codingctl -->|"persists thread"| node_models
node_coding -->|"uses provider"| node_registry
node_auth -->|"reads and writes"| node_models
node_models -->|"reads and writes"| node_db

click node_browser "https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/app.js"
click node_router "https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/core/router.js"
click node_featureui "https://github.com/sahastrawin/ai-research-studio/tree/main/public/js/modules"
click node_api "https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/utils/api.js"
click node_sse "https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/utils/sse.js"
click node_serverapp "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/app.js"
click node_routes "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/index.js"
click node_aihttp "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/aiRoutes.js"
click node_aihttpctl "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/aiController.js"
click node_sumroutes "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/summarizeRoutes.js"
click node_sumctl "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/summarizeController.js"
click node_genroutes "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/generatorRoutes.js"
click node_genctl "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/generatorControllers.js"
click node_codingctl "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/codingController.js"
click node_auth "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/authController.js"
click node_ai "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/aiService.js"
click node_summarizer "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/summarizerService.js"
click node_coding "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/codingAssistantService.js"
click node_generators "https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/services"
click node_sources "https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/services"
click node_registry "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/providers/providerRegistry.js"
click node_providers "https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/providers"
click node_models "https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/models"
click node_db "https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/config/db.js"

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_browser,node_router,node_featureui,node_api,node_sse toneBlue
class node_serverapp,node_routes,node_aihttp,node_aihttpctl,node_sumroutes,node_sumctl,node_genroutes,node_genctl,node_codingctl,node_auth toneAmber
class node_ai,node_summarizer,node_coding,node_generators toneMint
class node_sources,node_registry,node_providers toneRose
class node_models,node_db,node_user toneIndigo
```

## Components

### Browser app

- [Studio UI](https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/app.js): `public/js/app.js`
- [View router](https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/core/router.js): `public/js/core/router.js`
- [Learning modules](https://github.com/sahastrawin/ai-research-studio/tree/main/public/js/modules): `public/js/modules`
- [API client](https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/utils/api.js): `public/js/utils/api.js`
- [SSE reader](https://github.com/sahastrawin/ai-research-studio/blob/main/public/js/utils/sse.js): `public/js/utils/sse.js`

### HTTP application

- [Express app](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/app.js): `server/src/app.js`
- [API routes](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/index.js): `server/src/routes/index.js`
- [AI routes](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/aiRoutes.js): `server/src/routes/aiRoutes.js`
- [AI controller](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/aiController.js): `server/src/controllers/aiController.js`
- [Summary routes](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/summarizeRoutes.js): `server/src/routes/summarizeRoutes.js`
- [Summary controller](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/summarizeController.js): `server/src/controllers/summarizeController.js`
- [Generator routes](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/routes/generatorRoutes.js): `server/src/routes/generatorRoutes.js`
- [Generator controllers](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/generatorControllers.js): `server/src/controllers/generatorControllers.js`
- [Coding controller](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/codingController.js): `server/src/controllers/codingController.js`
- [Auth endpoints](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`

### Feature services

- [AI service](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/aiService.js): `server/src/services/aiService.js`
- [Summarizer](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/summarizerService.js): `server/src/services/summarizerService.js`
- [Coding assistant](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/services/codingAssistantService.js): `server/src/services/codingAssistantService.js`
- [Learning generators](https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/services): `server/src/services`

### Providers and sources

- [Content extraction](https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/services): `server/src/services`
- [Provider registry](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/providers/providerRegistry.js): `server/src/providers/providerRegistry.js`
- [AI providers](https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/providers): `server/src/providers`

### Persistence

- [Data models](https://github.com/sahastrawin/ai-research-studio/tree/main/server/src/models): `server/src/models`
- [SQLite database](https://github.com/sahastrawin/ai-research-studio/blob/main/server/src/config/db.js): `server/src/config/db.js`

### Other components

- **Learner**

## Connections

- Learner → Studio UI: uses
- Studio UI → View router: initializes
- Studio UI → Learning modules: initializes
- Studio UI → API client: requests
- Learning modules → API client: calls API
- Learning modules → SSE reader: reads streams
- API client → Express app: HTTP requests
- SSE reader → Express app: reads stream
- Express app → API routes: mounts
- API routes → AI routes: dispatches
- API routes → Summary routes: dispatches
- API routes → Generator routes: dispatches
- AI routes → AI controller: dispatches
- Summary routes → Summary controller: dispatches
- Generator routes → Generator controllers: dispatches
- AI controller → AI service: calls
- AI controller → Data models: persists chat
- AI service → Provider registry: selects provider
- Provider registry → AI providers: dispatches
- Summary controller → Content extraction: extracts input
- Summary controller → Summarizer: summarizes text
- Summary controller → Data models: saves artifact
- Generator controllers → Learning generators: generates content
- Generator controllers → Data models: saves results
- Coding controller → Coding assistant: requests help
- Coding controller → Data models: persists thread
- Coding assistant → Provider registry: uses provider
- Auth endpoints → Data models: reads and writes
- Data models → SQLite database: reads and writes
