> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webarchery.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Your First Archery Server

> Boot an Archery application, register a route, and serve HTTP requests through the framework kernel.

This quickstart builds the smallest useful Archery application: a configured `App`, one route, an HTTP kernel, and a `dart:io` server.

<Info>
  Complete [Installation](/getting-started/installation) first. The example assumes Archery is installed and `lib/src/config/server.json` exists.
</Info>

## Create the server entry point

Create `bin/server.dart`:

```dart theme={null}
import 'package:archery/archery/archery.dart';

Future<void> main(List<String> args) async {
  final app = App();

  final config = await AppConfig.create();
  app.container.singleton<AppConfig>(
    factory: (_, [_]) => config,
    eager: true,
  );

  await app.boot();

  final router = app.make<Router>();

  router.get('/health', (request) async {
    return request.json({
      'status': 'ok',
      'framework': 'archery',
    });
  });

  final kernel = AppKernel(router: router);
  final staticFiles = app.make<StaticFilesServer>();
  final port = config.get('server.port') ?? 5502;

  try {
    final server = await HttpServer.bind(
      InternetAddress.loopbackIPv4,
      port,
      shared: true,
    );

    server.autoCompress = config.get('server.compress', true);

    print('Archery is running at http://localhost:$port');

    await for (final request in server) {
      if (await staticFiles.tryServe(request)) continue;
      await kernel.handle(request);
    }
  } catch (error, stack) {
    app.archeryLogger.error('Server failed', {
      'error': error.toString(),
      'stack': stack.toString(),
    });
    await app.shutdown();
  }
}
```

The framework entry point exports the Archery types used here together with the required `dart:io` types.

## Start the application

```bash theme={null}
dart run bin/server.dart
```

You should see:

```text theme={null}
Archery is running at http://localhost:5502
```

In another terminal, request the health endpoint:

```bash theme={null}
curl http://localhost:5502/health
```

The server returns:

```json theme={null}
{"status":"ok","framework":"archery"}
```

## What the server is doing

1. `AppConfig.create()` loads JSON configuration from `lib/src/config`.
2. The configuration repository is registered as an eager singleton.
3. `app.boot()` prepares the framework and its registered providers.
4. `Router` records the `GET /health` handler.
5. `StaticFilesServer` receives the first opportunity to serve a public asset.
6. `AppKernel` sends every remaining request through middleware and route dispatch.

<Tip>
  Keep the listener on `InternetAddress.loopbackIPv4` when a local reverse proxy will expose the application. Public binding and production hardening are covered in Deployment.
</Tip>

<CardGroup cols={2}>
  <Card title="Project structure" icon="folder-tree" href="/getting-started/project-structure">
    Organize routes, views, configuration, and application code.
  </Card>

  <Card title="Architecture" icon="diagram-project" href="/getting-started/architecture">
    Understand what happens during startup and each request.
  </Card>
</CardGroup>
