# jlaikows/tip-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/jlaikows/tip-tracker
- Repository: https://github.com/jlaikows/tip-tracker

## Overview

##### Main Components

Frontend Layer:
- Next.js App Router Structure
- Client-Side Components (/src/lib/components)
- Custom Hooks Layer (/src/lib/hooks)
- Type Definitions Layer (/src/lib/types)

Backend Layer:
- API Routes (/src/app/api)
- Database Layer (Prisma ORM)
- Authentication System
- Session Management

##### Key Architectural Elements

**┌─ Client Layer ─────────────────────┐**
- Dashboard                        │
- Login/Signup                     │
- Client Management                │
- Invoice Management               │
- Payout Management               │
- ┬────────────────────┘
- ↓
**┌─ API Layer ──────────────────────┐**
- /api/clients                   │
- /api/invoices                  │
- /api/payouts                   │
- /api/users                     │
- ┬──────────────────┘
- ↓
**┌─ Database Layer ──────────────────┐**
- Users                          │
- Clients                        │
- Payouts                        │
- Invoices                       │
- Sessions                       │
- ┘

##### Important Relationships

- Relationship between Prisma schema and API routes
- Authentication flow from login/signup through the session management
- Demonstrate the relationship between invoices and payouts

##### Additional Elements

- A section showing the authentication flow
- Document the data flow for key operations (e.g., invoice creation)
- Relationship between clients and their associated payouts/invoices

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef component fill:#9b59b6,stroke:#8e44ad,color:white

    %% Frontend Layer
    subgraph Frontend
        Dashboard["Dashboard"]:::frontend
        Login["Login System"]:::frontend
        Signup["Signup System"]:::frontend
        ClientUI["Client Management UI"]:::frontend
        InvoiceUI["Invoice Management UI"]:::frontend
        PayoutUI["Payout Management UI"]:::frontend
        NavBar["Navigation Bar"]:::frontend
        
        subgraph Forms
            InvoiceForm["Invoice Creation Form"]:::component
            PayoutForm["Payout Creation Form"]:::component
            ClientForm["Client Creation Form"]:::component
        end
    end

    %% API Layer
    subgraph API
        ClientAPI["Clients API"]:::api
        InvoiceAPI["Invoices API"]:::api
        PayoutAPI["Payouts API"]:::api
        UserAPI["Users API"]:::api
        SignupAPI["Signup API"]:::auth
    end

    %% Database Layer
    subgraph Database
        DB[(Prisma Database)]:::database
        Users[("Users")]:::database
        Clients[("Clients")]:::database
        Invoices[("Invoices")]:::database
        Payouts[("Payouts")]:::database
        Sessions[("Sessions")]:::database
    end

    %% Relationships
    Dashboard --> NavBar
    ClientUI --> ClientAPI
    InvoiceUI --> InvoiceAPI
    PayoutUI --> PayoutAPI
    Login --> UserAPI
    Signup --> SignupAPI

    ClientForm --> ClientAPI
    InvoiceForm --> InvoiceAPI
    PayoutForm --> PayoutAPI

    ClientAPI --> DB
    InvoiceAPI --> DB
    PayoutAPI --> DB
    UserAPI --> DB
    SignupAPI --> DB

    DB --> Users
    DB --> Clients
    DB --> Invoices
    DB --> Payouts
    DB --> Sessions

    %% Click Events
    click Dashboard "https://github.com/JLaikows/tip-tracker/blob/main/src/app/dashboard/page.tsx"
    click Login "https://github.com/JLaikows/tip-tracker/blob/main/src/app/login/page.tsx"
    click Signup "https://github.com/JLaikows/tip-tracker/blob/main/src/app/signup/page.tsx"
    click ClientUI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/dashboard/clients/page.tsx"
    click InvoiceUI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/dashboard/invoices/page.tsx"
    click PayoutUI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/dashboard/payouts/page.tsx"
    click NavBar "https://github.com/JLaikows/tip-tracker/blob/main/src/lib/components/NavBar.tsx"
    click InvoiceForm "https://github.com/JLaikows/tip-tracker/blob/main/src/lib/components/Forms/InvoiceCreateForm.tsx"
    click PayoutForm "https://github.com/JLaikows/tip-tracker/blob/main/src/lib/components/Forms/PayoutCreateForm.tsx"
    click ClientForm "https://github.com/JLaikows/tip-tracker/blob/main/src/lib/components/ClientCreateForm.tsx"
    click ClientAPI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/api/clients/route.ts"
    click InvoiceAPI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/api/invoices/route.ts"
    click PayoutAPI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/api/payouts/route.ts"
    click UserAPI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/api/users/route.ts"
    click SignupAPI "https://github.com/JLaikows/tip-tracker/blob/main/src/app/api/users/signup/route.ts"
    click DB "https://github.com/JLaikows/tip-tracker/blob/main/prisma/schema.prisma"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        API_L["API"]:::api
        DB_L["Database"]:::database
        Auth_L["Auth"]:::auth
        Component_L["Component"]:::component
    end
```
