Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:OpenHands OpenHands Business Router Pattern

From Leeroopedia
Knowledge Sources
Domains Server_Architecture, SaaS_Infrastructure
Last Updated 2026-02-11 21:00 GMT

Overview

Concrete tool for mounting domain-specific business logic routers for billing, organizations, API keys, feedback, email, and shared conversations, provided by the OpenHands enterprise server layer.

Description

The Business Router Pattern is implemented in the SaaS server assembly module where each core business domain router is unconditionally mounted onto the FastAPI application. Unlike integration routers that are conditionally included, business routers represent essential SaaS functionality: billing_router handles subscription and payment endpoints, org_router manages organization and team operations, api_keys_router provides API key CRUD operations, feedback_router collects user feedback, email_router manages email notification preferences, and shared_conversation_router handles publicly shared conversation access. Each router is imported from its respective module under enterprise/server/routes/ and registered via app.include_router() with appropriate URL prefixes.

Usage

Use this pattern during SaaS server assembly to register all core business domain endpoints. These routers are always mounted regardless of environment configuration because they represent fundamental SaaS capabilities. Each router module can be independently developed, tested, and maintained by different teams.

Code Reference

Source Location

  • Repository: OpenHands
  • File: enterprise/saas_server.py:L100-130

Signature

# Business domain router mounting
from enterprise.server.routes.billing import router as billing_router
from enterprise.server.routes.organization import router as org_router
from enterprise.server.routes.api_keys import router as api_keys_router
from enterprise.server.routes.feedback import router as feedback_router
from enterprise.server.routes.email import router as email_router
from enterprise.server.routes.shared_conversation import router as shared_conversation_router

base_app.include_router(billing_router)
base_app.include_router(org_router)
base_app.include_router(api_keys_router)
base_app.include_router(feedback_router)
base_app.include_router(email_router)
base_app.include_router(shared_conversation_router)

Import

from enterprise.server.routes.billing import router as billing_router
from enterprise.server.routes.organization import router as org_router
from enterprise.server.routes.api_keys import router as api_keys_router
from enterprise.server.routes.feedback import router as feedback_router
from enterprise.server.routes.email import router as email_router
from enterprise.server.routes.shared_conversation import router as shared_conversation_router

I/O Contract

Inputs

Name Type Required Description
base_app FastAPI Yes The FastAPI application instance to mount routers onto
billing_router APIRouter Yes Router providing billing and subscription management endpoints
org_router APIRouter Yes Router providing organization and team management endpoints
api_keys_router APIRouter Yes Router providing API key lifecycle endpoints
feedback_router APIRouter Yes Router providing user feedback collection endpoints
email_router APIRouter Yes Router providing email notification preference endpoints
shared_conversation_router APIRouter Yes Router providing shared conversation access endpoints

Outputs

Name Type Description
base_app FastAPI The FastAPI application with all business domain routers mounted and accessible

Usage Examples

Basic Usage

from fastapi import FastAPI
from enterprise.server.routes.billing import router as billing_router
from enterprise.server.routes.organization import router as org_router
from enterprise.server.routes.api_keys import router as api_keys_router
from enterprise.server.routes.feedback import router as feedback_router
from enterprise.server.routes.email import router as email_router
from enterprise.server.routes.shared_conversation import router as shared_conversation_router

base_app = FastAPI()

# Mount all business domain routers
base_app.include_router(billing_router)
base_app.include_router(org_router)
base_app.include_router(api_keys_router)
base_app.include_router(feedback_router)
base_app.include_router(email_router)
base_app.include_router(shared_conversation_router)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment