# devnik14/budget-buddy-ai architecture

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

- Interactive diagram: https://gitdiagram.com/devnik14/budget-buddy-ai
- Repository: https://github.com/devnik14/budget-buddy-ai

## Overview

##### Main Application Architecture

a) Frontend Layer (React + TypeScript)
- Use Vite as the build tool/development server
- Firebase integration for authentication/backend services

##### Component Structure
Frontend architecture into these logical groups:

a) Core Application Components:
- Layout/Router Layer
- Authentication Layer (Firebase Auth)
- Context Providers (AuthContext)

b) Feature Modules:
- Dashboard
- Budget
- Transactions
- Advisor
- User Settings

##### UI Component Library
- Navigation Components (LargeScreenNav, MobileNavigation, SideNavigation)
- Form Components (Input, Button, Form)
- Common UI Elements (Card, Avatar, Sheet)

##### Data Flow and State Management
- Firebase Authentication flow
- Context API state management
- Component hierarchy and composition

**[Visual Hierarchy]**

**Top Level:**
**┌─ Client Application (React + TypeScript + Vite)**
- Authentication Layer (Firebase)
- Routing Layer
- Feature Modules

**Component Level:**
**┌─ Shared UI Components**
- Page Components
- Context Providers

##### Connection Types
- Double lines: Context boundaries

##### Special Notations
- Security shields for auth-protected routes

Key Architectural Patterns to Highlight:

##### Component-Based Architecture
- Hierarchy of components
- Reusable UI components
- Page composition

##### Authentication Flow
- Firebase authentication integration
- Protected routes
- User session management

##### Responsive Design Strategy
- Mobile/Desktop navigation variants
- Adaptive layout components

##### State Management
- Context API implementation
- Local state management
- Form state handling

Additional Considerations:

##### Development Tools
- Vite's HMR capability
- TypeScript type checking
- ESLint integration

##### Error Handling
- Error boundary implementation
- Auth error management
- Form validation flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application (React + TypeScript)"]
        Main["Main Entry"]:::core
        App["App Root"]:::core
        click Main "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/main.tsx"
        click App "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/App.tsx"

        subgraph Auth["Authentication Layer"]
            Firebase["Firebase Config"]:::auth
            AuthContext["Auth Context"]:::auth
            Login["Login Form"]:::auth
            Register["Register Form"]:::auth
            click Firebase "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/config/firebase.ts"
            click AuthContext "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/contexts/authContext.tsx"
            click Login "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Login/LoginForm.tsx"
            click Register "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Register/RegisterForm.tsx"
        end

        subgraph Layout["Layout/Router Layer"]
            MainLayout["Main Layout"]:::layout
            click MainLayout "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Layout/Layout.tsx"
        end

        subgraph Features["Feature Modules"]
            Dashboard["Dashboard"]:::feature
            Budget["Budget"]:::feature
            Transactions["Transactions"]:::feature
            Advisor["Advisor"]:::feature
            UserSettings["User Settings"]:::feature
            click Dashboard "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Dashboard/Dashboard.tsx"
            click Budget "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Budget/Budget.tsx"
            click Transactions "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Transactions/Transactions.tsx"
            click Advisor "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/Advisor/Advisor.tsx"
            click UserSettings "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/pages/UserSettings/UserSettings.tsx"
        end

        subgraph UI["UI Components"]
            subgraph Nav["Navigation Components"]
                LargeNav["Large Screen Nav"]:::ui
                MobileNav["Mobile Navigation"]:::ui
                SideNav["Side Navigation"]:::ui
                NavAvatar["Nav Avatar"]:::ui
                click LargeNav "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/LargeScreenNav.tsx"
                click MobileNav "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/MobileNavigation.tsx"
                click SideNav "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/SideNavigation.tsx"
                click NavAvatar "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/NavAvatar.tsx"
            end

            subgraph Forms["Form Components"]
                Input["Input"]:::ui
                Button["Button"]:::ui
                Form["Form"]:::ui
                click Input "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/input.tsx"
                click Button "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/button.tsx"
                click Form "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/form.tsx"
            end

            subgraph Common["Common UI Elements"]
                Card["Card"]:::ui
                Avatar["Avatar"]:::ui
                Sheet["Sheet"]:::ui
                ErrorMsg["Error Messages"]:::ui
                click Card "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/card.tsx"
                click Avatar "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/avatar.tsx"
                click Sheet "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/sheet.tsx"
                click ErrorMsg "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/components/ui/ErrorAuthMessage.tsx"
            end
        end

        subgraph Utils["Utilities"]
            UtilsLib["Utils"]:::util
            ErrorFormat["Error Formatting"]:::util
            click UtilsLib "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/lib/utils.ts"
            click ErrorFormat "https://github.com/DevNik14/budget-buddy-ai/blob/main/src/utils/formatErrorMessage.ts"
        end
    end

    %% Relationships
    Main --> App
    App --> AuthContext
    App --> MainLayout
    MainLayout --> Features
    MainLayout --> Nav
    Auth --> Features
    Features --> Forms
    Features --> Common
    Forms --> Common

    %% Styles
    classDef core fill:#2563eb,color:white
    classDef auth fill:#9333ea,color:white
    classDef layout fill:#0891b2,color:white
    classDef feature fill:#16a34a,color:white
    classDef ui fill:#ea580c,color:white
    classDef util fill:#64748b,color:white

    %% Legend
    subgraph Legend
        CoreL["Core Components"]:::core
        AuthL["Authentication"]:::auth
        LayoutL["Layout"]:::layout
        FeatureL["Features"]:::feature
        UIL["UI Components"]:::ui
        UtilL["Utilities"]:::util
    end
```
