Skip to content

Commit bc62c86

Browse files
committed
Add architecture design doc with key decisions from brainstorming session
1 parent ce3cc73 commit bc62c86

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Farscry Architecture Design
2+
3+
> Private, cross-platform video calling app. No chat. No bloat. Just calls.
4+
5+
## Status
6+
7+
**Phase:** Architecture design (pre-implementation)
8+
**Approach:** Architecture-first deep dive. Gav leads engineering with AI assistance — no black-box vibe coding.
9+
10+
---
11+
12+
## Key Decisions
13+
14+
### Product & Business
15+
16+
- **v1:** Paid product on managed infrastructure (Supabase)
17+
- **v2:** Self-hostable via Docker Compose (full self-hosted stack replacing Supabase)
18+
- **Self-hosting is a selling point** but ships after launch. Communicated to users early.
19+
- **Monetization:** Planned (details TBD in this doc)
20+
21+
### Identity & Auth
22+
23+
- **Primary identifier:** Phone number
24+
- **Secondary identifier:** Email
25+
- **Phone verification:** Skipped for now — phone numbers as identifiers without OTP verification
26+
- **Current auth:** Supabase email/password (will be reworked)
27+
- **v2 auth:** Custom auth service in Docker stack
28+
29+
### Data & Encryption
30+
31+
- **E2E encryption with user keys** — server is zero-knowledge
32+
- **Client-side key management:** Each user has a keypair
33+
- **Contact lists, metadata encrypted client-side** before storage
34+
- **Contact discovery:** Hashed identifiers (phone number + email hashes) for matching
35+
- **WebRTC media:** Already E2E encrypted (DTLS-SRTP)
36+
37+
### Native Integration
38+
39+
- **Full native call UI** — CallKit (iOS) + ConnectionService (Android)
40+
- **Push notifications:** APNs VoIP push (iOS) + FCM high-priority data messages (Android)
41+
- **Speakerphone by default** — remove ear speaker option entirely (this is video calling, not phone calling)
42+
- **Native contacts integration** — read phone contacts, cross-reference against database
43+
44+
### Infrastructure
45+
46+
- **v1 backend:** Supabase (managed Postgres, Auth, hosting)
47+
- **v1 signaling:** Node.js WebSocket server (existing, to be refined)
48+
- **TURN servers:** Not bundled. Self-hosters set up their own if needed. v1 uses Cloudflare free TURN.
49+
- **Push delivery:** TBD (signaling server vs separate service vs Supabase Edge Functions)
50+
51+
### UI/Theming
52+
53+
- **Color change:** Orange (#FF6B35) → Green (palette TBD)
54+
- **Dark mode only** for v1
55+
- **Material You on Android:** Future goal
56+
57+
---
58+
59+
## Architecture Layers (Deep Dive Plan)
60+
61+
Each layer to be discussed in detail across focused sessions. For each layer: what it does, how the protocol/technology works, design decisions, and how it connects to other layers.
62+
63+
1. **Identity & Auth** — How users exist in the system, phone number + email, JWT tokens
64+
2. **Data Layer** — Postgres schema, what's stored, what's encrypted client-side
65+
3. **E2E Encryption** — Key generation, storage, exchange, contact discovery with hashed identifiers
66+
4. **Signaling** — WebSocket protocol, message types, call initiation flow
67+
5. **Push Notifications** — APNs VoIP push, FCM high-priority, waking the app
68+
6. **Native Call Integration** — CallKit (iOS), ConnectionService (Android), OS-level call UI
69+
7. **WebRTC** — ICE/STUN/TURN, SDP offers/answers, media streams, audio routing
70+
8. **Mobile App Architecture** — Screen flow, state management, service layer
71+
9. **Theming** — Green palette, dark mode, Material You path
72+
10. **Deployment** — Supabase v1 setup, Docker Compose v2 design
73+
74+
---
75+
76+
## Current State (Proof of Concept)
77+
78+
### What Exists
79+
80+
- React Native monorepo (iOS + Android)
81+
- Node.js WebSocket signaling server
82+
- Supabase for auth (email/password) + Postgres database
83+
- WebRTC P2P calling with DTLS-SRTP
84+
- CallKit/ConnectionService libraries installed but push not wired up
85+
- Dark mode UI with orange accent
86+
87+
### What Works
88+
89+
- Basic video calling when both apps are open
90+
- User registration and login
91+
- Contact list (database-backed, no caching, no native contacts)
92+
- Signaling with auto-reconnect
93+
94+
### Known Issues (tracked in GAV-77)
95+
96+
- Calls only work with app open (no push notifications)
97+
- Audio through ear speaker only (should be speakerphone)
98+
- Contacts not cached, slow to load
99+
- No native phone contacts integration
100+
- No encryption on stored data
101+
- Orange theme (should be green)
102+
- Xcode build warnings
103+
- FCM not implemented (Android push)
104+
- Push token delivery is stubbed out
105+
106+
---
107+
108+
## Engineering Approach
109+
110+
- **Gav does the engineering** — understands every line, can defend every decision
111+
- **AI assists** — explains concepts, reviews code, helps with unfamiliar APIs
112+
- **No black boxes** — if you don't understand it, don't ship it
113+
- **Architecture-first** — full understanding before implementation
114+
- **Small tasks** — each implementable in a focused evening session
115+
- **Layer by layer** — learn, design, implement one component at a time
116+
117+
---
118+
119+
## Next Steps
120+
121+
1. Deep dive sessions on each architecture layer (2-3 layers per session)
122+
2. After all layers are understood, produce implementation task breakdown
123+
3. Create Linear tickets for each implementation task
124+
4. Build layer by layer, testing each before moving to the next

0 commit comments

Comments
 (0)