Skip to content

[Collect One 3/90] Docs: technical 1/2: client, backend (D02) - #2707

Open
gino-m wants to merge 2 commits into
review/c1/w01-build-scaffoldingfrom
review/c1/d02-docs-technical-1
Open

gino-m wants to merge 2 commits into
review/c1/w01-build-scaffoldingfrom
review/c1/d02-docs-technical-1

Conversation

@gino-m

@gino-m gino-m commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Collect One review series: D02 Docs: technical 1/2: client, backend (3/90)

Tracking issue: #2629 · Stacked on: #2698 · Reviewer: @rfontanarosa
FYI: @gino-m @shobhitagarwal1612

Context

Collect One is the Kotlin Multiplatform successor to Ground: a single shared codebase for the web
console, the mobile app (Android, iOS, browser), and a Spanner-backed user-data service. Forms use
ProtoForms, a lossless proto3 encoding of ODK XForms. Product and architecture background:
docs/product/prd.md, docs/technical/client/architecture.md (docs slices have not merged yet, so docs
are named by path here).

This PR is one slice of the wip/baobab tree. It only adds the files listed below. It is stacked on #2698:
review only this diff; it merges after #2698.
The technical docs are reviewed in 2 PRs (D02 client and backend, D03 forms, survey, data, library models and
sync).

This slice is documentation only (7 Markdown files). The docs describe the whole wip/baobab tree, so they
name classes, modules, and tests that arrive in later slices, and their relative links to code and to other
docs resolve as those slices merge.

What's in this PR

  • docs/technical/onboarding.md: engineering onboarding guide. Goals, the four application surfaces (web
    console, mobile app, Google Earth balloons, mobile workbench), a terminology bridge from Ground 1.0, CEO and
    XLSForm terms to proto messages, the entity-first data model, a system diagram, the repository layout, a
    local quickstart (Dev Launchpad, ports), essential commands, CI guardrails, and a reading list.
  • docs/technical/client/architecture.md: Clean Architecture and MVVM rules for the clients. Layers, when a
    ViewModel may call a repository directly versus a use case, SessionCoordinator and the client shells,
    DomainResult / DomainError, Kermit logging and redaction, Koin modules, clocks and dates, mobile and web
    navigation, ViewModel lifecycle and SavedStateHandle, device clients behind data sources, the directory
    tree, domain text rules, and a code review checklist.
  • docs/technical/client/modules.md: the Gradle module graphs of shared/app and shared/web, a table of
    each module's packages and dependencies, why the boundaries are where they are, where tests and fixture
    modules live, and what enforces the graph (compiler, Gradle, ModuleGraphTest,
    LayerDependencyArchitectureTest).
  • docs/technical/client/local-data-store.md: LocalStore as the clients' single source of truth.
    InMemoryLocalStore and PersistentLocalStore, what is persisted on the device (sync state, signed-in
    account, active survey, offline map areas), SQLDelight drivers per platform, the table schema, the browser
    SQLite worker (OPFS, IndexedDB, memory), seed and schema versioning with migrations 1.sqm to 4.sqm, and
    the handoff to the sync engine.
  • docs/technical/client/web-console.md: the web console page by page. URL scheme and route guard, Surveys
    page, Organizations pages and library tabs, Impact views, the dashboard (details card, data collection and
    media capture on web, data tables, exports), the Survey editor (sharing, datasets, close/archive/reopen),
    and the Form editor (flow canvas, geometry and media questions, save-to logic, concept links).
  • docs/technical/backend/spanner-schema.md: design doc (status: draft for review) for backing the user data
    RPCs with Cloud Spanner. Decision table, PROTO columns with STORED generated columns, client-generated
    UUID keys, read-timestamp sync tokens, watermark-only replay detection, permanent tombstones, explicit
    mobile downloads with FCM topic tickles, access epochs, Firebase Auth, the survey Trash lifecycle, sharing
    policies, the GoogleSQL DDL, an RPC to access-pattern map, emulator notes, and an implementation plan with a
    Status section listing where the code differs from the design.
  • docs/technical/backend/impact-aggregation.md: design doc (status: draft for review) for the impact
    aggregation job and the optional Earth Engine overlay pipeline. Inputs, GeoID deduplication, aggregation
    rules per concept, scope rules, the attribution score, S2 cell thresholding and suppression, the
    ImpactAggregate output message, privacy rules, hosting options, testing, rollout, and open questions.

Where it fits

Reference documentation only: nothing here is compiled or executed. onboarding.md is the entry point and
links to the other six files, to the product docs, and to the model and sync docs. The two backend design docs
describe the server and the shared impact aggregation logic.

Not in this PR

  • Product and UX docs (docs/product/*, docs/ux/content-guidelines.md) → D01 Docs: product and UX
  • docs/technical/sync-engine.md and docs/technical/model/** → D03 Docs: technical 2/2: forms, survey
  • Root README.md, GEMINI.md, shared/README.md, CI workflows → W01 Build system, CI workflows, and tooling
  • shared/protos/data/data_service.proto, impact_aggregate.proto, client_sync_state.proto → P03 Protos:
    data, library, sync, Earth Engine, user data
  • ImpactAggregator → K05 Core 5/7: impact, forms.engine (FormEngine, ImpactAggregator)
  • server/README.md, server/src/main/resources/spanner/schema.sql → S01 Server 1/4: server.data, server.geo
    (SpannerUserDataReader, StagedSeedOverlayUserDataStore)
  • LocalStore, InMemoryLocalStore → A07 App data 2/5: data.datasource.local.persistence,
    data.datasource.local.store (InMemoryLocalStore, LocalStore)

Suggested reading order

  1. docs/technical/onboarding.md
  2. docs/technical/client/architecture.md
  3. docs/technical/client/modules.md
  4. docs/technical/client/local-data-store.md
  5. docs/technical/backend/spanner-schema.md
  6. docs/technical/backend/impact-aggregation.md
  7. docs/technical/client/web-console.md

Focus areas

  • architecture.md, "The Rule for Use Cases vs. Direct Repository Access": ViewModels call repositories
    directly for simple CRUD and need a use case for anything else. This rule shapes most later app slices.
  • architecture.md, "Communication with Device Services": only a data source talks to a device client, with
    two named exceptions (trivial queries in a repository, foreground UI utilities in presentation).
  • spanner-schema.md, "Gap-Free Sync Tokens on Spanner" and "Replay Detection Without a Mutation Log": tokens
    anchored on the read timestamp, and one client_seq watermark per client and scope.
  • spanner-schema.md, "Sharing Policies and Access": the survey ID is the share link, with no separate link
    token and no link rotation. The doc states the trade-off.
  • spanner-schema.md internal consistency: the Decisions table calls tombstones permanent, while the
    Requirements table still says "rows with a TTL"; the Decisions table names SurveyAcl.sharing_role, while
    later sections use default_role; the DDL declares UsersByEmail unique, while Status says it isn't.
  • impact-aggregation.md, "Grid Cells and Thresholding" and "Privacy and Security": publication thresholds
    (10 features from 2 organizations), suppression, and the organization opt-out. Hosting, licensing, and
    thresholds are listed as open questions.
  • local-data-store.md, "Working Copy": the bullet saying stored models move to proto-aligned records "when
    the sync engine lands" reads as older than the sync sections below it.
  • onboarding.md calls ModuleGraphTest a Konsist test; modules.md says it reads Gradle dependencies and
    that LayerDependencyArchitectureTest is the Konsist one.

Safe to skim

  • The GoogleSQL DDL block and the RPC to access-pattern table in spanner-schema.md.
  • The Mermaid diagrams and the directory tree in architecture.md and modules.md.
  • The long "Feature view models" bullet in local-data-store.md, and the per-control UI detail in
    web-console.md (dashboard, media capture, Form editor).
  • The quickstart and command tables in onboarding.md.

Size

Source Tests Data Files
3479 0 0 7

Testing

bash scripts/ktfmt.sh --check: PASS. bash scripts/license-check.sh --check: PASS. This slice is Markdown only, so no Gradle tasks ran.
CI: Check (ktfmt, buf, license headers, JVM tests and detekt, server Spanner tests), as far as the modules in
this PR's tree exist. This PR adds only Markdown, so no Gradle task compiles or tests its files.

Technical documentation.

Sliced from wip/baobab @ 367fc1c. Tracking: #2629.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds comprehensive technical documentation for the Collect One platform, covering backend Spanner schemas, impact aggregation, client architecture, local data stores, module structures, and onboarding guides. The review feedback is highly constructive, pointing out several inconsistencies and inaccuracies across the newly introduced documents. Key corrections include resolving conflicting statements in the Spanner schema document regarding tombstone TTLs, standardizing the 'sharing_role' field name, aligning the 'UsersByEmail' index uniqueness with its status description, updating outdated phrasing about the sync engine, and correcting the test reference for architecture verification.

- `ROLE_UNSPECIFIED` reads as `DATA_COLLECTOR`, matching today's implicit
behavior. `SURVEY_ORGANIZER` is rejected with `INVALID_ARGUMENT`, because
organizers must be named on the ACL.
- Set through `SurveyMutation.acl_upsert.default_role` and exposed on

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is an inconsistency in the naming of the sharing role field. The Decisions table (line 59) and the section heading (line 485) specify SurveyAcl.sharing_role, noting that default_role was considered but rejected because it sounds like it applies to ACL entries too (line 499). However, lines 494 and 907 still refer to default_role (e.g., SurveyOverview.default_role, SurveyAcl.default_role). These should be updated to use sharing_role consistently.

Suggested change
- Set through `SurveyMutation.acl_upsert.default_role` and exposed on
- Set through SurveyMutation.acl_upsert.sharing_role and exposed on SurveyOverview.sharing_role, so clients can hide collection UI for view-only surveys.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✦ Good question; checking with the author and will follow up here. For context: the shipped schema names the field default_role (SurveyAcl.default_role, SurveyOverview.default_role in shared/protos/survey), while this doc records sharing_role as the decided name, so either the doc or the proto has to change.

Comment thread docs/technical/onboarding.md Resolved
…hitecture test references

Address review comments on #2707:
- spanner-schema.md: requirements table says tombstones are permanent, as the decisions and retention sections do
- spanner-schema.md: Users DDL matches the shipped schema (nullable email, EmailVerified, non-unique UsersByEmail)
- local-data-store.md: describe how the sync engine stores proto bases today
- onboarding.md: ModuleGraphTest pins the Gradle module graph; LayerDependencyArchitectureTest is the Konsist test
gino-m added a commit that referenced this pull request Nov 28, 2026
- spanner-schema.md, local-data-store.md, onboarding.md: #2707 review fixes (0a8ede8)
- model/forms and model/survey docs: align examples and tables with the schema, fix links (#2708, bd74cb3)
- SamplingApi.kt: KDoc names the canonical Geometry for generated plots

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

collect-one Tickets related to Collect One

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant