Files
gp/launch/architecture.md
T
2026-09-27 23:40:22 +08:00

79 lines
3.5 KiB
Markdown

# Focus Seed Architecture
Status: current release architecture for Focus Seed 1.0.2.
## Directory Layout
```text
lib/
main.dart
src/
app/ app shell, theme, ambience, localization setup
application/ product controllers and timer lifecycle
core/ date keys, focus durations, ambience, utilities
data/ local persistence boundary
data/local/ Drift SQLite database
models/ immutable product models and derived state
services/ no-op analytics and monetization interfaces
features/ Today, Focus, Records, Me, habits, onboarding, reflection, shell
widgets/ reusable panels, dialogs, headers, loading, illustrations
```
## Responsibility Boundaries
- `main.dart`: process entry only.
- `src/app`: app-level theme, locale policy, ambience updates, and shell bootstrapping.
- `src/application`: user commands, save rollback, local analytics events, and timer lifecycle.
- `src/core`: framework-light utilities and product constants.
- `src/data`: persistence boundary used by controllers.
- `src/data/local`: Drift tables, SQLite connection, and product-data clearing.
- `src/models`: product snapshots, sessions, habits, reflections, mood, records, and progress models.
- `src/services`: SDK-light interfaces with no-op implementations.
- `src/features/shell`: top-level navigation and controller wiring.
- `src/features/*`: screen-level UI and user flows.
- `src/widgets`: reusable UI primitives.
Widgets render state and forward intent. Controllers own commands. `FocusSeedStore` is the durable persistence boundary. Feature UI does not write to SQLite directly.
## Current Product Structure
Primary destinations:
- Today: daily focus, timer entry, habit summary, reflection prompt, and loop progress.
- Focus: immersive timer and active-session context.
- Records: completed focus sessions, reflections, and lightweight history.
- Me: preferences, privacy, local data controls, and about/legal surfaces.
Habits are a Today support flow, not a primary tab. Growth/Journey was removed from the V1 primary surface; review belongs in Records until a future feature has enough depth to justify a dedicated destination.
## Persistence
Focus Seed is offline-first and stores product data locally with Drift/SQLite:
- `daily_intentions`
- `focus_sessions`
- `habits`
- `habit_logs`
- `reflections`
- `app_settings`
The current user-facing app exposes no manual data transfer tools. Existing legacy local preference data is migrated once into SQLite when present, then removed. Small app preferences such as appearance and development language selection remain local preferences.
## Current Design Decisions
- No real ad SDK in V1.
- No real billing SDK in V1.
- No analytics SDK in V1.
- No account, server, or network dependency.
- Default focus duration is a user-facing local setting.
- Clear today resets only today's loop.
- Delete all data clears local product records while preserving app preference behavior where appropriate.
## Upgrade Path
- Keep Drift as the local source of truth while the product remains offline-first.
- Add DAO-style query methods before history grows large enough to make whole-snapshot writes inefficient.
- Add Riverpod or a repository package only when multiple apps or features need shared state patterns.
- Add real analytics, ads, billing, remote config, or sync only with privacy, Data safety, policy, and tests in the same release.
- Add golden or screenshot tests before scaling launch screenshots or visual variants.