# sarankumar1325/tasklyai architecture

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

- Interactive diagram: https://gitdiagram.com/sarankumar1325/tasklyai
- Repository: https://github.com/sarankumar1325/tasklyai

## Overview

##### Project Type and Purpose
- TaskFlowAI is a full-stack, serverless, single-page application (SPA) for AI-powered task management.
- Frontend: React + Vite + TypeScript + Tailwind + shadcn/ui
- Backend-as-a-Service: Supabase (PostgreSQL, real-time, RLS, Edge Functions)
- Authentication: Clerk
- AI Services: Groq Llama 3.3 70B via a Supabase Edge Function

##### File Structure
Top-level layout:
- public/ – static assets and manifest
- src/ – React app
– components/ (ai, auth, layout, tasks, ui, providers)
– pages/ (dashboard, AI chat, task views, settings)
– hooks/ (Supabase tasks, theme, debouncing)
– integrations/supabase (client, types)
– services/groqService.ts (edge function client stub)
– lib/ utilities (performance, Supabase-Clerk glue)
- supabase/ – database migrations, row-level security, Edge Functions (chat-with-tasks)
- config files: vite.config.ts, tailwind.config.ts, vercel.json, tsconfig, etc.

##### README for Architectural Insights
- Frontend communicates directly with:
- Clerk for auth (publishable key, session tokens)
- Supabase client (data CRUD and real-time subscriptions)
- Supabase Edge Function (`/api/chat-with-tasks`) for AI chat
- Edge Function calls Groq AI API using the user’s tasks payload
- Supabase holds the tasks table with RLS policies per user
- Vercel hosts the frontend SPA and rewrites all routes to index.html

a. Main Components
1. Client (Browser SPA)
- React components (pages, UI library)
- State & data layer: TanStack Query, React Hook Form, Zod
2. Authentication Service
- Clerk (hosted, issues JWT/session)
3. BaaS & Database
- Supabase client → PostgreSQL
- Row-Level Security (per-user data isolation)
- Real-time subscriptions
4. Serverless Functions
- Supabase Edge Function: `chat-with-tasks`
5. External AI Service
- Groq AI API (Llama inference)
6. Hosting & Deployment
- Vercel (frontend, environment config)

b. Relationships and Data Flows
- SPA → Clerk: user login/SSO, token exchange
- SPA → Supabase DB: fetch/create/update/delete tasks
- SPA ← real-time updates (task events)
- SPA → Edge Function: POST user message + tasks → returns AI response + stats
- Edge Function → Groq AI API: forward prompt, receive inference
- Groq AI → Edge Function → SPA
- Vercel serves SPA and proxies API requests

c. Architectural Patterns
- Client-Server (SPA + BaaS)
- Serverless (Edge Functions for AI)
- Micro-frontend-style componentization (shadcn/ui + custom modules)
- Real-time pub/sub (Supabase subscriptions)
- CQRS-style separation:
- Queries (TanStack Query fetch)
- Commands (Supabase mutations)

d. Key Technologies & Frameworks
- Frontend: React 18, Vite, TypeScript, Tailwind CSS, shadcn/ui, React Router, TanStack Query, Zod, React Hook Form
- Auth: Clerk
- BaaS/DB: Supabase (PostgreSQL, RLS, real-time)
- Serverless: Supabase Edge Functions (TypeScript)
- AI: Groq Llama 3.3 via HTTP API
- Charts & UI: Recharts, Radix UI primitives, Lucide React, Sonner
- Hosting: Vercel

##### Detail and Coverage
- Include:
- Clerk auth flow before Supabase requests
- Vercel hosting layer wrapping the SPA and environment variables

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier" 
        direction TB
        Client["Browser SPA"]:::frontend
        subgraph "Entry Points" 
            direction TB
            IndexHTML["index.html"]:::frontend
            MainTSX["src/main.tsx"]:::frontend
            AppTSX["src/App.tsx"]:::frontend
        end
        subgraph "Pages" 
            direction TB
            PIndex["Index.tsx"]:::frontend
            PToday["Today.tsx"]:::frontend
            PUpcoming["Upcoming.tsx"]:::frontend
            PImportant["Important.tsx"]:::frontend
            PCompleted["Completed.tsx"]:::frontend
            PArchive["Archive.tsx"]:::frontend
            PAIChat["AIChat.tsx"]:::frontend
            PSettings["Settings.tsx"]:::frontend
            PNotFound["NotFound.tsx"]:::frontend
        end
        subgraph "UI Components" 
            direction TB
            UIComponents["src/components/ui/*"]:::frontend
        end
        subgraph "Feature Components" 
            direction TB
            AIUI["AIChat.tsx"]:::frontend
            TaskList["TaskList.tsx"]:::frontend
            TaskCard["TaskCard.tsx"]:::frontend
            CreateModal["CreateTaskModal.tsx"]:::frontend
            EditModal["EditTaskModal.tsx"]:::frontend
            Header["Header.tsx"]:::frontend
            Sidebar["Sidebar.tsx"]:::frontend
            Footer["Footer.tsx"]:::frontend
            AuthGuard["AuthGuard.tsx"]:::frontend
            ThemeProv["ThemeProvider.tsx"]:::frontend
        end
        subgraph "Hooks & Providers" 
            direction TB
            HookTasks["useSupabaseTasks.ts"]:::frontend
            HookTheme["useTheme.ts"]:::frontend
            HookToast["useToast.ts"]:::frontend
            HookDebounce["useDebounce.ts"]:::frontend
            HookSidebar["useSidebar.ts"]:::frontend
            HookMobile["useMobile.tsx"]:::frontend
        end
        subgraph "Integrations & Lib" 
            direction TB
            SupaClerk["supabase-clerk.ts"]:::frontend
            SupaClient["client.ts"]:::frontend
            SupaTypes["types.ts"]:::frontend
            GroqSvc["groqService.ts"]:::frontend
            PerfUtil["performance.ts"]:::frontend
            Utils["utils.ts"]:::frontend
        end
    end

    %% Cloud Tier
    subgraph "Cloud Tier"
        direction TB
        subgraph "Auth Service"
            Clerk["Clerk (Auth)"]:::auth
        end
        subgraph "BaaS & Database"
            direction TB
            SupabaseClient["Supabase Client"]:::backend
            SupabaseDB["PostgreSQL with RLS"]:::backend
            subgraph "Migrations"
                M1["20250628140115-6b49...sql"]:::backend
                M2["20250629080434-8a44...sql"]:::backend
                M3["20250629081312-c1cf...sql"]:::backend
                M4["20250629090000-opt...sql"]:::backend
                M5["20250629100000-fi...sql"]:::backend
            end
        end
        subgraph "Serverless Functions"
            ChatFunc["chat-with-tasks"]:::backend
        end
        subgraph "AI Service"
            GroqAI["Groq Llama 3.3 API"]:::ai
        end
        Vercel["Vercel Hosting"]:::infra
    end

    %% Connections
    Client -->|"load index.html"| IndexHTML
    IndexHTML --> MainTSX
    MainTSX --> AppTSX
    AppTSX --> PIndex
    AppTSX --> PToday
    AppTSX --> PUpcoming
    AppTSX --> PImportant
    AppTSX --> PCompleted
    AppTSX --> PArchive
    AppTSX --> PAIChat
    AppTSX --> PSettings
    AppTSX --> PNotFound
    PAIChat --> AIUI
    PIndex --> TaskList
    TaskList --> TaskCard
    TaskCard --> CreateModal
    TaskCard --> EditModal
    AppTSX --> Header
    AppTSX --> Sidebar
    AppTSX --> Footer
    AppTSX --> AuthGuard
    AppTSX --> ThemeProv
    AppTSX --> HookTasks
    HookTasks --> SupabaseClient
    AppTSX --> HookTheme
    AppTSX --> HookToast
    AppTSX --> HookDebounce
    AppTSX --> HookSidebar
    AppTSX --> HookMobile
    SupaClerk --> Clerk
    SupabaseClient --> SupabaseDB
    SupabaseClient -->|subscribe| SupabaseDB
    ChatFunc -->|POST /api/chat-with-tasks| GroqAI
    GroqAI -->|response| ChatFunc
    ChatFunc -->|result| AppTSX
    Client --> Clerk
    Client --> SupabaseClient
    Client --> ChatFunc
    Vercel --> Client
    Vercel --> ChatFunc

    %% Click Events
    click IndexHTML "https://github.com/sarankumar1325/tasklyai/blob/main/index.html"
    click MainTSX "https://github.com/sarankumar1325/tasklyai/blob/main/src/main.tsx"
    click AppTSX "https://github.com/sarankumar1325/tasklyai/blob/main/src/App.tsx"
    click PIndex "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Index.tsx"
    click PToday "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Today.tsx"
    click PUpcoming "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Upcoming.tsx"
    click PImportant "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Important.tsx"
    click PCompleted "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Completed.tsx"
    click PArchive "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Archive.tsx"
    click PAIChat "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/AIChat.tsx"
    click PSettings "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/Settings.tsx"
    click PNotFound "https://github.com/sarankumar1325/tasklyai/blob/main/src/pages/NotFound.tsx"
    click UIComponents "https://github.com/sarankumar1325/tasklyai/tree/main/src/components/ui/"
    click AIUI "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/ai/AIChat.tsx"
    click TaskList "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/tasks/TaskList.tsx"
    click TaskCard "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/tasks/TaskCard.tsx"
    click CreateModal "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/tasks/CreateTaskModal.tsx"
    click EditModal "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/tasks/EditTaskModal.tsx"
    click Header "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/layout/Header.tsx"
    click Sidebar "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/layout/Sidebar.tsx"
    click Footer "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/layout/Footer.tsx"
    click AuthGuard "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/auth/AuthGuard.tsx"
    click ThemeProv "https://github.com/sarankumar1325/tasklyai/blob/main/src/components/providers/ThemeProvider.tsx"
    click HookTasks "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useSupabaseTasks.ts"
    click HookTheme "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useTheme.ts"
    click HookToast "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useToast.ts"
    click HookDebounce "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useDebounce.ts"
    click HookSidebar "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useSidebar.ts"
    click HookMobile "https://github.com/sarankumar1325/tasklyai/blob/main/src/hooks/useMobile.tsx"
    click SupaClerk "https://github.com/sarankumar1325/tasklyai/blob/main/src/lib/supabase-clerk.ts"
    click SupaClient "https://github.com/sarankumar1325/tasklyai/blob/main/src/integrations/supabase/client.ts"
    click SupaTypes "https://github.com/sarankumar1325/tasklyai/blob/main/src/integrations/supabase/types.ts"
    click GroqSvc "https://github.com/sarankumar1325/tasklyai/blob/main/src/services/groqService.ts"
    click PerfUtil "https://github.com/sarankumar1325/tasklyai/blob/main/src/lib/performance.ts"
    click Utils "https://github.com/sarankumar1325/tasklyai/blob/main/src/lib/utils.ts"
    click ChatFunc "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/functions/chat-with-tasks/index.ts"
    click GroqAI "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/config.toml"
    click M1 "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/migrations/20250628140115-6b495bd1-5bca-4ee2-b88f-44b7137664f7.sql"
    click M2 "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/migrations/20250629080434-8a444ffe-57d5-442f-a997-6703430cbe68.sql"
    click M3 "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/migrations/20250629081312-c1cf56a8-ab3a-4be3-8989-617cca362e87.sql"
    click M4 "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/migrations/20250629090000-optimize-tasks-table.sql"
    click M5 "https://github.com/sarankumar1325/tasklyai/blob/main/supabase/migrations/20250629100000-fix-rls-and-permissions.sql"
    click Vercel "https://github.com/sarankumar1325/tasklyai/blob/main/vercel.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0B69A3,color:#0B69A3
    classDef backend fill:#DFF7D0,stroke:#4A7C19,color:#4A7C19
    classDef ai fill:#FFE8CC,stroke:#D97706,color:#D97706
    classDef auth fill:#F3D9FF,stroke:#7C3AED,color:#7C3AED
    classDef infra fill:#E5E7EB,stroke:#6B7280,color:#6B7280
```
