# nyahav/budget-tracker-nextjs-ts architecture

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

- Interactive diagram: https://gitdiagram.com/nyahav/budget-tracker-nextjs-ts
- Repository: https://github.com/nyahav/budget-tracker-nextjs-ts

## Overview

##### High-Level Architecture Components

a) Client Layer
- Sub-components:
- Auth Module (from app/(auth))
- Dashboard Module (from app/(dashboard))
- Wizard Module (from app/wizard)
- UI Components Layer (from components/ui)

b) API Layer
- Endpoints:
- Categories API
- History Data API
- Stats API
- User Settings API

c) Database Layer
- Main data models (visible in prisma/schema.prisma)

##### Component Relationships

a) Client-Server Communication
- Data fetching flows
- Authentication flows
- Real-time updates (if any)

b) Server-Database Communication
- CRUD operations

##### Specific Implementation Details

a) Authentication Flow
- Sign-in/Sign-up processes
- Protected routes (middleware.ts)

b) State Management
- Client-side data flow
- Server actions (from _actions directories)

##### Technical Stack Indicators

- Next.js 14 (App Router)
- Prisma ORM
- SQLite Database
- ShadcnUI Components
- TypeScript

##### Key Architectural Patterns

Highlight:
- Server Components vs Client Components
- API Route Structure
- Data Flow Patterns

##### API route structure

This will provide a clear understanding of both the overall architecture and specific implementation details while maintaining readability.

Remember to emphasize:
- Next.js App Router architecture
- Server Components pattern
- API route organization
- Database interaction through Prisma
- Authentication flow
- Component hierarchy

This approach will give a comprehensive view of the application's architecture while maintaining clarity and providing necessary technical detail for implementation understanding.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Frontend (Next.js App)"]
        direction TB
        Auth["Authentication Module"]
        Dashboard["Dashboard Module"]
        Wizard["Wizard Module"]
        UI["UI Components Layer"]
        
        subgraph DashboardComponents["Dashboard Components"]
            Overview["Overview"]
            History["History View"]
            StatsCards["Stats Cards"]
            CategoriesStats["Categories Stats"]
        end
        
        Dashboard --> DashboardComponents
    end
    
    subgraph APILayer["API Routes Layer"]
        CategoriesAPI["Categories API"]
        HistoryAPI["History Data API"]
        StatsAPI["Stats API"]
        SettingsAPI["User Settings API"]
    end
    
    subgraph DBLayer["Database Layer"]
        Prisma["Prisma ORM"]
        SQLite["SQLite Database"]
        Schema["Database Schema"]
    end
    
    subgraph Utils["Utility Layer"]
        Helpers["Helpers"]
        Constants["Constants"]
        Types["Types"]
        Hooks["Custom Hooks"]
    end
    
    Auth --> APILayer
    Dashboard --> APILayer
    Wizard --> APILayer
    APILayer --> Prisma
    Prisma --> SQLite
    
    classDef frontend fill:#3b82f6,color:#fff
    classDef api fill:#22c55e,color:#fff
    classDef database fill:#a855f7,color:#fff
    classDef utils fill:#94a3b8,color:#fff
    
    class Auth,Dashboard,Wizard,UI,DashboardComponents,Overview,History,StatsCards,CategoriesStats frontend
    class CategoriesAPI,HistoryAPI,StatsAPI,SettingsAPI api
    class Prisma,SQLite,Schema database
    class Helpers,Constants,Types,Hooks utils
    
    click Auth "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/app/(auth)"
    click Dashboard "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/app/(dashboard)"
    click Wizard "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/app/wizard"
    click UI "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/components/ui"
    click CategoriesAPI "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/api/categories/route.ts"
    click HistoryAPI "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/api/history-data/route.ts"
    click StatsAPI "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/app/api/stats"
    click SettingsAPI "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/api/user-settings/route.ts"
    click Prisma "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/lib/prisma.ts"
    click Schema "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/prisma/schema.prisma"
    click SQLite "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/prisma/dev.db"
    click Overview "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/(dashboard)/_components/Overview.tsx"
    click History "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/(dashboard)/_components/History.tsx"
    click StatsCards "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/(dashboard)/_components/StatsCards.tsx"
    click CategoriesStats "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/app/(dashboard)/_components/CategoriesStats.tsx"
    click Helpers "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/lib/helpers.ts"
    click Constants "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/lib/constans.ts"
    click Types "https://github.com/nyahav/Budget-Tracker-NextJS-TS/blob/main/lib/types.ts"
    click Hooks "https://github.com/nyahav/Budget-Tracker-NextJS-TS/tree/main/hooks"
```
