video-streaming-ledger

byMorphy Morxel

You are a Principal Full-Stack Software Engineer and Systems Architect. I want you to build a complete, production-ready global video streaming platform (Netflix-style) with an integrated financial ledger, micro-transactional wallet system, creator payout dashboard, and administrative control center. Here are the exact technical, economic, and architectural specifications you must implement: --- ### 1. Database Architecture & Ledger (PostgreSQL) Build an immutable, double-entry financial ledger in PostgreSQL using raw SQL or Prisma/Sequelize. - **Users Table:** Stores user accounts with roles ('streamer', 'creator', 'admin'). - **Wallets Table:** Tracks live user balances (`balance_usd`, numeric precision 12,4). - **Ledger Transactions Table:** Immutable, append-only transaction log with unique idempotency keys to prevent double-spending or race conditions. All balance changes must write to this ledger. - **ACID Transactions:** Use explicit row locking (`SELECT ... FOR UPDATE`) inside database transactions for all wallet deductions and credits. --- ### 2. Business Logic & Monetization Rules - **User Funding:** Users fund their wallets via payment gateways (Stripe/Paystack webhook integrations supporting $3.00 minimum top-ups with tiered AOV bundles). - **Per-Stream Charges:** - Full Movie / Series: **₦60 (~$0.040 USD)**. - Season Episode: **₦30 (~$0.020 USD)**. - **The 70% Watch Milestone Payout:** - The frontend video player must securely track watch time (handling seeks/scrubs). - When a user reaches $\ge 70\%$ watch completion of a video session, the client sends a cryptographically signed heartbeat telemetry packet to the backend. - The backend validates the telemetry, deducts the fee from the streamer's wallet, and credits the creator's wallet (minus platform commissions). - **Platform Fee Split (Withdrawals):** - Creators can request withdrawals from their balance. - The platform automatically deducts a **40% platform commission** upon withdrawal, routing the 40% cut to the platform wallet and dispatching the remaining 60% net payout via Stripe Connect / Paystack / payout APIs. --- ### 3. Backend API (Node.js / Express) Implement the following secure REST endpoints: 1. `POST /v1/auth/login` - JWT-based authentication. 2. `POST /v1/billing/create-intent` & Webhook Handlers (`/webhook/stripe`, `/webhook/paystack`) - Handles card/mobile money top-ups and securely credits user wallets idempotently. 3. `POST /v1/telemetry/heartbeat` - Validates playback time-deltas and triggers the atomic 70% milestone payout. 4. `GET /v1/creator/metrics` - Returns real-time creator earnings, view counts, and recent $0.022/$0.040 micro-payout activity feed. 5. `POST /v1/creator/withdraw` - Calculates the 40% fee split and logs ledger entries. 6. `GET /v1/admin/analytics` - Computes total system volume, deposits, creator payouts, and total **40% platform commission revenue** collected. --- ### 4. Frontend Application (React / Next.js + Tailwind CSS) Build a sleek, dark-themed Netflix-style UI with the following views: 1. **Streaming Player View (`VideoPlayer.jsx`):** Integrates HLS.js for adaptive bitrate streaming, displays a live navbar wallet balance, and automatically fires secure telemetry heartbeats. 2. **Creator Studio Dashboard (`CreatorDashboard.jsx`):** Displays real-time earnings cards, total views, live transaction feeds, and a **Withdrawal Modal** that calculates the 40% platform fee split live before submitting. 3. **Admin Control Center (`AdminDashboard.jsx`):** Displays executive financial KPIs (Total Deposits, Gross Volume, 40% Platform Revenue, Active User Balance Float) and a real-time ledger auditing table. --- ### 5. Deployment & Containerization - Provide a `docker-compose.yml` file spinning up PostgreSQL and the Node.js backend container. - Ensure all code is clean, modular, heavily commented, secure against race conditions and bot manipulation, and ready for production deployment. Build the complete application now, starting with the database schema and backend server.

Landing
Landing

Comments (0)

No comments yet. Be the first!

Project Tasks

26 planning tasks
#1

Generate system requirement document

1m 52s0.05 cr used
Done
#2

Generate personas & user flows

0m 13s0.05 cr used
Done
#5

Architecture

0.05 cr needed
Backlog
#6

Workspace task plan

0.05 cr needed
Backlog
#7

Create flow for Streamer (Viewer)

0m 9sCredits in parent
Done
#8

Create flow for Creator

0m 9sCredits in parent
Done
#9

Create flow for Admin

0m 9sCredits in parent
Done
#10

Landing

12m 0sCredits in subtasks
Done
#11

Login

Credits in subtasks
Backlog
#12

Sign Up

Credits in subtasks
Backlog
#13

Streaming Player View

Credits in subtasks
Backlog
#14

Wallet

Credits in subtasks
Backlog
#15

Creator Studio Dashboard

Credits in subtasks
Backlog
#16

Admin Control Center

Credits in subtasks
Backlog
#17

Landing / Control Room Hero

1m 8s0.85 cr used
Done
#18

Landing / Pricing Tiers

0m 56s0.85 cr used
Done
#19

Landing / Settlement Explainer

0m 57s0.85 cr used
Done
#20

Landing / Creator Earnings

1m 3s0.85 cr used
Done
#21

Landing / Entry Actions

0m 55s0.85 cr used
Done
#22

Landing / Navigation

0m 0s0.85 cr used
Done
#23

Navigation

0m 54sCredits in parent
Done
#24

Fix Landing: Tablet navbar overflows horizontally and clips the Sign Up control; implicated files…

6m 3sCredits unavailable
Done
#25

Fix Landing: Hero CTA is wider than the mobile viewport and is covered at its right edge by the…

6m 3sCredits unavailable
Done
#26

Fix Landing: Sticky navbar covers the hero metadata row on mobile; implicated files: , (), and ().

6m 24sCredits unavailable
Done
#27

Fix Landing: The settlement receipt contradicts the required 40% withdrawal commission: is and is on…

6m 3sCredits unavailable
Done
#28

Fix Landing review findings: Tablet navbar overflows horizontally and clips the Sign Up… (+3 more)

3m 59s0.02 cr used
Done
Live
Landing design preview
Landing: Read platform settlement explanation
Sign Up: 1. Choose admin role and enroll
Sign Up: 2. Correct inline validation error
Login: 1. Submit credentials
Login: 2. Retry after invalid credentials
Admin Control Center: 1. Review executive financial KPIs
Admin Control Center: 2. Retry failed analytics fetch
Admin Control Center: Audit real-time ledger table
Admin Control Center: Inspect individual ledger rows
Admin Control Center: Identify marked commission entries
Live
Landing design preview
Landing: Read platform settlement explanation
Sign Up: 1. Choose admin role and enroll
Sign Up: 2. Correct inline validation error
Login: 1. Submit credentials
Login: 2. Retry after invalid credentials
Admin Control Center: 1. Review executive financial KPIs
Admin Control Center: 2. Retry failed analytics fetch
Admin Control Center: Audit real-time ledger table
Admin Control Center: Inspect individual ledger rows
Admin Control Center: Identify marked commission entries