windy-engine

byRaj Bahadur

Target Role: Senior Full-Stack Software Architect & WooCommerce Expert Project Name: Measure Man (Operational Engine for Raj.B Atelier) Context: We are building a custom operational engine named "Measure Man" for an existing luxury custom-tailoring brand, "Raj.B Atelier". The frontend website runs on WooCommerce. We are NOT building a customer app in Phase 1. Instead, the workflow is: Customer places a paid order on the website -> Webhook triggers our Node.js/Firebase Backend -> Admin Panel assigns a verified Master -> Master uses a Flutter/React-Native Android App to handle the visit, do GPS check-in, verify customer OTP, fill out a highly granular garment-specific Digital Measurement Form, and submit. Post-approval, a commission ledger is updated. Please generate the complete core technical architecture, schema definitions, and production-grade integration snippets based on the following specifications: --- ## 1. DATABASE SCHEMA (PostgreSQL / Firebase Firestore Hybrid Blueprint) Generate the database schema or collections mapping the exact operational state of "Measure Man". Include fields for: - `Orders / Measurement Jobs`: Linking WooCommerce Order ID, status mapped exactly to the business state flow (ready_for_assignment, master_assigned, visit_confirmed, at_location_pending_otp, visit_verified, measurement_submitted, commission_posted). - `Masters Profiles`: Including service areas (GeoJSON polygons or pincode arrays), skill tags (Shirt, Blazer, Sherwani), and balance/wallet tables. - `Garment-Specific Measurements Table`: High-precision float fields for Shirt/Kurta, Pant/Trouser, Blazer/Coat, and Sherwani/Indo-Western as defined in the product blueprint. - `Wallet Ledger & Withdrawal Requests`: Strict audit trail tracking transaction history (credited, pending, paid_out) with an Idempotency Key column to prevent double payouts. ## 2. WOOCOMMERCE EVENT-DRIVEN SYNC ENGINE Write a clean Node.js (Express) webhook endpoint that listens to WooCommerce `order.updated` or `order.created`. - Must explicitly validate the `X-WC-Webhook-Signature` using HMAC-SHA256 to guarantee security. - Must filter out non-paid or pending orders. It should trigger the internal measurement job ONLY when the status is 'processing' (meaning payment is captured via Razorpay). - Must extract shipping details, billing phone, and specific meta-keys (`rb_preferred_visit_date`, `rb_preferred_slot`, `rb_measure_required`). - Provide an automatic retry mechanism wrapper in case the backend or database is momentarily locked. ## 3. MASTER APP CORE CORE API ENDPOINTS (Node.js/Express + Firebase Auth) Draft the following production-grade secure REST API endpoints with JWT or Firebase Auth header validation: - `POST /api/master/checkin`: Validates that the Master’s current device coordinates match the customer's shipping address coordinates using a threshold of <150 meters. If outside the range, flag as `risk_medium`. - `POST /api/master/verify-otp`: Validates the customer-provided 6-digit visit verification OTP before unlocking the measurement form. - `POST /api/master/submit-measurement`: Validates that all mandatory fields for a specific garment type (e.g., Cross-Back, Armhole for Blazer) are completely filled before writing to the database and changing status to `measurement_submitted`. ## 4. RAZORPAYX PAYOUT & WALLET LEDGER LOGIC Generate a secure back-end service function `processMasterWithdrawal()` that interfaces with the RazorpayX Payouts API. - It must accept `master_id`, `amount`, and a unique `idempotency_key`. - It must perform a double-entry database transaction check: ensure the master has a sufficient `available_balance`, deduct the balance first, log a `pending_payout` transaction entry, and then make the server-to-server HTTP POST request to RazorpayX. - Include a separate webhook listener endpoint for RazorpayX `payout.processed` and `payout.reversed` to automatically update the wallet ledger or trigger an admin fallback email on failure. ## 5. REUSABLE UI COMPONENT SPECS (JSON/Markdown Structure) Provide structured JSON schemas that the mobile app can use to dynamically render the digital size form in Hindi and English based on the garment type selected, complete with input validation ranges (e.g., Chest: 28 to 65 inches/cms). Please output this modularly, beginning with the database schema and the secure WooCommerce webhook infrastructure first.

LandingMastersOTPVerifyLoginMeasurementForm
Landing

Comments (0)

No comments yet. Be the first!

Architecture

No Services Diagrams Yet

Architecture diagrams will be automatically generated when the Project Manager creates tasks for your project.

Landing design preview
Login: Sign In
Dashboard: View Overview
Dashboard: Monitor Jobs
Orders: View Pending Jobs
Orders: Assign Master
Masters: Browse Available
Masters: Confirm Assignment
Orders: Track Visit Status
Measurements: Review Submitted
Measurements: Approve Entry
Wallet: View Commission Ledger