# api

Authorized operations and shared contracts: responsibilities, supported exports and extension points.

## Purpose [#purpose]

The server defines oRPC procedures, domain routers, the assistant/MCP catalog and scheduled jobs. Public schema subpaths validate wire data; `client` exports only the router client type.

## Public exports [#public-exports]

Canonical subpaths follow `./<feature>/<role>` (see [ADR-0011](/docs/adr/0011-backend-feature-shape)). Contracts are leaf modules that web and mobile may import; the other entries are server-only and listed in the client boundary configuration.

| Subpath                         | Target                                                             |
| ------------------------------- | ------------------------------------------------------------------ |
| `./client`                      | `./src/client.ts`                                                  |
| `./rpc-scope`                   | `./src/rpc-scope.ts`                                               |
| `./request-id`                  | `./src/platform/rpc/request-id.ts`                                 |
| `./push-messages`               | `./src/features/notifications/notifications.push-messages.ts`      |
| `./context`                     | `./src/platform/rpc/context.ts`                                    |
| `./app-router`                  | `./src/platform/rpc/app-router.ts`                                 |
| `./jobs/run`                    | `./src/platform/jobs/run.ts`                                       |
| `./account-preference/contract` | `./src/features/account-preference/account-preference.contract.ts` |
| `./admin/contract`              | `./src/features/admin/admin.contract.ts`                           |
| `./audit/contract`              | `./src/features/audit/audit.contract.ts`                           |
| `./flags/contract`              | `./src/features/flags/flags.contract.ts`                           |
| `./todo/contract`               | `./src/features/todo/todo.contract.ts`                             |
| `./catalog/contract`            | `./src/features/catalog/catalog.contract.ts`                       |
| `./vehicle/contract`            | `./src/features/vehicle/vehicle.contract.ts`                       |
| `./proposals/contract`          | `./src/features/proposals/proposals.contract.ts`                   |
| `./integrations/contract`       | `./src/features/integrations/integrations.contract.ts`             |
| `./billing/contract`            | `./src/features/billing/billing.contract.ts`                       |
| `./notifications/contract`      | `./src/features/notifications/notifications.contract.ts`           |
| `./imports/contract`            | `./src/features/imports/imports.contract.ts`                       |
| `./assistant/contract`          | `./src/features/assistant/assistant.contract.ts`                   |
| `./documents/contract`          | `./src/features/documents/documents.contract.ts`                   |
| `./expense/contract`            | `./src/features/expense/expense.contract.ts`                       |
| `./reminder/contract`           | `./src/features/reminder/reminder.contract.ts`                     |
| `./service/contract`            | `./src/features/service/service.contract.ts`                       |
| `./vehicle-document/contract`   | `./src/features/vehicle-document/vehicle-document.contract.ts`     |
| `./vehicle-photo/contract`      | `./src/features/vehicle-photo/vehicle-photo.contract.ts`           |
| `./acquisition/contract`        | `./src/features/acquisition/acquisition.contract.ts`               |
| `./loan/contract`               | `./src/features/loan/loan.contract.ts`                             |
| `./insights/contract`           | `./src/features/insights/insights.contract.ts`                     |
| `./disposal/contract`           | `./src/features/disposal/disposal.contract.ts`                     |
| `./recurring-expense/contract`  | `./src/features/recurring-expense/recurring-expense.contract.ts`   |
| `./vehicle-history/contract`    | `./src/features/vehicle-history/vehicle-history.contract.ts`       |
| `./passport/contract`           | `./src/features/passport/passport.contract.ts`                     |
| `./showcase/contract`           | `./src/features/showcase/showcase.contract.ts`                     |
| `./studio/contract`             | `./src/features/studio/studio.contract.ts`                         |
| `./vehicle-member/contract`     | `./src/features/vehicle-member/vehicle-member.contract.ts`         |
| `./entry-approval/contract`     | `./src/features/entry-approval/entry-approval.contract.ts`         |
| `./vehicle-transfer/contract`   | `./src/features/vehicle-transfer/vehicle-transfer.contract.ts`     |
| `./invite-link/contract`        | `./src/features/invite-link/invite-link.contract.ts`               |
| `./partner/contract`            | `./src/features/partner/partner.contract.ts`                       |
| `./history-transfer/contract`   | `./src/features/history-transfer/history-transfer.contract.ts`     |
| `./moment/contract`             | `./src/features/moment/moment.contract.ts`                         |
| `./odometer/contract`           | `./src/features/odometer/odometer.contract.ts`                     |
| `./scan/contract`               | `./src/features/scan/scan.contract.ts`                             |
| `./data-export/contract`        | `./src/features/data-export/data-export.contract.ts`               |
| `./privacy/contract`            | `./src/features/privacy/privacy.contract.ts`                       |
| `./security/contract`           | `./src/features/security/security.contract.ts`                     |
| `./erasure/contract`            | `./src/features/erasure/erasure.contract.ts`                       |
| `./agent-tools/contract`        | `./src/features/agent-tools/agent-tools.contract.ts`               |
| `./ai/contract`                 | `./src/features/ai/ai.contract.ts`                                 |
| `./billing/plans`               | `./src/features/billing/billing.plans.ts`                          |
| `./billing/http`                | `./src/features/billing/billing.http.ts`                           |
| `./billing/web-http`            | `./src/features/billing/billing.web-http.ts`                       |
| `./mcp/server`                  | `./src/features/mcp/mcp.server.ts`                                 |
| `./mcp/context`                 | `./src/features/mcp/mcp.context.ts`                                |
| `./mcp/protocol`                | `./src/features/mcp/mcp.protocol.ts`                               |
| `./mcp/guard`                   | `./src/features/mcp/mcp.guard.ts`                                  |
| `./webhooks/events`             | `./src/features/webhooks/webhooks.events.ts`                       |
| `./uploads/service`             | `./src/features/uploads/uploads.service.ts`                        |
| `./assistant/http`              | `./src/features/assistant/assistant.http.ts`                       |
| `./documents/lifecycle-plugin`  | `./src/features/documents/documents.lifecycle-plugin.ts`           |

### Renamed subpaths [#renamed-subpaths]

These subpaths were renamed when the backend moved to one folder per feature. Import the new subpath.

| Earlier subpath                  | Use instead                |
| -------------------------------- | -------------------------- |
| `./routers/index`                | `./app-router`             |
| `./routers/admin.schema`         | `./admin/contract`         |
| `./routers/audit.schema`         | `./audit/contract`         |
| `./routers/flags.schema`         | `./flags/contract`         |
| `./routers/proposals.schema`     | `./proposals/contract`     |
| `./routers/imports.schema`       | `./imports/contract`       |
| `./routers/assistant.schema`     | `./assistant/contract`     |
| `./routers/todo.schema`          | `./todo/contract`          |
| `./routers/integrations.schema`  | `./integrations/contract`  |
| `./routers/billing.schema`       | `./billing/contract`       |
| `./routers/notifications.schema` | `./notifications/contract` |
| `./routers/documents.schema`     | `./documents/contract`     |
| `./billing-plans`                | `./billing/plans`          |
| `./uploads/workflow`             | `./uploads/service`        |
| `./ai/http`                      | `./assistant/http`         |
| `./ai/catalog.schema`            | `./agent-tools/contract`   |

These paths come from `packages/api/package.json`. Conditional targets distinguish platform or type resolution; consumers should import the subpath, not its source file.

## How to extend [#how-to-extend]

Add the operation to the feature's procedures and service, and register new procedures in `platform/rpc/app-router.ts`. Keep authorization in the procedure and resource scope in the query. Add a `./<feature>/contract` export when another package needs the contract. The `domain-feature` skill walks through a new feature. For AI/MCP tools, extend the single catalog after reading ADR-0007.

Read the [authorized operations and shared contracts guide](/docs/features/api) for the full flow.

## Key files [#key-files]

- [`packages/api/package.json`](https://github.com/CarlosZiegler/autofolio/blob/main/packages/api/package.json)

