Skip to main content
Archery separates application startup from request handling. Startup builds the services the application needs; the HTTP pipeline then reuses those services for each incoming request.

Application startup

A typical application starts in this order:
1

Create the application

App() provides the central application object and service container.
2

Load configuration

AppConfig.create() reads JSON configuration files and is usually bound as an eager singleton.
3

Register providers

Providers bind services, migrations, clients, seeders, or other application capabilities.
4

Boot the application

app.boot() prepares framework services, initializes eager bindings, and runs provider boot work.
5

Resolve runtime services

After boot, resolve services such as Router and StaticFilesServer from the container.
A provider’s register() phase defines bindings. Its boot() phase performs work that may depend on bindings from other providers.

Request lifecycle

For each incoming request:
  1. HttpServer yields a HttpRequest.
  2. StaticFilesServer.tryServe() handles matching public assets.
  3. AppKernel.handle() prepares the request and invokes global middleware.
  4. Router.dispatch() matches an exact or typed dynamic route.
  5. Route middleware runs in its defined order.
  6. The route handler writes a JSON, text, view, redirect, file, or error response.
  7. Unmatched requests receive the framework’s 404 response.

Component responsibilities

Failure and shutdown

A startup or listener failure should be logged and followed by explicit resource cleanup. Close the HTTP server and external clients, call app.container.dispose() when you rely on container disposal callbacks, and then call app.shutdown() to update the application lifecycle.

Service container

Learn how Archery owns and resolves services.

Build a small app

Apply the request lifecycle in a working JSON API.