Skip to content
HarryleverPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TradeChat

WhatsApp-native sales tracking and checkout provisioning for Nigerian micro-businesses

DevCareer Γ— Nomba Hackathon 2026

Watch Live Demo Video

πŸ“Ί Click here to watch the Tradechat Live Demo Video


What is TradeChat?

TradeChat turns a merchant's existing WhatsApp number into a full point-of-sale system. Merchants log sales in plain language via WhatsApp, the bot parses and confirms the transaction, generates a Nomba payment link or virtual account for the customer, and reconciles payment status via Nomba webhooks. A companion web dashboard surfaces sales history, revenue, and outstanding orders β€” while a daily summary is also pushed back into WhatsApp so merchants never have to leave the channel they already live in.


Architecture

πŸ“– Full Architecture & Security Note: For a deep-dive technical breakdown of our WhatsApp/Magic Link authentication, HMAC-SHA256 webhook signature verification (NombaSignatureGuard), idempotency guarantees (WebhookAuditService), and our ACID double-entry financial ledger (LedgerService), see our Architecture and Security Documentation.

Customer/Merchant (WhatsApp)
        β”‚
        β–Ό
Twilio WhatsApp Business API ──(webhook)──► NestJS Backend
                                                   β”‚
                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                    β–Ό              β–Ό               β–Ό
                              Gemini (parsing)  PostgreSQL     Nomba API
                                                (Prisma)     (Checkout / VA)
                                                   β”‚               β”‚
                                                   β–Ό               β–Ό
                                          Next.js Dashboard   Nomba Webhooks
                                             (Vercel)         (payment status)
                                                                   β”‚
                                                                   β–Ό
                                                        NestJS β†’ Twilio β†’ Merchant

Core loop:

  1. Merchant sends a free-text sale message on WhatsApp
  2. Twilio forwards it to a NestJS webhook endpoint
  3. Gemini extracts structured data (item, qty, price, customer)
  4. Bot echoes parsed data back for merchant confirmation
  5. On confirmation, backend creates a Nomba checkout link / virtual account
  6. Link is sent to the customer via the merchant
  7. Nomba webhook fires on payment β†’ backend updates transaction status
  8. Confirmation messages sent to both merchant and customer
  9. Dashboard and daily WhatsApp summary reflect the settled transaction

Tech Stack

Layer Choice
Messaging Twilio WhatsApp Business API
AI parsing Google Gemini 2.5 Flash (@google/genai)
Payments Nomba Checkout API + Virtual Accounts + Webhooks
Backend NestJS (Node.js 24 / TypeScript)
ORM / DB Prisma + PostgreSQL
Cache / Queue Upstash Redis + BullMQ
Dashboard Next.js 16 + Tailwind CSS v4 + Shadcn UI
Auth Custom WhatsApp OTP + Magic Links (JWT/Cookies)
Monitoring Sentry (APM & Profiling) + Logtail / Winston
Hosting (backend) Railway
Hosting (dashboard) Vercel

Monorepo Structure

This is a Turborepo monorepo managed with pnpm.

tradechat/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ backend/     # NestJS API β€” webhook receiver, Nomba integration, BullMQ jobs
β”‚   └── web/         # Next.js merchant dashboard
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ ui/                  # Shared React component library
β”‚   β”œβ”€β”€ eslint-config/       # Shared ESLint configuration
β”‚   └── typescript-config/   # Shared tsconfig.json bases
β”œβ”€β”€ turbo.json
└── pnpm-workspace.yaml

Getting Started

Prerequisites

  • Node.js 20+
  • pnpm 9+
  • A PostgreSQL database (Railway recommended)
  • An Upstash Redis instance

Installation

git clone https://github.com/Harrylever/tradechat.git
cd tradechat
pnpm install

Environment setup

Copy the example environment files for both the backend API and the web dashboard:

# Backend setup
cp apps/backend/.env.example apps/backend/.env

# Web dashboard setup
cp apps/web/.env.example apps/web/.env.local

Backend Environment (apps/backend/.env)

Variable Description
DATABASE_URL PostgreSQL connection string
TWILIO_ACCOUNT_SID Twilio account SID
TWILIO_AUTH_TOKEN Twilio auth token
TWILIO_WHATSAPP_NUMBER Twilio sender number e.g. whatsapp:+14155238886
GEMINI_API_KEY Google AI Studio API key
NOMBA_ACCOUNT_ID Nomba parent account UUID
NOMBA_SUBACCOUNT_ID Nomba sub-account UUID
NOMBA_CLIENT_ID Nomba OAuth client ID
NOMBA_CLIENT_SECRET Nomba OAuth client secret
NOMBA_WEBHOOK_SECRET Nomba webhook signature key
NOMBA_DEFAULT_EMAIL Default customer email (e.g. orders@...)
REDIS_URL Upstash Redis connection string
SENTRY_DSN Sentry error monitoring DSN
LOGTAIL_SOURCE_TOKEN Better Stack / Logtail source token
LOGTAIL_INGESTING_HOST Logtail ingesting host
JWT_SECRET Internal secret for dashboard ↔ backend auth
JWT_EXPIRES_IN JWT expiration duration (e.g. 7d)
WEB_APP_URL Web dashboard URL (e.g. http://localhost:3000)
ALLOWED_ORIGINS CORS allowed origins comma-separated list
PORT Server port (default 3001 or 3002)

Web Dashboard Environment (apps/web/.env.local)

Variable Description
NEXT_PUBLIC_API_URL Base URL of the backend API (default http://localhost:3001)
NEXT_PUBLIC_WHATSAPP_BOT_NUMBER WhatsApp bot contact number without + or whatsapp: (e.g. 14155238886)

Database

# Run migrations
cd apps/backend
pnpm dlx prisma migrate deploy

# Generate Prisma client
pnpm dlx prisma generate

Development

Run all apps in parallel from the monorepo root:

turbo dev

Or target a specific app:

turbo dev --filter=backend
turbo dev --filter=web

Building

# Build everything
turbo build

# Build a specific app
turbo build --filter=backend

API

The backend exposes a REST API with a global api/v1 prefix and Swagger documentation:

  • Documentation & Health

    • GET /api/v1/docs β€” Interactive Swagger UI
    • GET /api/v1/health β€” Service health check
  • Webhooks (No Auth / Signature Verified)

    • POST /api/v1/webhook/twilio β€” Inbound WhatsApp messages & status updates from Twilio
    • POST /api/v1/webhook/nomba β€” Payment event webhooks from Nomba (HMAC signature verified)
  • Authentication (/api/v1/auth)

    • POST /api/v1/auth/otp/request β€” Request a WhatsApp one-time password (OTP)
    • POST /api/v1/auth/otp/verify β€” Verify OTP and receive JWT session cookie / token
    • POST /api/v1/auth/magic/consume β€” Consume a single-use magic link token
  • Merchants (/api/v1/merchants)

    • GET /api/v1/merchants/me β€” Get authenticated merchant profile
    • GET /api/v1/merchants/me/stats β€” Get sales volume, success rates, and transaction counts
    • PATCH /api/v1/merchants/me β€” Update merchant profile and Nomba settings
  • Transactions (/api/v1/transactions)

    • GET /api/v1/transactions/me β€” List transactions filtered by status or limit
    • GET /api/v1/transactions/:id β€” Get single transaction details and webhook audit trail
  • Withdrawals & Bank Accounts (/api/v1/withdrawals)

    • GET /api/v1/withdrawals/me/balance β€” Get available balance in Naira
    • POST /api/v1/withdrawals β€” Submit a payout / withdrawal request
    • GET /api/v1/withdrawals/me β€” List withdrawal request history
    • GET /api/v1/withdrawals/me/bank-account β€” Get saved settlement bank account
    • PUT /api/v1/withdrawals/me/bank-account β€” Save or update settlement bank account details

Hackathon

Build window: July 1–7, 2026 Submission deadline: July 18, 2026 Track: Build Track - Virtual accounts as Infrastructure, Integrations & Plugins

Success criteria

  • Merchant onboards entirely via WhatsApp in under 5 minutes
  • A sale message produces a live Nomba checkout link within 60 seconds
  • Nomba webhook triggers merchant confirmation within 10 seconds of payment
  • Dashboard reflects real-time transaction data
  • Daily WhatsApp summary sends on schedule

Submission Artifacts

  • πŸ“„ Architecture and Security Note β€” Exhaustive technical breakdown of authentication, HMAC webhook signature verification, data isolation, and our ACID double-entry ledger model.
  • πŸŽ₯ Live Demo Video β€” 2-3 minute walkthrough of the WhatsApp bot and merchant dashboard.
  • 🎨 Design System & Guidelines β€” Visual design tokens, typography, and UI guidelines.

Steps to Test

Note: We're supposed to include testing credentials, and I honestly wish I could β€” but this is not that kind of application. TradeChat is built on real infrastructure that requires live WhatsApp numbers, active Nomba merchant accounts, and Twilio webhooks β€” things that can't meaningfully be mocked with a static test login. The best honest way to evaluate it is to watch the live demo and, if you have access to the stack, spin it up yourself with real credentials.

  1. Watch the Live Demo Video β€” Start here. The Loom walkthrough covers the full merchant flow end-to-end: WhatsApp onboarding, sale logging, Nomba checkout link generation, payment confirmation, and dashboard view.

  2. Review the Architecture β€” Read the Architecture and Security Documentation for a full breakdown of how the system handles authentication, HMAC webhook signature verification, idempotency, and the ACID double-entry ledger.

  3. Spin up the backend locally β€” Clone the repo, copy the environment files (apps/backend/.env.example β†’ .env), fill in your own credentials for Twilio, Nomba, Gemini, PostgreSQL, and Redis, then run:

    pnpm install
    cd apps/backend && pnpm dlx prisma migrate deploy
    turbo dev --filter=backend
  4. Expose your local server via ngrok β€” Nomba and Twilio webhooks need a publicly reachable URL. Use ngrok or a similar tunnel to expose your local port and update your Twilio and Nomba webhook settings accordingly.

  5. Send a sale message on WhatsApp β€” Using a WhatsApp number linked to your Twilio sandbox, message the bot in plain language (e.g. "Sold 2 bags of rice to Chidi for 8500"). Confirm the parsed result when the bot echoes it back.

  6. Complete a test payment β€” Use the Nomba checkout link or virtual account number generated by the bot to make a real or sandbox payment. Watch for the confirmation messages to come back through WhatsApp.

  7. Open the merchant dashboard β€” Navigate to the web app, log in via WhatsApp OTP, and verify that the transaction appears with the correct status and ledger entry.


Author

Name Role
Dean Full-stack / AI integration

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages