Skip to main content

Overview

Zeus Finance is built on a local-first architecture that prioritizes user data ownership and offline capability. This document explains the key architectural decisions and how components interact.
Zeus’s current web assistant is a separate subsystem from the older mobile local-first stack described here. For the end-to-end implementation of the current chat assistant, tools, structured UI, and plans boundary, see Conversational Assistant Architecture.

Core Principles

1. Local-First

Data is created, stored, and modified locally first. The server acts as a synchronization point, not the source of truth.

2. Optimistic Updates

UI updates immediately after local operations. If sync fails, the user is notified but can continue working.

3. Eventual Consistency

All devices will eventually sync to the same state. Conflicts are resolved by timestamp (last-write-wins) or manual intervention.

System Components

Mobile Application (Flutter)

Key Responsibilities:
  • Store all data in SQLite
  • Provide instant read/write operations
  • Queue changes for sync
  • Handle conflict resolution

Backend Server (Rust)

Key Responsibilities:
  • Store canonical data in PostgreSQL
  • Provide REST API for sync
  • Handle authentication
  • Manage concurrent updates

Data Flow

Creating a Transaction

Offline Scenario

Sync Strategy

Sync Status States

Every entity has a sync_status field:

Sync Process

  1. Query all entities where sync_status != 'synced'
  2. Batch operations by type (create/update/delete)
  3. Send to server in dependency order (categories → wallets → transactions)
  4. Update local records with server IDs and synced status
  5. Hard delete entities marked pending_delete and synced

Conflict Resolution

When the same entity is modified on multiple devices:
  1. Server receives update with current updated_at
  2. Compare with server’s last known update
  3. Last-write-wins based on timestamp
  4. Return current server state to outdated clients

Database Schema

Local (SQLite)

Server (PostgreSQL)

Security Considerations

Authentication

  • JWT tokens for API authentication
  • Tokens refreshed on app foreground
  • Secure storage for credentials

Data Validation

  • Client-side validation for immediate feedback
  • Server-side validation as authoritative
  • Type safety via Rust/Flutter type systems

Scaling Considerations

Mobile

  • SQLite handles thousands of records efficiently
  • Lazy loading for transaction history
  • Image compression for attachments

Server

  • Stateless design enables horizontal scaling
  • Connection pooling for database
  • Rate limiting per user

Monitoring

Track these metrics in production:
  • Sync success/failure rates
  • Average sync latency
  • Conflict frequency
  • Cache hit rates
  • Storage utilization