
Lunaar Mobile Backend
Multi-Tenant Go Backend for the Lunaar Mobile Apps
Overview
The Lunaar Mobile Backend is a Go service that powers all of the Lunaar mobile apps from a single multi-tenant codebase. It re-implements the .NET AI services in Go - with unit tests that guard prompt parity against the originals - and adds per-app isolation, a credit economy and store billing. Every app is a tenant, identified by its app-id and restricted to the AI services it actually ships.
What It Does
It exposes REST APIs for studio photography, product shots, jewelry and glasses try-on, food visuals, sketch-to-render and image upscaling, running each generation as an async job. A request deducts credits, uploads inputs and enqueues work in one transaction; a worker consumes the job, calls the AI model, stores the result and marks it complete. It also manages per-user credit wallets and reconciles RevenueCat subscriptions from the App Store and Play.
Tech Stack
Key Features
Multi-tenant by design: each app validated via an X-App-Id header against an apps table, with row-level isolation and a per-app allowed-service list enforced by middleware
Seven registered AI services (studio, product shot, jewelry and glasses try-on, food visual, sketch-to-render and upscale) behind a shared generic pipeline
Credit economy with row-locked atomic deduction (HTTP 402 on insufficient balance) and idempotent refunds that cannot double-credit
Plan catalog in code (free, weekly, yearly) with a one-time signup grant and non-accumulative monthly resets
RevenueCat webhook billing handling purchases, renewals, plan changes, cancellations, expirations and billing issues, with event dedup and safe retries
Separate API and worker binaries, with the API auto-running embedded database migrations on boot
Scheduled maintenance jobs: monthly credit reset, refund recovery, stale-operation sweep and outbox cleanup
JWT auth (register/login/refresh/delete) with email verification and per-IP rate limits on sensitive routes
Technical Highlights
Key Achievements
Consolidated the backend for the entire Lunaar mobile suite into one multi-tenant Go service with strict per-app service gating
Achieved verified prompt parity with the original .NET services through dedicated unit tests
Guaranteed credit integrity under concurrency via row-locked deductions and idempotent, recoverable refunds
Built a resilient async pipeline with outbox delivery plus stale-operation and refund-recovery sweeps that self-heal stuck jobs
Impact & Results
Built at Group Taiga as the shared engine behind the Lunaar suite of mobile apps, it lets many branded apps run on one codebase while staying isolated and independently monetized. The multi-tenant model, credit economy and outbox-backed pipeline make it a production billing and generation backend, not just an API wrapper.