# tanuj-datta/gita-gpt architecture

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

- Interactive diagram: https://gitdiagram.com/tanuj-datta/gita-gpt
- Repository: https://github.com/tanuj-datta/gita-gpt

## Overview

Gita-GPT is a bilingual Bhagavad Gita guidance app. Users explore chapter summaries or ask Krishna questions; the chat API retrieves verse context, requests a streamed Gemini response, and can persist conversations. Separate API routes handle verse loading, chat history, authentication, and voice. The excerpts show the UI-to-chat and chat-to-engine/auth/database/AI relationships; other unsampled route behavior is represented without inferred connections.

Main entry points: [`auth.ts`](https://github.com/tanuj-datta/gita-gpt/blob/master/auth.ts) (Authentication), [`app/api/chat/route.ts`](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chat/route.ts) (AI Chat API), [`app/page.tsx`](https://github.com/tanuj-datta/gita-gpt/blob/master/app/page.tsx) (Gita-GPT Interface), [`lib/prisma.ts`](https://github.com/tanuj-datta/gita-gpt/blob/master/lib/prisma.ts) (Prisma Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_home["Gita-GPT Interface<br/>[page.tsx]"]
  node_audio["Background Audio<br/>[AudioContext.tsx]"]
end

subgraph group_wisdom["Gita Wisdom"]
  node_roadmap["Chapter Roadmap<br/>[ChapterRoadmap.tsx]"]
  node_roadmapdata["Chapter Summaries"]
  node_gita_data["Verse Dataset<br/>[gita-data.json]"]
  node_engine["Verse Retrieval<br/>[gita-engine.ts]"]
  node_chapter_api["Chapter Verse API<br/>[route.ts]"]
end

subgraph group_conversation["Guidance and Chat"]
  node_chat_api["AI Chat API<br/>[route.ts]"]
  node_chat_list["Chat List API<br/>[route.ts]"]
  node_chat_detail["Chat Detail API<br/>[route.ts]"]
  node_voice_api["Voice API<br/>[route.ts]"]
end

subgraph group_identity["Identity and Storage"]
  node_auth_api["Auth Route<br/>[route.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_prisma["Prisma Client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
  node_providers["Session Providers<br/>[Providers.tsx]"]
end

node_user(("Visitor"))
node_gemini{{"Gemini AI"}}
node_google{{"Google Sign-In"}}
node_youtube{{"YouTube Player"}}

node_user -->|"uses"| node_home
node_home -->|"renders"| node_roadmap
node_home -->|"reads"| node_gita_data
node_roadmap -->|"reads"| node_roadmapdata
node_home -->|"sends messages"| node_chat_api
node_home -->|"uses"| node_audio
node_audio -->|"controls playback"| node_youtube
node_chat_api -->|"retrieves verses"| node_engine
node_engine -->|"searches"| node_gita_data
node_chat_api -->|"requests verses"| node_chapter_api
node_chat_api -->|"generates response"| node_gemini
node_chat_api -->|"checks session"| node_auth
node_chat_api -->|"reads and writes"| node_prisma
node_chat_list -->|"checks session"| node_auth
node_chat_list -->|"reads and creates"| node_prisma
node_chat_detail -->|"checks session"| node_auth
node_chat_detail -->|"reads and deletes"| node_prisma
node_auth_api -->|"routes handlers"| node_auth
node_auth -->|"configures adapter"| node_prisma
node_auth -->|"configures sign-in"| node_google
node_prisma -->|"connects"| node_database
node_providers -.->|"provides session context"| node_auth

click node_home "https://github.com/tanuj-datta/gita-gpt/blob/master/app/page.tsx"
click node_audio "https://github.com/tanuj-datta/gita-gpt/blob/master/components/AudioContext.tsx"
click node_roadmap "https://github.com/tanuj-datta/gita-gpt/blob/master/components/ChapterRoadmap.tsx"
click node_roadmapdata "https://github.com/tanuj-datta/gita-gpt/blob/master/lib/chapter-roadmap-data.ts"
click node_gita_data "https://github.com/tanuj-datta/gita-gpt/blob/master/lib/gita-data.json"
click node_engine "https://github.com/tanuj-datta/gita-gpt/blob/master/lib/gita-engine.ts"
click node_chapter_api "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chapters/%5Bid%5D/slokas/route.ts"
click node_chat_api "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chat/route.ts"
click node_chat_list "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chats/route.ts"
click node_chat_detail "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chats/%5Bid%5D/route.ts"
click node_voice_api "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/voice/route.ts"
click node_auth_api "https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/auth/%5B...nextauth%5D/route.ts"
click node_auth "https://github.com/tanuj-datta/gita-gpt/blob/master/auth.ts"
click node_prisma "https://github.com/tanuj-datta/gita-gpt/blob/master/lib/prisma.ts"
click node_providers "https://github.com/tanuj-datta/gita-gpt/blob/master/components/Providers.tsx"

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_home,node_audio toneBlue
class node_roadmap,node_roadmapdata,node_gita_data,node_engine,node_chapter_api toneAmber
class node_chat_api,node_chat_list,node_chat_detail,node_voice_api toneMint
class node_auth_api,node_auth,node_prisma,node_database,node_providers toneRose
class node_user,node_gemini,node_google,node_youtube toneIndigo
```

## Components

### User Experience

- [Gita-GPT Interface](https://github.com/tanuj-datta/gita-gpt/blob/master/app/page.tsx): `app/page.tsx`
- [Background Audio](https://github.com/tanuj-datta/gita-gpt/blob/master/components/AudioContext.tsx): `components/AudioContext.tsx`

### Gita Wisdom

- [Chapter Roadmap](https://github.com/tanuj-datta/gita-gpt/blob/master/components/ChapterRoadmap.tsx): `components/ChapterRoadmap.tsx`
- [Chapter Summaries](https://github.com/tanuj-datta/gita-gpt/blob/master/lib/chapter-roadmap-data.ts): `lib/chapter-roadmap-data.ts`
- [Verse Dataset](https://github.com/tanuj-datta/gita-gpt/blob/master/lib/gita-data.json): `lib/gita-data.json`
- [Verse Retrieval](https://github.com/tanuj-datta/gita-gpt/blob/master/lib/gita-engine.ts): `lib/gita-engine.ts`
- [Chapter Verse API](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chapters/%5Bid%5D/slokas/route.ts): `app/api/chapters/[id]/slokas/route.ts`

### Guidance and Chat

- [AI Chat API](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chat/route.ts): `app/api/chat/route.ts`
- [Chat List API](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chats/route.ts): `app/api/chats/route.ts`
- [Chat Detail API](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/chats/%5Bid%5D/route.ts): `app/api/chats/[id]/route.ts`
- [Voice API](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/voice/route.ts): `app/api/voice/route.ts`

### Identity and Storage

- [Auth Route](https://github.com/tanuj-datta/gita-gpt/blob/master/app/api/auth/%5B...nextauth%5D/route.ts): `app/api/auth/[...nextauth]/route.ts`
- [Authentication](https://github.com/tanuj-datta/gita-gpt/blob/master/auth.ts): `auth.ts`
- [Prisma Client](https://github.com/tanuj-datta/gita-gpt/blob/master/lib/prisma.ts): `lib/prisma.ts`
- **PostgreSQL**
- [Session Providers](https://github.com/tanuj-datta/gita-gpt/blob/master/components/Providers.tsx): `components/Providers.tsx`

### Other components

- **Visitor**
- **Gemini AI**
- **Google Sign-In**
- **YouTube Player**

## Connections

- Visitor → Gita-GPT Interface: uses
- Gita-GPT Interface → Chapter Roadmap: renders (evidence: `app/page.tsx`)
- Gita-GPT Interface → Verse Dataset: reads (evidence: `app/page.tsx`)
- Chapter Roadmap → Chapter Summaries: reads (evidence: `components/ChapterRoadmap.tsx`)
- Gita-GPT Interface → AI Chat API: sends messages (evidence: `app/page.tsx`)
- Gita-GPT Interface → Background Audio: uses (evidence: `app/page.tsx`)
- Background Audio → YouTube Player: controls playback (evidence: `components/AudioContext.tsx`)
- AI Chat API → Verse Retrieval: retrieves verses (evidence: `app/api/chat/route.ts`)
- Verse Retrieval → Verse Dataset: searches (evidence: `lib/gita-engine.ts`)
- AI Chat API → Chapter Verse API: requests verses (evidence: `app/api/chat/route.ts`)
- AI Chat API → Gemini AI: generates response (evidence: `app/api/chat/route.ts`)
- AI Chat API → Authentication: checks session (evidence: `app/api/chat/route.ts`)
- AI Chat API → Prisma Client: reads and writes (evidence: `app/api/chat/route.ts`)
- Chat List API → Authentication: checks session (evidence: `app/api/chats/route.ts`)
- Chat List API → Prisma Client: reads and creates (evidence: `app/api/chats/route.ts`)
- Chat Detail API → Authentication: checks session (evidence: `app/api/chats/[id]/route.ts`)
- Chat Detail API → Prisma Client: reads and deletes (evidence: `app/api/chats/[id]/route.ts`)
- Auth Route → Authentication: routes handlers (evidence: `app/api/auth/[...nextauth]/route.ts`)
- Authentication → Prisma Client: configures adapter (evidence: `auth.ts`)
- Authentication → Google Sign-In: configures sign-in (evidence: `auth.ts`)
- Prisma Client → PostgreSQL: connects (evidence: `lib/prisma.ts`)
- Session Providers → Authentication: provides session context
