# sarthakischauhan/groovy architecture

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

- Interactive diagram: https://gitdiagram.com/sarthakischauhan/groovy
- Repository: https://github.com/sarthakischauhan/groovy

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend (React-based)
- UI Components Library
- Authentication Interface
- Client-side State Management

b) Server Layer:
- Next.js API Routes
- Authentication Service
- Middleware

c) Data Layer:
- Supabase Database
- External Services (Future Apple Pay/Wallet integration)

**[Client Layer]**
- ↕
**[Server Layer]**
- ↕
**[Data Layer]**

##### Connection Flows

- Authentication flow (Client → NextAuth → Supabase)
- Data operations flow (Client → API Routes → Supabase)
- Protected route flow (Middleware → Auth Check)

##### Important Details

Annotations for:
- TailwindCSS styling system
- Next.js 13+ App Router architecture
- Supabase real-time capabilities
- Protected vs public routes
- State management flow

##### Future Integration Points

Clearly:
- Apple Pay/Wallet integration point
- Analytics/Infographics module
- Income tracking module

##### The planned integration points for future features

Remember to indicate the real-time nature of the expense tracking features and how they interact with the Supabase backend, as this is crucial for the application's core functionality.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Frontend["Next.js Frontend"]
        UI["UI Components"]:::frontend
        Auth["Authentication Interface"]:::frontend
        ExpMgmt["Expense Management"]:::frontend
        Onboard["Onboarding Flow"]:::frontend
        Nav["Navigation"]:::frontend
        Layout["Core Layout"]:::frontend
        Login["Login Page"]:::frontend
        MgmtHeader["Management Interface"]:::frontend
    end

    subgraph Server
        API["Next.js API Routes"]:::server
        NextAuth["NextAuth Service"]:::auth
        Middleware["Route Protection"]:::server
        AuthUtils["Auth Utilities"]:::server
    end

    subgraph Data
        Supabase["Supabase Database"]:::database
        AuthStore["Authentication Store"]:::database
        ApplePay["Apple Pay Integration"]:::planned
    end

    subgraph Utilities
        Hooks["Custom Hooks"]:::util
        Types["Type Definitions"]:::util
        Utils["Utility Functions"]:::util
        AuthContext["Auth Context"]:::util
    end

    Frontend --> API
    Frontend --> NextAuth
    API --> Supabase
    NextAuth --> AuthStore
    Middleware --> NextAuth
    AuthUtils --> AuthStore
    AuthContext --> AuthUtils
    Frontend --> Hooks
    Frontend --> Types
    API --> Utils

    %% Click Events
    click UI "https://github.com/Sarthakischauhan/groovy/tree/main/app/components/ui/"
    click Auth "https://github.com/Sarthakischauhan/groovy/blob/main/app/components/Signin.tsx"
    click ExpMgmt "https://github.com/Sarthakischauhan/groovy/tree/main/app/components/ExpenseTable/"
    click Onboard "https://github.com/Sarthakischauhan/groovy/tree/main/app/onboard/"
    click NextAuth "https://github.com/Sarthakischauhan/groovy/blob/main/app/api/auth/[...nextauth]/route.ts"
    click Middleware "https://github.com/Sarthakischauhan/groovy/blob/main/middleware.ts"
    click Supabase "https://github.com/Sarthakischauhan/groovy/blob/main/utils/supabase.ts"
    click AuthUtils "https://github.com/Sarthakischauhan/groovy/blob/main/utils/auth.ts"
    click AuthContext "https://github.com/Sarthakischauhan/groovy/blob/main/utils/authContext.tsx"
    click Hooks "https://github.com/Sarthakischauhan/groovy/tree/main/app/hooks/"
    click Types "https://github.com/Sarthakischauhan/groovy/tree/main/app/types/"
    click Nav "https://github.com/Sarthakischauhan/groovy/blob/main/app/components/Navbar/Navbar.tsx"
    click Layout "https://github.com/Sarthakischauhan/groovy/blob/main/app/layout.tsx"
    click Login "https://github.com/Sarthakischauhan/groovy/blob/main/app/login/page.tsx"
    click MgmtHeader "https://github.com/Sarthakischauhan/groovy/blob/main/app/components/ManagementHeader.tsx"
    click Utils "https://github.com/Sarthakischauhan/groovy/blob/main/lib/utils.ts"

    %% Styles
    classDef frontend fill:#3b82f6,color:white
    classDef server fill:#22c55e,color:white
    classDef database fill:#eab308,color:black
    classDef auth fill:#ef4444,color:white
    classDef util fill:#6b7280,color:white
    classDef planned fill:#a855f7,color:white,stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Server_L["Server"]:::server
        Database_L["Database"]:::database
        Auth_L["Authentication"]:::auth
        Util_L["Utilities"]:::util
        Planned_L["Planned"]:::planned
    end
```
