Architecture
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
app,api, औरauthके लिए अलग public domains- Postgres source of truth है
- iOS client local SQLite और sync के साथ offline-first है
- Web app, iOS client, और external agent surface एक ही workspace model share करते हैं
- External agents
GET https://api.flashcards-open-source-app.com/v1/से शुरू करते हैं
Supported Clients
app.flashcards-open-source-app.comपर web app- Main repository में local SQLite storage वाला iOS app
- Google Play पर Android app
- Discovery, OTP bootstrap, और
Authorization: ApiKeyauth के जरिए external agent clients
Data Model
workspacesworkspace_membersuser_settingsdevicescardsdecksreview_eventsapplied_operationssync_state
Data Flow
Web
- Browser
auth.<domain>के जरिए sign in करता है। - Web app
api.<domain>से workspace data load करता है। - AI chat requests
/chat/local-turnसे गुजरती हैं। - Review submissions scheduler state अपडेट करती हैं।
iOS
- iOS app पहले local SQLite में लिखता है।
- Local changes outbox में queue होती हैं।
- Sync
/v1/workspaces/{workspaceId}/sync/pushसे changes upload करती है। - Sync
/v1/workspaces/{workspaceId}/sync/pullसे remote updates download करती है। - Local database changes apply करती है और sync cursor आगे बढ़ाती है।
External Agents
- Agents
GET /v1/से शुरू करते हैं। - पहला OTP stage
auth.<domain>पर चलता है। - Agent को long-lived API key मिलती है।
- Agent
/v1/agent/meload करता है, workspaces list करता है, जरूरत पड़ने पर एक चुनता है, और/v1/agent/sqlइस्तेमाल करता है।
Scheduling
Flashcards review scheduler के रूप में FSRS इस्तेमाल करता है।
Implementation notes:
- Backend और iOS, FSRS implementations aligned रखते हैं
- Web app scheduling data contract को mirror करता है, लेकिन scheduler की तीसरी implementation ship नहीं करता
- Workspace-level scheduler settings में desired retention, learning steps, relearning steps, max interval, और fuzz शामिल हैं
- Actual review timestamp
reviewedAtClientसे आता है
Detailed contract के लिए main repository FSRS scheduling logic देखें।
Authentication
- Cognito के जरिए email OTP
- Hosted web app के लिए shared-domain session cookies
auth.<domain>पर agent OTP bootstrap जो long-lived ApiKey देता है- Local development के लिए
AUTH_MODE=none - Production-like auth के लिए
AUTH_MODE=cognito
Deployment Shape
app.<domain>-> CloudFront + S3api.<domain>-> API Gateway + Lambda backendauth.<domain>-> API Gateway + Lambda auth service- AWS RDS पर Postgres
Root domain एक अलग marketing site पर रह सकता है। अगर bootstrap phase में वह unused है, तो infrastructure इसे अस्थायी रूप से app.<domain> पर redirect कर सकती है।