Архитектура
System Overview
iOS app / agent client -> api.<domain> -> API Gateway -> Lambda backend -> Postgres
Web app -> app.<domain> -> CloudFront -> SPA
Browser and agent auth -> auth.<domain> -> API Gateway -> Auth Lambda -> Cognito
Apex redirect -> <domain> -> CloudFront redirect -> app.<domain>
Principles
- Отдельные public domains для
app,apiиauth - Postgres — source of truth
- iOS client работает в offline-first режиме с local SQLite и sync
- Web app, iOS client и external agent surface используют одну workspace model
- External agents начинают с
GET https://api.flashcards-open-source-app.com/v1/
Supported Clients
- Web app на
app.flashcards-open-source-app.com - iOS app в основном repository с local SQLite storage
- Android app в Google Play
- External agent clients через discovery, OTP bootstrap и
Authorization: ApiKeyauth
Data Model
workspacesworkspace_membersuser_settingsdevicescardsdecksreview_eventsapplied_operationssync_state
Data Flow
Web
- Browser выполняет sign in через
auth.<domain> - Web app загружает workspace data из
api.<domain> - AI chat requests проходят через
/chat/local-turn - Review submissions обновляют состояние scheduler
iOS
- iOS app сначала пишет в local SQLite
- Local changes ставятся в outbox
- Sync отправляет changes через
/v1/workspaces/{workspaceId}/sync/push - Sync скачивает remote updates через
/v1/workspaces/{workspaceId}/sync/pull - Local database применяет changes и продвигает sync cursor
External Agents
- Agents начинают с
GET /v1/ - Первый OTP stage работает на
auth.<domain> - Agent получает long-lived API key
- Agent загружает
/v1/agent/me, перечисляет workspaces, при необходимости выбирает один и затем использует/v1/agent/sql
Scheduling
Flashcards использует FSRS как review scheduler.
Implementation notes:
- Backend и iOS держат FSRS implementations согласованными
- Web app повторяет scheduling data contract, но не поставляет третью реализацию scheduler
- Workspace-level scheduler settings включают desired retention, learning steps, relearning steps, max interval и fuzz
- Actual review timestamp приходит из
reviewedAtClient
Для подробного contract см. main repository FSRS scheduling logic.
Authentication
- Email OTP через Cognito
- Shared-domain session cookies для hosted web app
- Agent OTP bootstrap на
auth.<domain>с выдачей long-lived ApiKey AUTH_MODE=noneдля local developmentAUTH_MODE=cognitoдля production-like auth
Deployment Shape
app.<domain>-> CloudFront + S3api.<domain>-> API Gateway + Lambda backendauth.<domain>-> API Gateway + Lambda auth service- Postgres on AWS RDS
Root domain может оставаться отдельным marketing site. Если он не используется на этапе bootstrap, infrastructure может временно redirect его на app.<domain>.