Multi-Service SaaS Encore.ts

A SaaS backend starter with user management, billing, and project management. Demonstrates event-driven provisioning, plan-based limits, and database-per-service architecture.

Explore and test endpoints in the Local Dashboard when running locally. When deployed to Encore Cloud, use the Service Catalog to call endpoints and view traces to see how requests flow between services.

Setup

No secrets or manual configuration needed. The Postgres databases are provisioned automatically when you run encore run. Each service gets its own database.

Architecture

When a user is created, the billing service automatically provisions a free subscription via Pub/Sub. The project service enforces plan-based limits (free: 3, pro: 25, enterprise: unlimited).

Authentication

Billing and project endpoints require authentication. This example includes a placeholder auth handler that reads the user ID from the ?auth_user= query parameter. In a real app, you would replace this with a proper auth implementation (e.g. JWT validation, session cookies, or an auth provider like Clerk or Auth0).

Endpoints

Users

POST /users user.create

Create a new user. Triggers automatic free plan provisioning.

curl -X POST https://api.innovwayz.io/users \
  -H "Content-Type: application/json" \
  -d '{"email": "alice@example.com", "name": "Alice"}'
GET /users/:id user.get

Get a user by ID.

curl https://api.innovwayz.io/users/<user_id>
GET /users user.list

List all users.

curl https://api.innovwayz.io/users

Billing

GET /billing billing.get

Get billing info for the authenticated user. Auto-created after user signup.

curl "https://api.innovwayz.io/billing?auth_user=<user_id>"
POST /billing/upgrade billing.upgrade

Upgrade the authenticated user's plan. Options: free, pro, enterprise.

curl -X POST "https://api.innovwayz.io/billing/upgrade?auth_user=<user_id>" \
  -H "Content-Type: application/json" \
  -d '{"plan": "pro"}'

Projects

POST /projects project.create

Create a project. Enforces plan-based limits (free: 3, pro: 25, enterprise: unlimited). Requires authentication.

curl -X POST "https://api.innovwayz.io/projects?auth_user=<user_id>" \
  -H "Content-Type: application/json" \
  -d '{"name": "My Project", "description": "A great project"}'
GET /projects/:id project.get

Get a project by ID.

curl https://api.innovwayz.io/projects/<project_id>
GET /projects project.list

List projects. Optionally filter by owner.

curl https://api.innovwayz.io/projects
curl "https://api.innovwayz.io/projects?owner_id=<user_id>"