Data Models
Entity Relationship Diagram
Models
User
Extends Django's AbstractUser. Key additions:
| Field | Type | Description |
|---|---|---|
currency_preference | CharField(3) | Default: "PHP" |
sync_enabled | BooleanField | Whether E2E sync is active |
public_key | TextField | E2E encryption public key (X25519) |
Category
System defaults (18 seeded) plus user-created categories.
| Field | Type | Description |
|---|---|---|
user | FK(User), nullable | null = system default |
name | CharField(100) | Category name |
icon | CharField(50) | Icon identifier |
color | CharField(7) | Hex color code |
type | CharField | "expense" or "income" |
is_default | BooleanField | System default flag |
sort_order | IntegerField | Display ordering |
Unique constraint: (user, name, type).
Transaction
UUID primary key for sync compatibility. Supports soft delete.
| Field | Type | Description |
|---|---|---|
id | UUIDField (PK) | Client-generated UUID |
user | FK(User) | Owner |
type | CharField | "expense" or "income" |
amount | DecimalField(12,2) | Transaction amount |
currency | CharField(3) | Default: "PHP" |
category | FK(Category), nullable | Assigned category |
merchant | CharField(255) | Merchant/payee name |
description | CharField(500) | Short description |
notes | TextField | Additional notes |
date | DateField | Transaction date |
time | TimeField, nullable | Transaction time |
payment_method | CharField(50) | Payment method |
is_recurring | BooleanField | Generated from recurring rule |
recurring_rule | FK(RecurringRule) | Source rule |
client_id | UUIDField (unique) | ID from mobile device |
deleted_at | DateTimeField, nullable | Soft delete timestamp |
TransactionLineItem
Individual items within a transaction (e.g., receipt line items).
| Field | Type | Description |
|---|---|---|
transaction | FK(Transaction) | Parent transaction (cascade delete) |
name | CharField(255) | Item name |
quantity | DecimalField(8,3) | Quantity (default: 1) |
unit_price | DecimalField(10,2) | Price per unit |
total_price | DecimalField(10,2) | Line total |
sort_order | IntegerField | Display ordering |
Receipt
Receipt image with OCR/AI processing results.
| Field | Type | Description |
|---|---|---|
id | UUIDField (PK) | Client-generated UUID |
user | FK(User) | Owner |
image | ImageField | Receipt image file |
document_type | CharField | receipt, bill, screenshot, etc. |
raw_ocr_text | TextField | Raw OCR output |
parsed_data | JSONField | Structured extraction result |
ai_confidence | FloatField | AI confidence score |
processing_status | CharField | pending, processing, completed, failed |
transaction | FK(Transaction) | Created on confirm |
Inherits TimestampMixin and SyncMixin.
Budget
Per-category or overall budgets with computed spend.
| Field | Type | Description |
|---|---|---|
id | UUIDField (PK) | Client-generated UUID |
user | FK(User) | Owner |
category | FK(Category), nullable | null = overall budget |
amount | DecimalField(12,2) | Budget limit |
period | CharField | weekly, biweekly, monthly |
start_date | DateField | Budget start date |
is_active | BooleanField | Active flag |
Spent and remaining amounts are computed from transactions at query time.
RecurringRule
Rules for auto-generating transactions on a schedule.
| Field | Type | Description |
|---|---|---|
id | UUIDField (PK) | Client-generated UUID |
user | FK(User) | Owner |
type | CharField | "expense" or "income" |
amount | DecimalField(12,2) | Transaction amount |
category | FK(Category) | Category |
frequency | CharField | weekly, biweekly, monthly, quarterly, annually |
next_date | DateField | Next generation date |
end_date | DateField, nullable | Rule expiration |
is_active | BooleanField | Active flag |