# imzodev/gemini-presupuesto-voz architecture

> Architecture diagram of the GitHub repository imzodev/gemini-presupuesto-voz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imzodev/gemini-presupuesto-voz
- Repository: https://github.com/imzodev/gemini-presupuesto-voz

## Overview

##### Project Overview
- This is a full-stack budget tracking application that uses React, TypeScript, and Vite for the frontend, and a Node.js–powered backend (written in TypeScript) that serves APIs and handles database operations.
- The application leverages an SQLite database (budget.db) for persistence and integrates with Google’s Gemini AI API for voice command and reporting capabilities.

##### Main Components
a. Frontend:
- Represented by the “src” directory, it includes:
- React components (e.g., CategoriesTable, Dashboard, DashboardCharts, etc.).
- API calls (in src/api/budgetApi.ts) that likely interact with the backend.
- Application pages (in src/pages) and context management (src/contexts).
- Styling and utility modules.
- Use Vite (as seen from vite.config.ts) as the build tool.

b. Backend:
- Represented by the “server” directory which includes:
- The main server file (server/index.ts) which likely sets up routes and middleware.
- A “db” subdirectory containing database connection and operations (database.ts and operations.ts).
- The backend serves as the API layer for the frontend and interacts with both the SQLite database and the external Gemini API.

c. Database:
- The “budget.db” file is an SQLite database used by the backend to store expense and income data.

d. External Services:
- Google Gemini AI is used for voice command processing. Indicate an external API component (along with the integration key set in the .env) that interacts with the Gemini API.

##### Relationships and Data Flow
- From the Frontend to the Backend: API calls for submitting transactions, managing categories, and requesting budget info.
- From the Backend to the Database: CRUD operations using functions in the “server/db” modules.
- From the Backend to Google Gemini API: Voice command processing calls, likely invoked by endpoints dedicated to handling voice commands.
- The voice command functionality ties the external service with a frontend action (clicking “Voice Report” or similar) and then feeds the result back to the user interface.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly divide the application into frontend (user interface), backend (API and business logic), and data persistence layers.
- Modular Design: The frontend is component-based (React) and the backend has separate modules for database operations.
- API-driven Communication: The frontend interacts with the backend via defined API endpoints, and the backend in turn communicates with external services.
- Environment-based configuration: The use of .env for storing sensitive API keys.

– API endpoints
– Database Operations (store in “server/db”)
– Integration with Gemini API.
- Directional data flows and use legends or annotations where necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (React & Vite)"
        A1["General Frontend Code"]:::frontend
        A2["API Integration"]:::frontend
        A3["Build Tool Config"]:::frontend
    end

    subgraph "Backend (Node.js/TypeScript)"
        B1["Main Server Setup"]:::backend
        subgraph "Database Operations"
            B2["database.ts"]:::backend
            B3["operations.ts"]:::backend
        end
        B4["Gemini API Connector"]:::backend
    end

    subgraph "Data Storage"
        DB["SQLite Database (budget.db)"]:::database
    end

    subgraph "External Services"
        E1["Google Gemini API"]:::external
    end

    subgraph "Configuration"
        C1["Environment Config (.env)"]:::config
    end

    A2 -->|"calls"| B1
    B1 -->|"invokes"| B4
    B4 -->|"connects"| E1
    B2 -->|"CRUD_ops"| DB
    C1 -->|"configures"| B4

    classDef frontend fill:#AEDFF7,stroke:#1F78B4,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef database fill:#FFF59D,stroke:#FBC02D,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#E53935,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#673AB7,stroke-width:2px;

    click A1 "https://github.com/imzodev/gemini-presupuesto-voz/tree/main/src"
    click A2 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/src/api/budgetApi.ts"
    click A3 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/vite.config.ts"
    click B1 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/server/index.ts"
    click B2 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/server/db/database.ts"
    click B3 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/server/db/operations.ts"
    click DB "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/budget.db"
    click B4 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/src/utils/geminiApi.ts"
    click C1 "https://github.com/imzodev/gemini-presupuesto-voz/blob/main/.env"
```
