# ahmadkhan100/money-mapper architecture

> Architecture diagram of the GitHub repository ahmadkhan100/money-mapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmadkhan100/money-mapper
- Repository: https://github.com/ahmadkhan100/money-mapper

## Overview

##### Main Components

A. Frontend Layer:
- Client-side Components (app directory structure)
- UI Components (shadcn-ui)
- State Management (Zustand)
- Data Visualization (Recharts)

B. Backend Layer:
- API Routes (Next.js API)
- Authentication System (NextAuth.js)
- Database Layer (Prisma + MongoDB)

**┌─ Client Layer ─────────────────────┐**
- Pages (/, /dashboard, /money)    │
- Components                       │
- Client-side State (Zustand)     │
- Charts (Recharts)               │
- ┬───────────────────┘
- ↕
**┌─ Server Layer ─────────────────────┐**
- Next.js API Routes              │
- Authentication (NextAuth.js)     │
- Form Validation (Zod)           │
- ┬───────────────────┘
- ↕
**┌─ Data Layer ──────────────────────┐**
- Prisma ORM                      │
- MongoDB Database                │
- ┘

##### Detailed Component Relationships

- Frontend pages and API routes
- API routes and database
- Authentication flow between client, NextAuth, and OAuth providers
- State management interactions

##### Key Elements to Highlight

A. Frontend Architecture:
- Relationship between pages (/dashboard, /money)
- Component hierarchy
- State management flow
- Theme switching mechanism

B. API Layer:
- Financial records CRUD operations
- Authentication endpoints
- Data validation flow

C. Data Layer:
- Database schema representation
- Prisma ORM interaction
- Data models for financial records

##### Implementation Notes

- Lucidchart
- PlantUML

- High-level architecture visibility
- Detailed component relationships
- Clear data flow paths
- System boundaries

##### Special Features to Highlight

- Dark/light theme switching mechanism
- Financial data visualization pipeline
- CRUD operations flow
- Authentication process

Remember to:
- Use consistent naming conventions
- Brief descriptions for complex interactions
- Error handling paths
- Security boundaries

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Pages["Pages"]
        UI["UI Components"]
        State["State Management (Zustand)"]
        Charts["Data Visualization"]
        
        subgraph Pages
            Home["Home Page"]:::page
            Dashboard["Dashboard"]:::page
            Money["Money Management"]:::page
        end
        
        subgraph UI
            NavComp["Navigation"]:::component
            ThemeToggle["Theme Toggle"]:::component
            UserAccount["User Account"]:::component
            Forms["Forms"]:::component
        end
        
        subgraph Charts
            BarChart["Bar Chart"]:::chart
            DashCharts["Dashboard Charts"]:::chart
            ChartContainer["Chart Container"]:::chart
        end
    end
    
    subgraph Server
        API["API Routes"]
        Auth["Authentication"]
        Validation["Form Validation (Zod)"]
        
        subgraph API
            FinancialAPI["Financial Records API"]:::api
            RecordAPI["Individual Record API"]:::api
        end
        
        subgraph Auth
            NextAuth["NextAuth.js"]:::auth
            AuthForm["Auth Form"]:::auth
            AuthActions["Auth Actions"]:::auth
        end
    end
    
    subgraph Data
        Prisma["Prisma ORM"]:::db
        MongoDB["MongoDB"]:::db
        Schema["Database Schema"]:::db
    end
    
    %% Relationships
    Pages --> API
    UI --> State
    Charts --> API
    API --> Prisma
    Prisma --> MongoDB
    Auth --> API
    Forms --> Validation
    Validation --> API
    
    %% Styling
    classDef page fill:#2563eb,color:white
    classDef component fill:#3b82f6,color:white
    classDef chart fill:#60a5fa,color:white
    classDef api fill:#22c55e,color:white
    classDef auth fill:#a855f7,color:white
    classDef db fill:#eab308,color:black
    
    %% Click Events
    click Home "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/(site)/page.tsx"
    click Dashboard "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/dashboard/page.tsx"
    click Money "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/money/page.tsx"
    click NavComp "https://github.com/ahmadkhan100/Money-Mapper/blob/master/components/Nav/Nav.tsx"
    click ThemeToggle "https://github.com/ahmadkhan100/Money-Mapper/blob/master/components/Nav/ThemeToggle.tsx"
    click UserAccount "https://github.com/ahmadkhan100/Money-Mapper/blob/master/components/Nav/UserAccountNav.tsx"
    click BarChart "https://github.com/ahmadkhan100/Money-Mapper/blob/master/components/Charts/BarChart.tsx"
    click DashCharts "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/dashboard/components/Charts.tsx"
    click ChartContainer "https://github.com/ahmadkhan100/Money-Mapper/blob/master/components/Charts/ChartContainer.tsx"
    click NextAuth "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/api/auth/[...nextauth]/route.ts"
    click AuthForm "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/(site)/components/AuthForm.tsx"
    click AuthActions "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/actions/auth.ts"
    click FinancialAPI "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/api/financial-records/route.ts"
    click RecordAPI "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/api/financial-records/[id]/route.ts"
    click Prisma "https://github.com/ahmadkhan100/Money-Mapper/blob/master/prisma/schema.prisma"
    click Forms "https://github.com/ahmadkhan100/Money-Mapper/blob/master/app/money/components/CreateFinancialRecordForm.tsx"
```
