# jayp927/ai-manthan architecture

> Architecture diagram of the GitHub repository jayp927/ai-manthan, 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/jayp927/ai-manthan
- Repository: https://github.com/jayp927/ai-manthan

## Overview

ConnectIQ is a multi-tenant business community application. A representative user workflow is selecting a document template, submitting notes for AI-generated content, and receiving a populated document; the product also supports community and direct messaging, networking, announcements, events, and gamification. The graph combines sampled call relationships with README-documented capabilities; unsampled feature internals and their wiring are not inferred.

Main entry points: [`app/api/generate-document/route.ts`](https://github.com/jayp927/ai-manthan/blob/main/app/api/generate-document/route.ts) (Document Generator), [`app/community/page.tsx`](https://github.com/jayp927/ai-manthan/blob/main/app/community/page.tsx) (Community), [`app/actions/auth.ts`](https://github.com/jayp927/ai-manthan/blob/main/app/actions/auth.ts) (Authentication), [`app/templates/page.tsx`](https://github.com/jayp927/ai-manthan/blob/main/app/templates/page.tsx) (Template Browser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; Tenancy"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_tenant_context["Tenant Context<br/>[tenant-context.tsx]"]
end

subgraph group_documents["Document Generation"]
  node_template_ui["Template Browser<br/>[page.tsx]"]
  node_document_api["Document Generator<br/>[route.ts]"]
  node_templates["Template Storage<br/>[templates.ts]"]
  node_gemini["Gemini Model"]
end

subgraph group_community["Community &amp; Messaging"]
  node_community_page["Community<br/>[page.tsx]"]
  node_community_chat["Community Chat<br/>[realtime-chat.tsx]"]
  node_realtime_hook["Realtime Chat Hook"]
  node_direct_chat["Direct Chat<br/>[ChatComponent.tsx]"]
  node_conversation_list["Conversation List"]
  node_chat_api["Messaging API<br/>[route.ts]"]
  node_sangam_ui["Sangam Assistant<br/>[sangam-chat.tsx]"]
  node_sangam_api["Sangam Q&amp;A API<br/>[route.ts]"]
end

subgraph group_network["Networking &amp; Engagement"]
  node_matching["User Matching<br/>[route.ts]"]
  node_connections["Connections API<br/>[route.ts]"]
  node_announcements["Announcements<br/>[page.tsx]"]
  node_events["Events<br/>[page.tsx]"]
  node_leaderboard["Leaderboard<br/>[page.tsx]"]
end

subgraph group_platform["Data &amp; AI Services"]
  node_database[("Supabase Access<br/>[clients.ts]")]
  node_sangam_core["Document AI<br/>[embeddings.ts]"]
  node_gamification["Gamification Service"]
end

node_user(("Member"))

node_user -->|"selects template"| node_template_ui
node_template_ui -.->|"requests generation"| node_document_api
node_document_api -->|"checks user"| node_auth
node_document_api -->|"loads template"| node_templates
node_document_api -->|"generates content"| node_gemini
node_document_api -->|"returns generated data"| node_user
node_user -->|"authenticates"| node_auth
node_auth -->|"loads user"| node_database
node_user -.->|"opens community"| node_community_page
node_community_page -->|"renders chat"| node_community_chat
node_community_chat -->|"uses realtime"| node_realtime_hook
node_user -->|"opens conversation"| node_direct_chat
node_direct_chat -->|"loads conversation"| node_database
node_conversation_list -.->|"shows conversations"| node_user
node_user -.->|"sends messages"| node_chat_api
node_community_page -->|"renders assistant"| node_sangam_ui
node_sangam_ui -.->|"asks question"| node_sangam_api
node_sangam_api -.->|"retrieves knowledge"| node_sangam_core
node_user -.->|"finds matches"| node_matching
node_user -.->|"manages connections"| node_connections
node_user -->|"views opportunities"| node_announcements
node_user -->|"views events"| node_events
node_user -.->|"views standing"| node_leaderboard
node_leaderboard -->|"loads stats"| node_gamification
node_user -->|"selects tenant"| node_tenant_context

click node_template_ui "https://github.com/jayp927/ai-manthan/blob/main/app/templates/page.tsx"
click node_document_api "https://github.com/jayp927/ai-manthan/blob/main/app/api/generate-document/route.ts"
click node_templates "https://github.com/jayp927/ai-manthan/blob/main/lib/database/templates.ts"
click node_auth "https://github.com/jayp927/ai-manthan/blob/main/app/actions/auth.ts"
click node_tenant_context "https://github.com/jayp927/ai-manthan/blob/main/contexts/tenant-context.tsx"
click node_database "https://github.com/jayp927/ai-manthan/blob/main/lib/database/clients.ts"
click node_community_page "https://github.com/jayp927/ai-manthan/blob/main/app/community/page.tsx"
click node_community_chat "https://github.com/jayp927/ai-manthan/blob/main/components/community/realtime-chat.tsx"
click node_realtime_hook "https://github.com/jayp927/ai-manthan/blob/main/hooks/use-realtime-chat.tsx"
click node_direct_chat "https://github.com/jayp927/ai-manthan/blob/main/components/chat/ChatComponent.tsx"
click node_conversation_list "https://github.com/jayp927/ai-manthan/blob/main/components/chat/ConversationList.tsx"
click node_chat_api "https://github.com/jayp927/ai-manthan/blob/main/app/api/messages/route.ts"
click node_sangam_ui "https://github.com/jayp927/ai-manthan/blob/main/components/community/sangam-chat.tsx"
click node_sangam_api "https://github.com/jayp927/ai-manthan/blob/main/app/api/sangam/ask/route.ts"
click node_sangam_core "https://github.com/jayp927/ai-manthan/blob/main/lib/sangam/embeddings.ts"
click node_matching "https://github.com/jayp927/ai-manthan/blob/main/app/api/users/match/route.ts"
click node_connections "https://github.com/jayp927/ai-manthan/blob/main/app/api/connections/route.ts"
click node_announcements "https://github.com/jayp927/ai-manthan/blob/main/app/announcements/page.tsx"
click node_events "https://github.com/jayp927/ai-manthan/blob/main/app/events/page.tsx"
click node_leaderboard "https://github.com/jayp927/ai-manthan/blob/main/app/leaderboard/page.tsx"
click node_gamification "https://github.com/jayp927/ai-manthan/blob/main/lib/services/gamification-service.ts"

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_auth,node_tenant_context toneBlue
class node_template_ui,node_document_api,node_templates,node_gemini toneAmber
class node_community_page,node_community_chat,node_realtime_hook,node_direct_chat,node_conversation_list,node_chat_api,node_sangam_ui,node_sangam_api toneMint
class node_matching,node_connections,node_announcements,node_events,node_leaderboard toneRose
class node_database,node_sangam_core,node_gamification,node_user toneIndigo
```

## Components

### Identity & Tenancy

- [Authentication](https://github.com/jayp927/ai-manthan/blob/main/app/actions/auth.ts): `app/actions/auth.ts`
- [Tenant Context](https://github.com/jayp927/ai-manthan/blob/main/contexts/tenant-context.tsx): `contexts/tenant-context.tsx`

### Document Generation

- [Template Browser](https://github.com/jayp927/ai-manthan/blob/main/app/templates/page.tsx): `app/templates/page.tsx`
- [Document Generator](https://github.com/jayp927/ai-manthan/blob/main/app/api/generate-document/route.ts): `app/api/generate-document/route.ts`
- [Template Storage](https://github.com/jayp927/ai-manthan/blob/main/lib/database/templates.ts): `lib/database/templates.ts`
- **Gemini Model**

### Community & Messaging

- [Community](https://github.com/jayp927/ai-manthan/blob/main/app/community/page.tsx): `app/community/page.tsx`
- [Community Chat](https://github.com/jayp927/ai-manthan/blob/main/components/community/realtime-chat.tsx): `components/community/realtime-chat.tsx`
- [Realtime Chat Hook](https://github.com/jayp927/ai-manthan/blob/main/hooks/use-realtime-chat.tsx): `hooks/use-realtime-chat.tsx`
- [Direct Chat](https://github.com/jayp927/ai-manthan/blob/main/components/chat/ChatComponent.tsx): `components/chat/ChatComponent.tsx`
- [Conversation List](https://github.com/jayp927/ai-manthan/blob/main/components/chat/ConversationList.tsx): `components/chat/ConversationList.tsx`
- [Messaging API](https://github.com/jayp927/ai-manthan/blob/main/app/api/messages/route.ts): `app/api/messages/route.ts`
- [Sangam Assistant](https://github.com/jayp927/ai-manthan/blob/main/components/community/sangam-chat.tsx): `components/community/sangam-chat.tsx`
- [Sangam Q&A API](https://github.com/jayp927/ai-manthan/blob/main/app/api/sangam/ask/route.ts): `app/api/sangam/ask/route.ts`

### Networking & Engagement

- [User Matching](https://github.com/jayp927/ai-manthan/blob/main/app/api/users/match/route.ts): `app/api/users/match/route.ts`
- [Connections API](https://github.com/jayp927/ai-manthan/blob/main/app/api/connections/route.ts): `app/api/connections/route.ts`
- [Announcements](https://github.com/jayp927/ai-manthan/blob/main/app/announcements/page.tsx): `app/announcements/page.tsx`
- [Events](https://github.com/jayp927/ai-manthan/blob/main/app/events/page.tsx): `app/events/page.tsx`
- [Leaderboard](https://github.com/jayp927/ai-manthan/blob/main/app/leaderboard/page.tsx): `app/leaderboard/page.tsx`

### Data & AI Services

- [Supabase Access](https://github.com/jayp927/ai-manthan/blob/main/lib/database/clients.ts): `lib/database/clients.ts`
- [Document AI](https://github.com/jayp927/ai-manthan/blob/main/lib/sangam/embeddings.ts): `lib/sangam/embeddings.ts`
- [Gamification Service](https://github.com/jayp927/ai-manthan/blob/main/lib/services/gamification-service.ts): `lib/services/gamification-service.ts`

### Other components

- **Member**

## Connections

- Member → Template Browser: selects template
- Template Browser → Document Generator: requests generation
- Document Generator → Authentication: checks user (evidence: `app/api/generate-document/route.ts`)
- Document Generator → Template Storage: loads template (evidence: `app/api/generate-document/route.ts`)
- Document Generator → Gemini Model: generates content (evidence: `app/api/generate-document/route.ts`)
- Document Generator → Member: returns generated data (evidence: `app/api/generate-document/route.ts`)
- Member → Authentication: authenticates
- Authentication → Supabase Access: loads user (evidence: `app/actions/auth.ts`)
- Member → Community: opens community
- Community → Community Chat: renders chat (evidence: `app/community/page.tsx`)
- Community Chat → Realtime Chat Hook: uses realtime (evidence: `components/community/realtime-chat.tsx`)
- Member → Direct Chat: opens conversation
- Direct Chat → Supabase Access: loads conversation (evidence: `app/chat/[conversationId]/ChatPageClient.tsx`)
- Conversation List → Member: shows conversations
- Member → Messaging API: sends messages
- Community → Sangam Assistant: renders assistant (evidence: `app/community/page.tsx`)
- Sangam Assistant → Sangam Q&A API: asks question
- Sangam Q&A API → Document AI: retrieves knowledge
- Member → User Matching: finds matches
- Member → Connections API: manages connections
- Member → Announcements: views opportunities
- Member → Events: views events
- Member → Leaderboard: views standing
- Leaderboard → Gamification Service: loads stats (evidence: `app/leaderboard/page.tsx`)
- Member → Tenant Context: selects tenant
