# Space-Gib Server

This directory contains the Node.js server implementation for `space-gib`. 

The server is built on a custom microframework called `serve-gib`. For details on how routing, contexts, and request handling work within the framework, please refer to the [serve-gib Microframework Guide](serve-gib/README.md).

## Architecture

* **Framework**: Uses the minimalist `serve-gib` microframework instead of Express to maintain strict control over routing and IbGib multitenant contexts.
* **Hosting**: The server runs inside a Docker container orchestrated via `docker-compose`.
* **Build**: Compiled and bundled by `esbuild` using the monorepo's shared `build-space-gib.mts` script.

## Core Files & Endpoints
* `server.mts`: The main entry point that initializes the server, handles WebSocket upgrades, and defines the HTTP routing pipeline.
* `path-constants.mts`: Canonical definitions for all API regex routes (`/api/health`, `/api/keystone/*`, `/api/email/inbound`, `/api/email/send`, etc.).
* `bootstrap-helper.mts`: Logic for initializing domain-isolated multitenant metaspaces.
* `handlers/api/email/`: Endpoint handlers for inbound SES webhook processing (`POST /api/email/inbound`) and outbound email dispatch (`POST /api/email/send`).

For local development commands, please refer to the [Root space-gib README](../../README.md).
