# yosefzaher/expenses_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/yosefzaher/expenses_tracker
- Repository: https://github.com/yosefzaher/expenses_tracker

## Overview

##### Project Type and Purpose
- This is a desktop GUI application (built in Python) for tracking daily expenses.
- It uses a local SQLite database (Expenses.db) to store records, a Tkinter GUI (with tkcalendar) for interaction, the requests library to fetch currency-conversion rates, and exports data to CSV.

##### File Structure
- Top-level files:
- ExpensesTracker_project.py – the main application logic and UI
- Expenses.db – SQLite database file
- requirements.txt – dependency list
- README.md – project description
- No separate frontend/backend folders: everything lives in one Python process.
- Uses environment variables (via python-dotenv) for external API keys.

##### README for Additional Insights
- Core features:
- CRUD on expenses (add, update, delete)
- Currency conversion to USD (via external API)
- CSV export
- UI layout: input fields, buttons, a table view, and a total-display section.

##### Main Components
a. Presentation Layer (UI)
- Tkinter main window
- Widgets: Entry fields, Dropdowns (Currency, Category, Payment Method), Buttons (Add, Delete, Update, Convert, Export), Table/Grid, Total display
- tkcalendar date-picker component
b. Application Logic Layer
- Controller functions in ExpensesTracker_project.py handling button callbacks
- Business rules: validation, CRUD operations, sum calculation, conversion logic
c. Data Layer
- SQLite database (Expenses.db)
- ORM or direct SQL queries in the Python script
- CSV export module (reads DB rows and writes a .csv file)
d. External Service
- Currency conversion API (accessed via requests)
- Environment variables loaded by python-dotenv for API key

##### Relationships and Data Flows
1. User clicks “Add Expense” → UI widget event → Controller processes input → Writes to SQLite DB → Refreshes UI table
2. User clicks “Update/Delete” → Similar flow, targeting a specific record
3. User clicks “Convert to USD” → Controller reads all expenses from DB → Sends HTTP request to currency API → Receives rates → Applies conversion → Displays results in UI
4. User clicks “Export to CSV” → Controller queries DB → Writes .csv file to local filesystem

##### Architectural Patterns and Principles
- Layered architecture: Presentation → Application → Data
- Single-process monolithic desktop app
- Separation of concerns: UI code vs. data-access vs. external-service calls
- Use of environment variables for secrets (python-dotenv)

##### Final Checklist
- Components: UI (Tkinter + tkcalendar), Controller/Business Logic, SQLite DB, External API, CSV Export
- Notes on key technologies: Python 3.x, Tkinter, SQLite, requests, python-dotenv

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Desktop Host"
        subgraph "Presentation Layer"
            UI["Tkinter Window\n(Entry, Dropdowns, Buttons, Table, Total Display)"]:::ui
            Calendar["tkcalendar DatePicker"]:::ui
        end
        subgraph "Application Logic Layer"
            Controller["ExpenseController\n(validation, CRUD, conversion, export)"]:::logic
            Env["Environment Variables Loader\ndotenv"]:::logic
        end
        subgraph "Data Layer"
            DB[(Expenses.db)]:::db
            CSV["CSV Export Module"]:::doc
        end
        subgraph "Documentation"
            README["Project Overview\nREADME.md"]:::doc
            GitIgnore[".gitignore"]:::doc
        end
    end
    External["Currency Conversion API"]:::cloud

    UI -->|"user event"| Controller
    Calendar -->|"date input"| Controller
    Controller -->|"INSERT/UPDATE/DELETE"| DB
    Controller -->|"EXPORT CSV"| CSV
    Controller -->|"GET conversion rates"| External
    External -->|"rates response"| Controller
    Env -->|"API key"| Controller

    click UI "https://github.com/yosefzaher/expenses_tracker/blob/main/ExpensesTracker_project.py"
    click Calendar "https://github.com/yosefzaher/expenses_tracker/blob/main/ExpensesTracker_project.py"
    click Controller "https://github.com/yosefzaher/expenses_tracker/blob/main/ExpensesTracker_project.py"
    click DB "https://github.com/yosefzaher/expenses_tracker/blob/main/Expenses.db"
    click CSV "https://github.com/yosefzaher/expenses_tracker/blob/main/ExpensesTracker_project.py"
    click External "https://github.com/yosefzaher/expenses_tracker/blob/main/ExpensesTracker_project.py"
    click Env "https://github.com/yosefzaher/expenses_tracker/blob/main/requirements.txt"
    click README "https://github.com/yosefzaher/expenses_tracker/blob/main/README.md"
    click GitIgnore "https://github.com/yosefzaher/expenses_tracker/blob/main/.gitignore"

    classDef ui fill:#D0E8FF,stroke:#0366d6
    classDef logic fill:#DFFFE0,stroke:#228B22
    classDef db fill:#FFEDB5,stroke:#DAA520
    classDef cloud fill:#F0F0F0,stroke:#888888
    classDef doc fill:#FFE4E1,stroke:#FF6347
```
