# rachit4018/expense_tracker architecture

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

- Interactive diagram: https://gitdiagram.com/rachit4018/expense_tracker
- Repository: https://github.com/rachit4018/expense_tracker

## Overview

##### Project Identification
- Project Type: Full-stack web application.
- Purpose: Manage and track individual and group expenses with user authentication, expense management, and visualization.
- Key Features: User authentication (with JWT support per the API docs), CRUD operations for expenses, group management, and integration with a media storage system for user-uploaded receipts.

##### Main Components
a. Frontend Layer:
- HTML Templates: Representing different views like home, login, signup, add expense, group details, etc.
- Client-side Assets: Even if not explicitly detailed in the tree, the README mentions CSS and JavaScript styling for the frontend.

b. Backend Layer:
- Django Application (expense_tracker): Contains views, models, serializers, forms, and migrations which handle business logic and interactions with the database.
- API Endpoints: As listed in the README (e.g., authentication endpoints, expense CRUD endpoints, and group management endpoints). Emphasize that these endpoints follow RESTful principles via Django REST Framework.
- Admin Interface (via admin.py): Useful for managing internal data, user accounts, and expense management.

c. Database Layer:
- Persistent Storage: Initially using SQLite (as evidenced by db.sqlite3) with instructions to update to PostgreSQL for production. This layer handles user data, expense records, and group information.

d. Media/Receipt Storage:
- Receipts Directory: Likely used for handling or storing user-uploaded files such as images of receipts.

e. Supporting Components:
- Migrations: For database schema changes.
- Utilities and Tests: Modules for additional business logic (e.g., utils.py) and comprehensive testing (views.test.py and tests.py).

##### Relationships and Interactions
- The Frontend (HTML templates) interacts with the backend via HTTP requests. This includes interactions from regular web pages and API calls.
- The Backend processes incoming requests:
- It uses Django views and REST API endpoints to perform authentication, CRUD operations, and group expense management.
- It relies on serializers to convert data between JSON (for the API) and Django models.
- The Backend communicates with the Database via Django’s ORM for data persistence.
- The Receipts (media storage) module handles user-uploaded files linked to expenses.

##### Architectural Patterns and Design Principles
- MVC/MVT Pattern: Django’s Model-View-Template structure separates the business logic (models/views) from presentation (templates).
- RESTful API: Utilizing Django REST Framework to cleanly expose endpoints for frontend and potential third-party integrations.
- Modularization: Separation of concerns is evident through dedicated directories for migrations, tests, and isolated modules (like utils, serializers).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        FE["HTML Templates + Client Assets"]:::frontend
    end

    subgraph "Business Logic Layer"
        BE["Django Application (Views, Models, Forms)"]:::backend
        subgraph "REST API Endpoints"
            API_V["API: Views"]:::backend
            API_S["API: Serializers"]:::backend
        end
        ADM["Admin Interface"]:::backend
        UTIL["Utilities Module"]:::backend
        TEST["Testing Modules"]:::backend
        MIG["Migrations"]:::backend
    end

    subgraph "Data & Persistence Layer"
        DB["SQLite/PostgreSQL Database"]:::data
        MEDIA["Receipts/Uploaded Files Directory"]:::data
    end

    %% Connections
    FE -->|"HTTP/REST"| API_V
    FE -->|"HTTP/REST"| API_S
    API_V -->|"Processes_API_Call"| BE
    API_S -->|"Processes_Data"| BE
    BE -->|"CRUD_Operations"| DB
    BE -->|"File_Upload/Download"| MEDIA
    BE -->|"Schema_Updates"| MIG
    ADM -->|"Admin_Operations"| DB
    UTIL -.->|"Supports"| BE
    TEST -.->|"Validates"| BE

    %% Click Events
    click FE "https://github.com/rachit4018/expense_tracker/tree/master/expense_tracker/templates"
    click BE "https://github.com/rachit4018/expense_tracker/tree/master/expense_tracker/"
    click API_V "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/views.py"
    click API_S "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/serializers.py"
    click ADM "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/admin.py"
    click DB "https://github.com/rachit4018/expense_tracker/blob/master/db.sqlite3"
    click MEDIA "https://github.com/rachit4018/expense_tracker/tree/master/receipts/"
    click MIG "https://github.com/rachit4018/expense_tracker/tree/master/expense_tracker/migrations"
    click UTIL "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/utils.py"
    click TEST "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/tests.py"
    click TEST "https://github.com/rachit4018/expense_tracker/blob/master/expense_tracker/views.test.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef data fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
```
