How ggwarrior001/ledgerx works
1. Product shape
LedgerX is a client-side finance/accounting application with one shared React/TypeScript codebase that is packaged for three runtimes: browser (Vite), desktop (Electron), and Android (Capacitor). The core domain is offline-first personal/business finance data, with optional Firebase sign-in and cloud sync.
2. Top-level UI shell
The app is organized around a routed shell in src/App.tsx, src/main.tsx, and src/app/AppShell.tsx. The shell composes the global layout, navigation, and feature pages. Page-level routes map to business areas like Dashboard, Invoices, Expenses, Clients, Vendors, Reports, Ledger, Settings, and Auth.
3. Feature-oriented structure
Business logic is split by domain under src/features/*. Each feature typically has:
- a view component for the page surface,
- one or more modal components for create/edit flows,
- a feature service for data access/business operations,
- a feature store for local state.
This keeps invoices, expenses, clients, vendors, and auth isolated from one another while sharing common primitives.
4. State and app boundaries
Global application state lives in src/contexts/AppContext.tsx, while authentication state lives in src/contexts/AuthContext.tsx. Feature stores such as useInvoiceStore, useExpenseStore, useClientStore, etc. manage feature-specific collections and UI state. The architecture is a mix of React context for cross-cutting concerns and feature stores for domain state.
5. Data access layer
There is a clear separation between UI and persistence. Shared services in src/shared/services and src/lib provide the data boundary:
- storage.ts / storageService.ts for encrypted local persistence,
- firestoreService.ts / firestoreSync.ts for cloud reads/writes,
- dataService.ts as the higher-level data orchestration layer.
Feature services call into this shared layer rather than talking directly to storage from UI components.
6. Offline-first local data model
The default persistence path is local and encrypted. The README describes AES-256 encryption with PBKDF2-derived keys, and the codebase reflects that with storage helpers in src/lib/storage.ts and the shared storage service. This makes local device storage the primary system of record unless cloud sync is enabled.
7. Optional Firebase sync path
Firebase is an opt-in boundary, not a hard dependency. src/lib/firebase.ts initializes Firebase auth and Firestore, and src/features/auth/services/authService.ts plus src/lib/firestoreSync.ts handle authenticated cloud behavior. When a user signs in, the app can mirror finance data to Firestore under that user account; otherwise it remains fully local.
8. Authentication and onboarding
Auth is a dedicated subsystem with src/pages/Auth.tsx, src/features/auth/components/AuthPage.tsx, AuthContext, and an auth store. First-run setup is handled by onboarding components, and AutoLock enforces inactivity-based session locking. These pieces sit at the boundary between secure access and the rest of the app.
9. Domain screens and shared UI
The visible product surfaces are mostly feature views in src/features/*/components/*View.tsx, backed by reusable UI from src/components/ui and layout components such as Sidebar and Topbar. Modals for clients, invoices, expenses, and vendors are the main create/edit interaction pattern, while dashboard and reports are read-heavy analytical surfaces.
10. Financial reporting flow
Dashboard, Reports, and Ledger consume the same underlying transaction data but present it differently: summary metrics and charts, analytical breakdowns, and full transaction history. The presence of Recharts in the README and chart-related UI in the component tree indicates that aggregated data is computed in the app layer rather than fetched from a separate analytics backend.
11. Cross-cutting UX concerns
Notifications, privacy mode, multi-currency behavior, fiscal-year configuration, and data export are app-wide concerns housed in shared components, constants, and settings screens. src/lib/constants.ts and src/features/settings are the main places where these configuration-driven behaviors are surfaced.
12. Platform wrappers
Electron and Capacitor are packaging/runtime layers around the same frontend code, not separate business applications. electron/main.js and electron/preload.js define the desktop shell and bridge, while android/ holds the generated/native Android project. The core finance logic remains in src/, which is what makes the architecture portable across runtimes.
13. Testing and automation
The repository includes unit tests with Vitest and end-to-end tests with Playwright. Those tests exercise the same frontend-centric architecture, with the main operational risk concentrated in state, storage/encryption, and auth/sync boundaries rather than in backend services.
14. Diagram takeaway
If you draw the system, the central node should be the React app shell. From there, branch into domain features, then into shared UI/state, then into the persistence boundary where data either stays in encrypted local storage or flows through Firebase auth into Firestore sync. Electron and Capacitor sit outside that core as runtime adapters.
Main entry points: AppShell.tsx Shell · dataService.ts Data service · AuthPage.tsx Auth page · firestoreService.ts Firestore svc
Components 34
App shell
Routing, global layout, and top-level composition
- main · Vite entrypoint
src/main.tsx - App · Top-level route host
src/App.tsx - Shell · Global navigation and page composition
src/app/AppShell.tsx - Home · Index route wrapper
src/pages/Index.tsx - Dashboard · Dashboard route wrapper
src/pages/Dashboard.tsx - Invoices · Invoices route wrapper
src/pages/Invoices.tsx - Expenses · Expenses route wrapper
src/pages/Expenses.tsx - Clients · Clients route wrapper
src/pages/Clients.tsx - Vendors · Vendors route wrapper
src/pages/Vendors.tsx - Ledger · Ledger route wrapper
src/pages/Ledger.tsx - Reports · Reports route wrapper
src/pages/Reports.tsx - Settings · Settings route wrapper
src/pages/Settings.tsx - Auth · Authentication route wrapper
src/pages/Auth.tsx
Feature domains
Business modules for finance workflows
- Dashboard view · Summary metrics and charts
src/features/dashboard/components/DashboardView.tsx - Invoice view · Invoice list and workflow
src/features/invoices/components/InvoicesView.tsx - Expense view · Expense tracking surface
src/features/expenses/components/ExpensesView.tsx - Clients view · Client management surface
src/features/clients/components/ClientsView.tsx - Vendors view · Vendor management surface
src/features/vendors/components/VendorsView.tsx - Ledger view · Transaction history surface
src/features/ledger/components/LedgerView.tsx - Reports view · Analytical breakdowns
src/features/reports/components/ReportsView.tsx - Settings view · App configuration surface
src/features/settings/components/SettingsView.tsx - Auth page · Sign-in and onboarding surface
src/features/auth/components/AuthPage.tsx
Shared state and data
Cross-cutting state, services, and local/cloud persistence
- App state · Cross-cutting application state
src/contexts/AppContext.tsx - Auth state · Authentication and lock state
src/contexts/AuthContext.tsx - Data service · Shared data boundary
src/shared/services/dataService.ts - Storage svc · Encrypted local storage access
src/shared/services/storageService.ts - Firestore svc · Cloud reads and writes
src/shared/services/firestoreService.ts - Storage lib · AES/PBKDF2 local data helpers
src/lib/storage.ts - Firebase · Auth and Firestore initialization
src/lib/firebase.ts - Sync · Firestore synchronization logic
src/lib/firestoreSync.ts
Shared UI
Reusable layout, modal, and interface primitives
- Sidebar · Primary navigation layout
src/components/layout/Sidebar.tsx - Topbar · Top-level app header
src/components/layout/Topbar.tsx - Onboarding · First-run setup flow
src/components/Onboarding.tsx - AutoLock · Inactivity-based lock
src/components/AutoLock.tsx
Connections 33
- main → App: mounts · Bootstraps the React application
- App → Shell: routes into · Delegates to the routed shell
- Shell → Home: route · Index entrypoint
- Shell → Dashboard: route · Dashboard page
- Shell → Invoices: route · Invoices page
- Shell → Expenses: route · Expenses page
- Shell → Clients: route · Clients page
- Shell → Vendors: route · Vendors page
- Shell → Ledger: route · Ledger page
- Shell → Reports: route · Reports page
- Shell → Settings: route · Settings page
- Shell → Auth: route · Auth page
- Dashboard → Dashboard view: renders · Dashboard UI surface
- Invoices → Invoice view: renders · Invoice UI surface
- Expenses → Expense view: renders · Expense UI surface
- Clients → Clients view: renders · Client UI surface
- Vendors → Vendors view: renders · Vendor UI surface
- Ledger → Ledger view: renders · Ledger UI surface
- Reports → Reports view: renders · Reports UI surface
- Settings → Settings view: renders · Settings UI surface
- Auth → Auth page: renders · Auth and onboarding surface
- Shell → Sidebar: uses · Primary navigation
- Shell → Topbar: uses · Global header
- Auth page → Onboarding: includes · First-run setup
- Auth page → AutoLock: enforces · Session inactivity lock
- App state → Data service: coordinates · App-wide data state flows into shared data operations
- Auth state → Firebase: authenticates · Firebase-backed sign-in boundary
- Data service → Storage svc: uses · Primary local persistence path
- Data service → Firestore svc: uses · Optional cloud persistence path
- Storage svc → Storage lib: wraps · Encrypted device storage helpers
- Firestore svc → Firebase: depends on · Uses Firebase initialization and SDK
- Sync → Firestore svc: syncs via · Mirrors finance data to Firestore
- Sync → Data service: orchestrates · Synchronizes shared app data