# willianba/expenso architecture

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

- Interactive diagram: https://gitdiagram.com/willianba/expenso
- Repository: https://github.com/willianba/expenso

## Overview

Project Type: Full-stack web application for expense tracking using Deno's Fresh framework and Deno KV as the database.

##### Connection Flows

- User authentication flow (auth plugins → GitHub/Google)
- Data flow between frontend and API endpoints
- Database operations flow
- Signal management (from /signals directory)

##### Component Grouping

Related components:
- Expense management (ExpenseForm, ExpensesTable, expense API routes)
- Income management (IncomeForm, IncomeTable, income API routes)
- Authentication (AuthButton, auth plugins, GitHub/Google integration)
- Database models (category, expense, income, payment-method, user)

##### Technical Details

Annotations for:
- Database migrations system
- Environment configuration
- API endpoints structure
- Frontend-backend communication patterns

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        direction TB
        SC[Static Components]
        IC[Interactive Components]
        RT[Routes]

        subgraph "Static Components"
            direction TB
            NB["Navigation Bar"]:::frontend
            LE["Layout Elements"]:::frontend
        end

        subgraph "Interactive Islands"
            direction TB
            EF["Expense Form"]:::frontend
            ET["Expenses Table"]:::frontend
            IF["Income Form"]:::frontend
            IT["Income Table"]:::frontend
            AB["Auth Button"]:::frontend
        end

        subgraph "Route Handlers"
            direction TB
            APP["App Route"]:::frontend
            LOGIN["Login Route"]:::frontend
            MAIN["Main Route"]:::frontend
        end
    end

    subgraph Middleware
        direction TB
        AUTH["Authentication"]:::middleware
        SESS["Session Management"]:::middleware
        ERR["Error Handling"]:::middleware
    end

    subgraph "Backend"
        direction TB
        subgraph "API Routes"
            direction TB
            EXP_API["/api/expenses"]:::api
            INC_API["/api/income"]:::api
        end

        subgraph "Database Models"
            direction TB
            USER_M["User Model"]:::db
            EXP_M["Expense Model"]:::db
            INC_M["Income Model"]:::db
            CAT_M["Category Model"]:::db
            PAY_M["Payment Method Model"]:::db
        end

        KV[("Deno KV Storage")]:::db
    end

    subgraph "State Management"
        direction TB
        EXP_S["Expense Signals"]:::state
        INC_S["Income Signals"]:::state
        INP_S["Input Signals"]:::state
        MENU_S["Menu Signals"]:::state
    end

    subgraph "Auth Providers"
        direction TB
        GH["GitHub"]:::auth
        GO["Google"]:::auth
    end

    %% Connections
    NB --> MAIN
    EF --> EXP_API
    IF --> INC_API
    ET --> EXP_API
    IT --> INC_API
    AB --> AUTH
    AUTH --> GH
    AUTH --> GO
    EXP_API --> KV
    INC_API --> KV
    EXP_API --> EXP_M
    INC_API --> INC_M
    EXP_S --> EF
    INC_S --> IF
    MENU_S --> NB

    %% Click Events
    click NB "https://github.com/willianba/expenso/blob/master/components/NavBar.tsx"
    click LE "https://github.com/willianba/expenso/blob/master/components/Container.tsx"
    click EF "https://github.com/willianba/expenso/blob/master/islands/forms/ExpenseForm.tsx"
    click ET "https://github.com/willianba/expenso/blob/master/islands/tables/ExpensesTable.tsx"
    click IF "https://github.com/willianba/expenso/blob/master/islands/forms/IncomeForm.tsx"
    click IT "https://github.com/willianba/expenso/blob/master/islands/tables/IncomeTable.tsx"
    click AB "https://github.com/willianba/expenso/blob/master/islands/AuthButton.tsx"
    click APP "https://github.com/willianba/expenso/blob/master/routes/_app.tsx"
    click LOGIN "https://github.com/willianba/expenso/blob/master/routes/login.tsx"
    click MAIN "https://github.com/willianba/expenso/blob/master/routes/app.tsx"
    click AUTH "https://github.com/willianba/expenso/blob/master/plugins/auth.ts"
    click SESS "https://github.com/willianba/expenso/blob/master/plugins/session.ts"
    click ERR "https://github.com/willianba/expenso/blob/master/plugins/error-handling.ts"
    click USER_M "https://github.com/willianba/expenso/blob/master/db/models/user.ts"
    click EXP_M "https://github.com/willianba/expenso/blob/master/db/models/expense.ts"
    click INC_M "https://github.com/willianba/expenso/blob/master/db/models/income.ts"
    click CAT_M "https://github.com/willianba/expenso/blob/master/db/models/category.ts"
    click PAY_M "https://github.com/willianba/expenso/blob/master/db/models/payment-method.ts"
    click GH "https://github.com/willianba/expenso/blob/master/utils/auth/github.ts"
    click GO "https://github.com/willianba/expenso/blob/master/utils/auth/google.ts"
    click EXP_S "https://github.com/willianba/expenso/blob/master/signals/expenses.ts"
    click INC_S "https://github.com/willianba/expenso/blob/master/signals/income.ts"
    click INP_S "https://github.com/willianba/expenso/blob/master/signals/input-data.ts"
    click MENU_S "https://github.com/willianba/expenso/blob/master/signals/menu.ts"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef middleware fill:#e74c3c,stroke:#c0392b,color:white
    classDef db fill:#9b59b6,stroke:#8e44ad,color:white
    classDef state fill:#f1c40f,stroke:#f39c12,color:black
    classDef auth fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        A[API]:::api
        M[Middleware]:::middleware
        D[Database]:::db
        S[State]:::state
        AU[Auth]:::auth
    end
```
