Files
boc/rexo-task.md

4.4 KiB

REXO Task: quiXzoom + LandveX Transaction System

Overview

Build automated transaction monitoring and customer self-service for quiXzoom (DE) and LandveX (SE/TX).

Part 1: quiXzoom Event Streaming

Requirements

  • Log EVERY transaction event to Kafka topic quixzoom.events
  • Events: user lifecycle, job lifecycle, payments, payouts, QZ tokens
  • Full searchability via Elasticsearch
  • Real-time alerting for anomalies

Database Schema (PostgreSQL)

-- Events table (immutable)
CREATE TABLE qz_events (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    event_type TEXT NOT NULL, -- user.registered, job.matched, payment.received, etc
    payload JSONB NOT NULL,
    user_id UUID,
    job_id UUID,
    company_id UUID,
    amount DECIMAL(15,2),
    currency TEXT,
    status TEXT, -- success, failed, pending
    ip_address INET,
    user_agent TEXT,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_qz_events_type ON qz_events(event_type, created_at DESC);
CREATE INDEX idx_qz_events_user ON qz_events(user_id, created_at DESC);
CREATE INDEX idx_qz_events_job ON qz_events(job_id);

API Endpoints

  • POST /api/v1/events — ingest event
  • GET /api/v1/events/search — search events (Elasticsearch)
  • GET /api/v1/events/:user_id — user transaction history
  • GET /api/v1/events/summary — aggregated stats

Kafka Topics

  • quixzoom.events — all events
  • quixzoom.payments — payment events for ledger
  • quixzoom.payouts — payout events for ledger
  • quixzoom.alerts — anomaly alerts

Part 2: LandveX Customer Portal

Requirements

  • Self-service: view contract, invoices, usage
  • Automatic recurring billing (Stripe)
  • No manual invoicing — everything is automated

Database Schema

-- Contracts (auto-generated)
CREATE TABLE lv_contracts (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    company_id UUID NOT NULL,
    plan_type TEXT NOT NULL, -- basic, pro, enterprise
    start_date DATE NOT NULL,
    end_date DATE,
    auto_renew BOOLEAN DEFAULT TRUE,
    monthly_fee DECIMAL(15,2) NOT NULL,
    currency TEXT DEFAULT 'SEK',
    status TEXT DEFAULT 'active',
    stripe_subscription_id TEXT,
    metadata JSONB DEFAULT '{}',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Invoices (auto-generated)
CREATE TABLE lv_invoices (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    contract_id UUID REFERENCES lv_contracts(id),
    invoice_number TEXT NOT NULL,
    period_start DATE NOT NULL,
    period_end DATE NOT NULL,
    amount DECIMAL(15,2) NOT NULL,
    vat_amount DECIMAL(15,2) NOT NULL,
    total_amount DECIMAL(15,2) NOT NULL,
    currency TEXT DEFAULT 'SEK',
    status TEXT DEFAULT 'draft', -- draft, sent, paid, overdue
    stripe_invoice_id TEXT,
    paid_at TIMESTAMPTZ,
    metadata JSONB DEFAULT '{}',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Usage tracking
CREATE TABLE lv_usage (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    contract_id UUID REFERENCES lv_contracts(id),
    resource_type TEXT NOT NULL, -- api_calls, storage, users
    quantity DECIMAL(15,2) NOT NULL,
    unit TEXT NOT NULL,
    period DATE NOT NULL,
    metadata JSONB DEFAULT '{}',
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

API Endpoints

  • GET /api/v1/contract — view current contract
  • GET /api/v1/invoices — list invoices
  • GET /api/v1/invoices/:id/download — download PDF
  • GET /api/v1/usage — view usage report
  • POST /api/v1/upgrade — upgrade/downgrade plan
  • POST /api/v1/cancel — request cancellation

Frontend

  • Customer dashboard (React/Vue)
  • Invoice viewer with PDF download
  • Usage charts (Chart.js)
  • Stripe payment integration

Part 3: Automated Accounting

Requirements

  • Every payment → auto-booked to ledger
  • Every payout → auto-booked to ledger
  • VAT calculated per transaction
  • Employer contributions calculated per payroll

Integration Points

  • quiXzoom payments → BOC ledger (SEK/USD)
  • LandveX invoices → BOC ledger (SEK)
  • Payroll → BOC ledger (SEK)
  • Intercompany → BOC ledger (USD/SEK conversion)

Deliverables

  1. Go backend with Chi router
  2. PostgreSQL migrations
  3. Kafka producers/consumers
  4. Elasticsearch indexing
  5. React frontend for customer portal
  6. Stripe integration
  7. Automated accounting hooks

Notes

  • Use RS256 auth (same as BOC)
  • Multi-tenant (3 companies)
  • Currency: SEK for LandveX AB, USD for quiXzoom Inc + Landvex Inc
  • All code must be production-ready with tests