Skip to content

DavyDevelops/opensub-haven

Repository files navigation

OpenSub Haven

Self-hosted, open source subscription management platform for iOS and Android. Backend-first with Expo/React Native client SDKs — inspired by RevenueCat, built for developers who want full control.

Features

  • Subscription engine — Apple & Google receipt verification, lifecycle state machine
  • Multi-tenant API — per-app API keys, isolated data boundaries
  • Webhooks — reliable delivery with exponential backoff and dead-letter queue
  • API gateway — rate limiting and usage tracking per plan tier
  • Mobile SDK@opensub-haven/sdk for Expo/React Native apps

Tech Stack

  • Express.js, TypeScript, Prisma, PostgreSQL
  • Redis, BullMQ
  • Zod validation, Docker, GitHub Actions CI
  • Vitest + Testcontainers for integration tests

Quick Start

Prerequisites

  • Node.js 20+
  • Docker (for Postgres, Redis, and integration tests)

Local development

# Install dependencies
npm install

# Start Postgres + Redis
docker compose up postgres redis -d

# Copy env and run migrations
cp .env.example .env
npm run db:generate
npm run db:push
npm run db:seed

# Start API and worker (separate terminals)
npm run dev --workspace=@opensub-haven/api
npm run dev --workspace=@opensub-haven/worker

API health check: GET http://localhost:3000/health

Create an app

curl -X POST http://localhost:3000/v1/apps \
  -H "Content-Type: application/json" \
  -d '{"name": "My App"}'

Save the returned apiKey — use it as x-api-key on all authenticated routes.

Project Structure

apps/
  api/         Express HTTP API
  worker/      BullMQ background jobs
  sample-app/  Expo app for Maestro E2E tests
packages/
  shared/    Types, Zod schemas, state machine
  sdk/       Expo/React Native client SDK
prisma/      Database schema and seed

Testing

npm run test:unit          # Fast unit tests (no Docker)
npm run test:integration   # API integration tests (requires Docker)
npm run test               # All tests via Turborepo

End-to-end (Maestro + mobile)

Full E2E guide: docs/e2e-testing.md

npm run e2e:up                              # Docker: Postgres, Redis, API, worker
cd apps/sample-app && npx expo run:android  # or run:ios
maestro test .maestro/android/              # or .maestro/ios/

Uses Maestro for iOS/Android UI tests against the sample app and sandbox store flows.

API Overview

Endpoint Description
POST /v1/apps Create app (returns API key)
POST /v1/users Create user
POST /v1/products Register subscription product
POST /v1/apple/verify Verify iOS receipt
POST /v1/google/verify Verify Android purchase
GET /v1/subscriptions/:userId List user subscriptions
POST /v1/webhooks Register webhook endpoint
GET /v1/usage API usage analytics

See docs/sdk-integration.md for mobile SDK setup.

License

MIT

About

is a self-hosted subscription backend that allows developers to manage: Mobile subscriptions (iOS / Android), User entitlements (feature access control) Subscription lifecycle events via webhooks Cross-platform user identity syncing

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors