Store Architecture
Location:app/src/lib/stores/
The store layer manages all application state and coordinates data flow between the UI and business logic.
AppStore
Central store coordinating all application state (~8,700 lines)
GitStore
Per-repository Git state and operations
RepositoriesStore
Repository list and metadata persistence
AccountsStore
User accounts and authentication tokens
State Interfaces
IAppState
File:app/src/lib/app-state.ts
The central state interface defining all application state:
IRepositoryState
File:app/src/lib/app-state.ts
State for a single repository:
State interfaces are deeply readonly to prevent accidental mutations. New state is created via immutable updates.
AppStore
File:app/src/lib/stores/app-store.ts (8,717 lines)
The central store orchestrating all application state:
State Updates
State updates follow an immutable pattern:Repository Operations
GitStore
File:app/src/lib/stores/git-store.ts (1,400+ lines)
Manages Git state for a single repository:
Operation Queue
Serializes Git operations to prevent conflicts:The operation queue ensures Git operations execute serially, preventing race conditions and repository corruption.
Specialized Stores
RepositoriesStore
File:app/src/lib/stores/repositories-store.ts
Persists repository list to local database:
AccountsStore
File:app/src/lib/stores/accounts-store.ts
Manages user accounts and tokens:
PullRequestStore
File:app/src/lib/stores/pull-request-store.ts
Caches pull request data:
CommitStatusStore
File:app/src/lib/stores/commit-status-store.ts
Tracks CI/CD check status:
State Persistence
Local Storage
UI preferences stored in localStorage:IndexedDB
Structured data stored in IndexedDB via Dexie:Secure Storage
Sensitive data (tokens) stored in system keychain:Event System
Store Events
Stores emit events when state changes:Component Subscriptions
Components subscribe to store updates:Derived State
Memoized Selectors
Derived state computed on-demand:State Debugging
Dev Tools
Logging state changes in development:State Snapshots
Export state for debugging:Performance Optimization
Memoization
Cache expensive derived state computations
Batching
Batch multiple updates into single render
Lazy Loading
Load repository data on-demand
Background Tasks
Refresh data in background without blocking UI
Update Batching
Testing Stores
Mock Stores
Store Tests
Related Pages
UI Components
See how components consume state
Git Operations
Learn how Git data enters stores