AxiomCore
Guides

Connect FastAPI to a web client

Extract a FastAPI service, build and inspect its contract, run a local mock, and generate an ATMX web client.

This path keeps FastAPI as the executable backend and the browser application as ordinary web code. AxiomCore owns the reviewed contract artifact between them.

Prerequisites

Install the CLI, create an isolated Python environment, and install every dependency imported by the application entrypoint:

axiom --version
axiom doctor
python -m venv .venv
source .venv/bin/activate
python -m pip install fastapi pydantic
axiom install axiom-fastapi --module

Create and review the contract source

From the backend directory, replace main.py:app if your module or FastAPI object has another name:

axiom init main.py:app --module axiom-fastapi
axiom eval axiom.acore
axiom build axiom.acore
axiom inspect axiom.axiom

Review route paths and methods, request and response shapes, required fields, validation, and any authored authentication or error behavior. Extraction cannot infer business behavior that is not present in the discoverable framework surface.

Exercise a local boundary

Run declared contract tests, then start the mock server:

axiom test axiom.acore
axiom serve axiom.acore --port 8080 --debug

The mock follows authored contract responses and state. It is useful for frontend work, but does not replace a test against the real FastAPI service.

Pull the web client

In a second terminal, write the generated ATMX web surface into your frontend:

axiom pull ./axiom.axiom --framework atmx-web --out ./web/axiom

Load the generated entry point according to its emitted README or package metadata and await atmx.init(...) before issuing imperative calls or relying on declarative bindings. The exact generated symbols are contract-dependent; inspect the generated output instead of copying a guessed operation name.

Validate the application

Before treating the integration as complete, verify:

  • one successful request and one authored error;
  • missing/invalid input and the browser-visible validation result;
  • the production base URL, CORS allowlist, cookies or authorization header;
  • loading, empty, retry, and offline/cache states; and
  • a fresh browser session so cached data does not hide startup failures.

For release review, retain axiom.acore, axiom.axiom, the relevant lock, test output, and the semantic diff from the previous accepted contract.

On this page