Language: English | Español
This document describes the internal persistence used by the API runtime.
- ORM:
SQLModel(sqlalchemybackend) - Migration tool: Alembic
- Runtime setting:
SQLALCHEMY_DATABASE_URI - Default DB URI:
sqlite:////resources/cache/sqlite/database.db - Startup behavior:
- API checks DB connectivity.
- If SQLite file does not exist, it creates parent directories.
- API runs
alembic upgrade headon startup.
Related code:
aymurai/settings.pyaymurai/api/startup/database.pyaymurai/api/main.pyaymurai/database/versions/13f78d08e925_create_database.py
Editable source: schema.mmd
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Primary key |
created_at |
DATETIME |
no | Server default CURRENT_TIMESTAMP |
updated_at |
DATETIME |
yes | Updated on row changes |
name |
TEXT |
no | Original filename |
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Primary key, derived from paragraph text hash |
text |
TEXT |
no | Normalized paragraph text |
prediction |
JSON |
yes | Model predictions (list[DocLabel]) |
validation |
JSON |
yes | Manual labels (list[DocLabel]) |
created_at |
DATETIME |
no | Server default CURRENT_TIMESTAMP |
updated_at |
DATETIME |
yes | Updated on row changes |
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Link row identifier |
document_id |
UUID |
no | FK -> anonymization_document.id |
paragraph_id |
UUID |
no | FK -> anonymization_paragraph.id |
order |
INTEGER |
yes | Paragraph order in source document |
Primary key is composite over id, document_id, paragraph_id.
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Primary key (document identifier) |
prediction |
JSON |
yes | Reserved document-level prediction payload; not written by the current public router |
validation |
JSON |
yes | Document-level validation payload |
created_at |
DATETIME |
no | Server default CURRENT_TIMESTAMP |
updated_at |
DATETIME |
yes | Updated on row changes |
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Primary key, derived from paragraph text hash |
text |
TEXT |
no | Normalized paragraph text |
prediction |
JSON |
yes | Model predictions (list[DocLabel]) |
validation |
JSON |
yes | Reserved for paragraph-level validation; public route is currently commented legacy logic |
created_at |
DATETIME |
no | Server default CURRENT_TIMESTAMP |
updated_at |
DATETIME |
yes | Updated on row changes |
| Column | Type | Nullable | Notes |
|---|---|---|---|
id |
UUID |
no | Link row identifier |
document_id |
UUID |
no | FK -> datapublic_document.id |
paragraph_id |
UUID |
no | FK -> datapublic_paragraph.id |
order |
INTEGER |
yes | Paragraph order in source document |
Primary key is composite over id, document_id, paragraph_id.
POST /api/anonymizer/predict- Reads
anonymization_paragraphby paragraph UUID. - Writes
anonymization_paragraph.predictionwhen cache is enabled.
- Reads
POST /api/anonymizer/disambiguate- Writes disambiguated predictions to
anonymization_paragraph.prediction.
- Writes disambiguated predictions to
POST /api/anonymizer/validation- Reads
anonymization_paragraph.validation.
- Reads
POST /api/anonymizer/anonymize-document- Writes
anonymization_paragraph.validation. - Creates
anonymization_documentkeyed by uploaded file content hash. - Creates link rows in
anonymization_document_paragraph.
- Writes
POST /api/datapublic/predict/{document_id}- Uses caller-provided
document_idas the document primary key. - Ensures
datapublic_documentexists whenuse_cache=true. - Writes
datapublic_paragraph.predictionwhenuse_cache=true. - Writes link row in
datapublic_document_paragraphwhenuse_cache=true.
- Uses caller-provided
GET /api/datapublic/validation/document/{document_id}- Reads
datapublic_document.validation.
- Reads
POST /api/datapublic/validation/document/{document_id}- Upserts
datapublic_document.validation.
- Upserts
Route modules for dataset CRUD (/api/datapublic/dataset/*) exist in code but are not mounted in the public router. Do not treat them as active public API until exposed in core.router.
