Skip to content

Prepare the application for production

Tenchi keeps production infrastructure outside the framework core, but it gives each concern a defined place. Process resources live in lifespan, request resources live in the context scope, external systems sit behind application-owned ports, and operational entrypoints call the same use cases as HTTP.

This guide turns that model into an ordered production checklist for a service that needs to survive retries, concurrent writes, partial failures, and deployment changes.

Prepare the API for deployment

Start with the resources and behavior your API already uses:

  1. Validate configuration and secrets at startup.
  2. Give each connection pool and SDK client a lifespan that closes it on shutdown. If requests write to a database, configure transactions that commit on success and roll back on failure.
  3. For protected operations, authenticate callers and authorize their actions. Keep credentials and identity out of request data.
  4. Configure body limits, deadlines, health checks, and your ASGI process and proxy using the deployment guide.
  5. Record outcomes so you can investigate errors and latency without logging request bodies or credentials.
  6. Run tenchi check and review API compatibility against the version callers currently use. Follow the release sequence to verify and deploy the finished application.

Test business behavior with memory adapters, then test real transactions and lifespan behavior through in-process HTTP clients.

Add safeguards for the capabilities you use

An HTTP API can ship without jobs, tools, evaluations, or business quotas. Use the following guides when their conditions apply:

If your application…Prepare this before deployment
Accepts commands callers may retryIdempotency with durable storage in the same transaction as protected writes
Calls external servicesBounded retries and failure handling, with provider timeouts and explicit retry-safe operations
Enforces per-user or per-tenant quotasRate limits backed by shared storage; configure edge limits separately for request floods
Receives signed provider callbacksWebhook verification, timestamp checks, and duplicate-delivery handling
Enqueues background workDurable jobs, worker deadlines, acknowledgement, retries, and dead-letter handling
Needs maintenance commandsOperational tasks, operator access, and application-defined dry runs
Exposes application toolsTool contracts and, for MCP, authentication, visibility, and approval
Uses model-backed behaviorEvaluations with suitable cases, thresholds, deadlines, and usage budgets
Depends on external deployment resourcesRead-only preflight checks for connectivity, permissions, and schema readiness
Choose infrastructure for your application

Tenchi provides contracts, validation, and lifecycle integration. You choose database drivers, migrations, identity providers, queues, schedulers, and telemetry exporters, and connect them through application-owned adapters.

Choose a consistency requirement before an adapter

A port should say what its caller needs, not which vendor implements it. A command repository normally needs strong reads and writes in the current transaction. A search port can explicitly permit stale results and use a read replica. A notification port can promise only that work was durably accepted, not that an email was delivered during the request.

Keep those meanings visible in method names and docstrings. Wiring can then change from SQLite to PostgreSQL, an in-process adapter to a service client, or a primary connection to a replica without silently weakening a use case.

Define the failure owner

For every boundary, decide which component owns each outcome:

This avoids ambiguous failures such as retrying invalid payloads forever, committing state before its outbox record, or treating a logging outage as an API failure.

Continue with the deployment guide for process configuration, release verification, rollout, and rollback.