# hemanthgirimath/text_to_sql_lanchain architecture

> Architecture diagram of the GitHub repository hemanthgirimath/text_to_sql_lanchain, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hemanthgirimath/text_to_sql_lanchain
- Repository: https://github.com/hemanthgirimath/text_to_sql_lanchain

## Overview

##### Main Components

Frontend Layer:
- Next.js Application (Client-Side)
- Pages (/, /chat, /sign-in, /sign-up, /profile)
- Components (UI components, Navigation, Sidebar)
- Hooks (Authentication, Mobile responsiveness)

Backend Layer:
- Next.js API Routes
- Groq Integration (/api/groq)
- Supabase Authentication
- Server-Side Components

External Services:
- Supabase (Authentication & Database)
- Groq (AI/ML Service)

**[Client Layer]**
- ↕
**[Server Layer]**
- ↕
**[External Services]**

##### Detailed Component Breakdown

Client Layer (Blue):
- A UI Components section showing shared components
- A Hooks section showing authentication and utility hooks

Server Layer (Green):
- Next.js API Routes section
- Groq integration endpoint
- Server-side rendering flow

External Services (Purple):
- Supabase Authentication
- Groq AI Service
- Database (if applicable)

##### Connection Flows

- Authentication flow between client and Supabase
- API requests between client and server
- Data flow between server and Groq
- Server-side rendering paths

##### Technical Details

Annotations for:
- Next.js 13+ App Router
- API Routes
- Authentication Context
- Supabase Client
- Groq Integration

##### Additional Notes

- Version information for major dependencies
- Error handling flows
- Real-time functionality if present
- Development vs production configurations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Pages["Pages"]
        Pages --> Home["Home Page"]:::page
        Pages --> Chat["Chat Page"]:::page
        Pages --> SignIn["Sign In Page"]:::page
        Pages --> SignUp["Sign Up Page"]:::page
        Pages --> Profile["Profile Page"]:::page

        UI["UI Components"]
        UI --> Button["Button"]:::component
        UI --> Input["Input"]:::component
        UI --> Toast["Toast"]:::component
        UI --> Avatar["Avatar"]:::component
        UI --> Card["Card"]:::component
        UI --> Dialog["Dialog"]:::component

        Layout["Layout Components"]
        Layout --> Nav["Navigation Wrapper"]:::component
        Layout --> Sidebar["Sidebar"]:::component
        Layout --> RecentChats["Recent Chats"]:::component
        Layout --> ThemeProvider["Theme Provider"]:::component

        Hooks["Utility Hooks"]
        Hooks --> MobileHook["Mobile Hook"]:::util
        Hooks --> UserHook["User Hook"]:::util
        Hooks --> Utils["Utilities"]:::util
    end

    subgraph Server
        API["API Routes"]
        API --> GroqRoute["Groq API Route"]:::api
        
        Auth["Authentication System"]
        Auth --> SupabaseClient["Supabase Client"]:::auth
        Auth --> AuthContext["Auth Context"]:::auth
        Auth --> ProtectedRoute["Protected Route"]:::auth

        ServerComponents["Server Components"]
        ServerComponents --> RootLayout["Root Layout"]:::server
        ServerComponents --> GlobalStyles["Global Styles"]:::server
    end

    subgraph External
        Supabase[(Supabase)]:::external
        Groq["Groq AI Service"]:::external
    end

    Auth --> Supabase
    GroqRoute --> Groq
    Pages --> Auth
    Pages --> API

    %% Click Events
    click Home "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/page.tsx"
    click Chat "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/chat/page.tsx"
    click SignIn "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/sign-in/page.tsx"
    click SignUp "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/sign-up/page.tsx"
    click Profile "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/profile/page.tsx"
    click Button "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/button.tsx"
    click Input "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/input.tsx"
    click Toast "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/toast.tsx"
    click Avatar "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/avatar.tsx"
    click Card "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/card.tsx"
    click Dialog "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/ui/alert-dialog.tsx"
    click Nav "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/navigation-wrapper.tsx"
    click Sidebar "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/sidebar/sidebar.tsx"
    click RecentChats "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/sidebar/recent-chats.tsx"
    click ThemeProvider "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/theme-provider.tsx"
    click MobileHook "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/hooks/use-modbile.ts"
    click UserHook "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/hooks/useUser.ts"
    click Utils "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/lib/utils.ts"
    click GroqRoute "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/api/groq/route.ts"
    click SupabaseClient "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/auth/supabase-client.ts"
    click AuthContext "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/auth/useAuthContext.ts"
    click ProtectedRoute "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/components/protected-route.tsx"
    click RootLayout "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/layout.tsx"
    click GlobalStyles "https://github.com/HemanthGirimath/text_to_sql_lanchain/blob/main/src/app/globals.css"

    %% Styling
    classDef page fill:#2563eb,color:white
    classDef component fill:#3b82f6,color:white
    classDef util fill:#60a5fa,color:white
    classDef api fill:#22c55e,color:white
    classDef auth fill:#f97316,color:white
    classDef server fill:#84cc16,color:white
    classDef external fill:#a855f7,color:white

    %% Legend
    subgraph Legend
        L1["Page"]:::page
        L2["Component"]:::component
        L3["Utility"]:::util
        L4["API"]:::api
        L5["Auth"]:::auth
        L6["Server"]:::server
        L7["External"]:::external
    end
```
