# Database Manager API Database Manager handles SQLite database files and cell-level queries, images, and exports. All routes are served under the backend API prefix: `/api/v1`. ## Base URL ``` http://:/api/v1 ``` ## Database Files - Stored in `backend/app/databases/`. - File names must end with `.db` (path components are stripped). - Upload triggers a lightweight migration to ensure required columns exist. ## Common Query Parameters - `dbname` (required): database filename, e.g. `example.db` - `cell_id` (required for cell endpoints): cell identifier in the `cells` table - `image_type`: - image endpoints: `ph | fluo1 | fluo2` (some are fluo-only; see below) - `draw_contour` (optional): `true | false` - `draw_scale_bar` (optional): `true | false` - `degree` (optional): integer >= 1 (default: `4`) - `map_mode` (map256 endpoints only): `map256 | raw` (default: `map256`) ## Endpoints ### Database Files **GET** `/get-databases` Lists available database files. Response: JSON array of filenames. **POST** `/database_files` Upload a database file (multipart form field `file`). Response: `{ "filename": "example.db" }` **GET** `/database_files/{dbname}` Download a database file. Response: `application/octet-stream` **DELETE** `/database_files/{dbname}` Delete a database file. Response: `{ "deleted": true, "filename": "example.db" }` **PATCH** `/database_files/{dbname}` Rename a database file. Params: `new_name` (query, required) Response: `{ "previous": "old.db", "filename": "new.db" }` ### Labels and Contours **GET** `/get-cell-ids` Returns all cell IDs. Params: `dbname` Response: JSON array of strings. **GET** `/get-cell-ids-by-label` Returns cell IDs matching a manual label. Params: `dbname`, `label` Response: JSON array of strings. **GET** `/get-manual-labels` Returns distinct manual labels. Params: `dbname` Response: JSON array of strings. **GET** `/get-cell-contour` Returns contour points. Params: `dbname`, `cell_id` Response: `{ "contour": [[x, y], ...] }` **GET** `/get-cell-label` Returns the manual label for a cell. Params: `dbname`, `cell_id` Response: string. **PATCH** `/update-cell-label` Updates the manual label for a cell. Params: `dbname`, `cell_id`, `label` Response: `{ "cell_id": "", "label": "