Phase 09 · Production AI engineering Core

AI app architecture

A production AI app is a normal app with a model behind a protected backend.

In plain terms

The frontend should not hold provider keys. Your backend receives the user request, gathers context, calls the model, logs the trace, and streams the answer back.

Why it matters

This protects secrets, enables auth and rate limits, and gives you a place to improve prompts without shipping a new frontend.

How it works

A common stack is a web UI, FastAPI or Node backend, model provider, database, vector store, tracing, and background workers for ingestion.

When you use it

Use this structure as soon as anyone besides you will use the project.

Common mistakes

  • Putting API keys in browser code.
  • No timeouts or retries.
  • No per-user cost tracking.

Best practices

  • Keep provider calls server-side.
  • Add health checks and request IDs.
  • Stream long answers so the UI feels alive.

Try it yourself

Wrap your RAG bot in a backend endpoint that streams responses and records a trace row.

Resources

  • FastAPI docs A practical Python backend framework for AI apps.