Skip to content

Commit 098dabf

Browse files
committed
Enhance developer manual: add transaction model, failure modes, and out of scope details
1 parent 985c173 commit 098dabf

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

docs/ARCHITECTURE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,15 @@ graph TD
236236
- Analytics and reporting exports.
237237
- Workers are idempotent and safe to run in multiple replicas.
238238

239-
** Architectural Characteristics**
239+
**Architectural Characteristics**
240240

241241
- Stateless handlers → easy horizontal scaling.
242242
- Single domain model shared across bot and WebApp.
243243
- Strong consistency via DB locks and transactions.
244244
- UTC-based scheduling to avoid DST issues.
245245
- Clear separation of concerns across layers.
246246

247-
** Why This Architecture**
247+
**Why This Architecture**
248248

249249
- Supports multiple interfaces (Chat + WebApp) without duplicating logic.
250250
- Prevents double bookings under concurrent load.

docs/DEVELOPER_MANUAL.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ This is the detailed reference for engineers. It complements the high-level READ
1616
- Acquire `pg_advisory_xact_lock(master_id, time_bucket)` before booking write.
1717
- Holds for transaction lifetime; prevents double booking; auto-released on commit/rollback.
1818

19+
## Transaction Model
20+
21+
- Each application service executes in a single DB transaction. Services should open, use, and commit/rollback a single transaction boundary for each use-case to keep invariants simple and auditable.
22+
- Workers operate in independent transactions per job; retry and idempotency are expected at the job level.
23+
- No cross-service distributed transactions; instead, use compensation, events, or eventual consistency when coordination across bounded contexts is required.
24+
25+
## Failure Modes & Guarantees
26+
27+
- Payment succeeds but callback is delayed: a `payment_reconcile` worker periodically verifies provider state and reconciles the booking/payment state (idempotent reconciler).
28+
- Bot restarts mid-flow: FSM state and navigation stack are persisted or reconstructable from DB; the handler resumes based on stored FSM context or presents a deterministic restart path.
29+
- Worker crash during reminder send: workers use idempotency keys and at-least-once delivery with exponential backoff; retries are safe and deduplicated.
30+
31+
## Out Of Scope
32+
33+
- No real-time locking UI (clients are not expected to hold server-side locks visible to users).
34+
- No multi-currency conversion or FX plumbing — amounts are stored as amount+currency and conversions are out-of-scope for core booking flows.
35+
- No sharding or horizontal partitioning of the primary booking table yet; scale by vertical sizing, caching, and read replicas first.
36+
1937
## Gap Search (Sketch)
2038
- Inputs: working hours, breaks, existing bookings, requested services, durations, per-master speed.
2139
- Build occupied intervals; derive free windows; subtract total duration; apply lead-time and cutoff policies.

0 commit comments

Comments
 (0)