# chiragagg5k/cal-buddy architecture

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

- Interactive diagram: https://gitdiagram.com/chiragagg5k/cal-buddy
- Repository: https://github.com/chiragagg5k/cal-buddy

## Overview

##### Main Components

a. Frontend Layer:
- Next.js Application (Client-Side)
- Landing Pages (/src/components/landing/*)
- Authentication Pages (/src/app/(auth)/*)
- Dashboard Interface (/src/app/dashboard)
- Calendar Components (/src/components/calendar/*)
- UI Components (/src/components/ui/*)

b. Backend Layer:
- Next.js API Routes (/src/app/api/*)
- CopilotKit Integration (/src/app/api/copilotkit)
- Authentication System

c. External Services:
- Appwrite (Backend as a Service)
- Google Calendar API
- Groq API (AI Integration)

##### Component Relationships

**[Client Layer] ←→ [Next.js API Routes] ←→ [External Services]**
- ↑                    ↑                       ↑

**[UI Components] ←→ [State Management] ←→ [Service Integrations]**

##### Specific Implementation Details

a. Frontend Architecture:
**[Theme Provider] → [Auth Provider] → [App Layout]**
- ↓              ↓              ↓
**[UI Components] ← [Page Components] → [Calendar Components]**

b. Backend Integration:
**[API Routes] → [Appwrite Client] → [Database]**
- ↓
**[CopilotKit Route] → [Groq API] → [AI Processing]**

c. External Service Integration:
**[Google Calendar API] ← [Calendar Components]**
**[Appwrite Services] ← [Auth Provider]**
**[Groq API] ← [AI Features]**

##### Important Elements to Highlight

- Authentication flow through Appwrite
- Real-time calendar synchronization
- AI-powered task management system
- Theme switching capability
- API integration points

Create distinct sections for:

##### Special Notes

- Separation between authenticated and public routes
- AI-powered features integration
- Demonstrate the calendar synchronization flow
- Error handling and fallback patterns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        Landing["Landing Pages"]
        Dashboard["Dashboard Interface"]
        Calendar["Calendar Components"]
        UI["UI Components"]
        Theme["Theme Provider"]
    end

    subgraph "Application Logic Layer"
        AuthProvider["Auth Provider"]
        StateManagement["State Management"]
        EventsHook["Events Hook"]
        CopilotFeatures["Copilot Features"]
    end

    subgraph "API Layer"
        APIRoutes["API Routes"]
        CopilotRoute["CopilotKit Route"]
    end

    subgraph "External Services"
        AppwriteService["Appwrite"]
        GoogleCalendar["Google Calendar API"]
        GroqAPI["Groq API"]
    end

    %% Relationships
    Landing --> AuthProvider
    Dashboard --> StateManagement
    Calendar --> StateManagement
    UI --> Theme
    
    AuthProvider --> AppwriteService
    StateManagement --> APIRoutes
    EventsHook --> GoogleCalendar
    CopilotFeatures --> CopilotRoute
    
    APIRoutes --> AppwriteService
    CopilotRoute --> GroqAPI
    
    %% Click Events
    click Landing "https://github.com/ChiragAgg5k/cal-buddy/tree/master//src/components/landing/*"
    click Dashboard "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/app/dashboard/page.tsx"
    click Calendar "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/components/calendar/smart-calendar.tsx"
    click UI "https://github.com/ChiragAgg5k/cal-buddy/tree/master//src/components/ui/*"
    click Theme "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/components/context/theme-provider.tsx"
    click AuthProvider "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/components/context/auth-provider.tsx"
    click EventsHook "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/hooks/useEvents.ts"
    click CopilotFeatures "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/hooks/useCopilotFeatures.tsx"
    click CopilotRoute "https://github.com/ChiragAgg5k/cal-buddy/blob/master//src/app/api/copilotkit/route.ts"
    
    %% Styling
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef external fill:#a855f7,color:#fff
    classDef auth fill:#f97316,color:#fff
    
    class Landing,Dashboard,Calendar,UI,Theme frontend
    class APIRoutes,CopilotRoute,StateManagement,EventsHook,CopilotFeatures backend
    class AppwriteService,GoogleCalendar,GroqAPI external
    class AuthProvider auth
```
