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

# @parmana/api

> The Express server and its bootstrap composition root. For the REST surface itself, see the API Reference section.

<Info>**\[AVAILABLE]**. `packages/api`. Not a library other packages import, it's the running server. No public exports (`src/index.ts` is empty).</Info>

## Purpose

Composes every other package into one running Express process: policy loading, the
[gateway](/concepts/the-gateway), [credential isolation](/concepts/credential-isolation),
and 14 HTTP routes. For the routes themselves, request/response shapes, and verified error
codes, see [REST API Introduction](/api-reference/introduction) and
[Endpoints](/api-reference/endpoints), this page covers the server's internal structure.

## Install

Not installed as a dependency, this package is the deployable server itself. See [Deploy
patterns](/guides/deploy-patterns).

## Structure

| Path                                       | Purpose                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `src/server.ts`                            | Entry point. Builds the execution system, the application, then the Express app, and listens on port 3000.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `src/app.ts`                               | Mounts all 14 routes and the error handler, in order, the error handler must be registered last.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `src/application.ts`                       | `createApplication(executionSystem)`, wires `RuntimeFactory.create()` with the repositories and policy repository.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `src/routes/*.ts`                          | One file per route (or router factory), see [Endpoints](/api-reference/endpoints) for each one's behavior.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `src/middleware/error-handler.ts`          | Maps thrown errors to HTTP status codes by `instanceof`, falls through to an unstructured 500 for anything unrecognized.                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `src/mappers/BusinessTransactionMapper.ts` | `fromRequest(body)`, forces `status: RECEIVED` and `createdAt: now` regardless of client input.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `src/bootstrap/*.ts`                       | The composition root: `createExecutionSystem`, `createExecutionGateway`, `createExecutionControl`, `createConnectorRegistry`, `createConnectorRoute`, `createConnectorAuthenticator`, `createCredentialProvider`, `createVendorPaymentConnector`, `createGatewayKeyPair`, `createGatewayPublicKey`, `createGatewayIdentity`, `createNonceStore`, `createSessionStore`, `createExecutionAuditSink`. Every bootstrap decision described on [The gateway](/concepts/the-gateway) and [Credential isolation](/concepts/credential-isolation) lives here. |

<Warning>
  **Two files in `src/bootstrap/` are dead code, not wired into anything**: `ConnectorCatalog.ts`
  and `ConnectorFactory.ts` list connectors (including disabled stubs like `stripe`/`sap`) but
  neither is imported anywhere in `packages/api/src`. The real, running connector registration
  path is `createConnectorRegistry.ts`, see [The gateway](/concepts/the-gateway). Two other
  files, `scripts/generate-keys.ts` (repo root) and
  `packages/api/src/bootstrap/createVendorPaymentSecureConnector.ts`, are empty, 0-byte stub
  files, also unused.
</Warning>

## Minimal example

```bash theme={null}
npm run generate:gateway-keys
PARMANA_STORAGE=memory PARMANA_POLICY_DIR=/absolute/path/to/policies \
  VENDOR_PAYMENT_TOKEN=quickstart-demo-token npm run dev
```

Full walkthrough: [Quickstart](/quickstart).

## Next

<CardGroup cols={2}>
  <Card title="Endpoints" icon="route" href="/api-reference/endpoints">
    Every route's request, response, and verified error codes.
  </Card>

  <Card title="Deploy patterns" icon="server" href="/guides/deploy-patterns">
    Storage, keys, and the full environment checklist for running this server.
  </Card>
</CardGroup>
