37
نموذجاً للبيانات
largest schema I have shipped
منصّة · 2025 · دون ذكر اسم العميل
منصّة تجمع أصحاب مشاريع العمارة والتصميم بالمستقلّين الذين ينفّذونها. تحتفظ المنصّة بالمال حتى يتأكّد تسليم العمل، وتُقدَّم العروض عبر محادثة لحظية.
37
نموذجاً للبيانات
largest schema I have shipped
15.4k
سطر من الكود
lines, excluding docs
8
Deal states
escrow state machine
6s to 2s
Response time
after database profiling
المشكلة
Design work in this market runs on trust and cash. A client hands money over and hopes; a freelancer delivers and hopes. The platform had to hold the money until delivery was confirmed, run the negotiation in real time, and vet freelancers before they could bid, while also carrying a materials catalogue and a course library in the same product.
الحلّ المعتمد
Four systems that would normally be separate products, against one 37-collection schema: a marketplace with escrow, a real-time chat where the bidding actually happens, a supplier materials catalogue, and a course platform whose completion records feed freelancer ranking. The spine is an eight-state deal machine where the escrow balance is not a flag but money physically moved out of the client wallet and parked on the deal document.
بنية النظام
Escrow is the core invariant. Money leaves the client wallet on acceptance and sits on the deal until completion or cancellation, when a narrow transaction splits it between freelancer and platform. Real-time chat drives negotiation, so socket load scales with active deals rather than registered users.
ومع كل قرار ثمنه
القرار الذي لا يُذكر ثمنه مجرّد تفضيل شخصي.
01
السبب
داخل المعاملة ثلاث عمليات فقط، وهي التي يجب أن تنجح معاً أو تفشل معاً: إضافة المبلغ إلى رصيد المستقلّ، وتسجيل عمولة المنصّة، وتحديث حالة الاتفاق. أمّا جلب الأسماء وإرسال الإشعارات فيجري خارجها.
الثمن
هذا يتطلّب كوداً أكثر من وضع العملية كلّها داخل معاملة واحدة. لكن المعاملة تبقى قصيرة بما يكفي كي لا يصبح انتظار الأقفال هو ما يبطئ النظام حين تُنجَز صفقات كثيرة في الوقت نفسه.
02
السبب
A freelancer defaults to pending approval, a client defaults to approved. The vetting requirement lives in the schema rather than being remembered in a controller.
الثمن
Logic in the model layer is unusual, but it makes the invariant impossible to forget at any of the signup paths.
03
السبب
A phone number can have many soft-deleted rows and at most one active account, which a unique index cannot express.
الثمن
The invariant depends on the signup paths checking correctly, so those checks are centralised rather than duplicated.
النتيجة
Live in production. Money moves between three parties, held and released against confirmed delivery, with the platform commission split out atomically on completion. Response time cut from roughly six seconds to two.