Read only
No mutation endpoints, account state, sessions, or authorization flow.
SYSTEM DOCUMENTATION · IMPLEMENTATION REFERENCE
DOCS
A technical reference for installation, configuration, data contracts, endpoint behavior, image delivery, deployment, and failure handling.
FOUNDATION
The Aesthetics API exposes a normalized collection of aesthetic names, slugs, source links, image filenames, and resolved image URLs through a compact read-only HTTP interface.
Keep the dataset portable and the API predictable. Records remain image-host agnostic while the server resolves the final image URL at response time.
No mutation endpoints, account state, sessions, or authorization flow.
Small JSON objects that map directly into UI, scripts, and data pipelines.
Switch between local files, a custom CDN, or source-hosted images without rewriting records.
SYSTEM MODEL
GET /aesthetics/{slug}validation + lookupnormalized recordsresolved image_urlThe application loads the JSON dataset at startup and constructs a slug-addressable in-memory collection. This makes list, direct lookup, search, and random selection inexpensive at runtime.
The stored image value remains a filename. The response layer generates image_url from the active image delivery mode and base configuration.
LOCAL RUNTIME
python3 -m venv .venv
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1python -m pip install --upgrade pip
pip install "fastapi[standard]" uvicorn requests beautifulsoup4project/
├── api.py
├── aesthetics.json
└── images/
├── acid-design.png
└── ...uvicorn api:app --reload --host 127.0.0.1 --port 8000Open http://127.0.0.1:8000/healthz. A healthy process returns status, record count, and active image mode.
RUNTIME CONTROL
Keep deployment-specific values outside the dataset. The following table defines the configuration surface expected by this documentation baseline.
| Variable | Purpose | Example | Required |
|---|---|---|---|
AESTHETICS_DATA | Path to the JSON dataset. | ./aesthetics.json | No |
IMAGE_MODE | Image delivery strategy. | local, cdn, source | No |
IMAGE_DIR | Filesystem directory used by local image mode. | ./images | Local mode |
IMAGE_BASE_URL | Public base URL used by custom CDN mode. | https://cdn.example.com/aesthetics | CDN mode |
PUBLIC_API_BASE | Optional public base used when constructing absolute local URLs. | https://api.example.com | No |
# Example local configuration
export AESTHETICS_DATA="./aesthetics.json"
export IMAGE_MODE="local"
export IMAGE_DIR="./images"
uvicorn api:app --host 0.0.0.0 --port 8000HTTP CONTRACT
/aesthetics200 JSONReturns the complete collection. Optional pagination parameters can be applied by clients that do not want the entire payload.
limitoffsetArray of Aesthetic objects.
curl -s "http://127.0.0.1:8000/aesthetics?limit=20&offset=0"const response = await fetch(
"http://127.0.0.1:8000/aesthetics?limit=20&offset=0"
);
const aesthetics = await response.json();import requests
aesthetics = requests.get(
"http://127.0.0.1:8000/aesthetics",
params={"limit": 20, "offset": 0},
timeout=10,
).json()/aesthetics/{slug}200 / 404Returns one exact record selected by canonical slug.
slugAn unknown slug returns 404 with a JSON error body.
curl -s http://127.0.0.1:8000/aesthetics/acid-design/aesthetics/{slug}/imageIMAGE / REDIRECTResolves the primary moodboard media for a record. The exact transport behavior depends on the configured image mode.
Returns the file response from the configured image directory.
Redirects to the generated CDN URL or the record's source image URL.
/random200 JSONReturns one randomly selected aesthetic record.
curl -s http://127.0.0.1:8000/random/search?q={query}200 / 422Performs a case-insensitive substring search against aesthetic names.
qArray of matching Aesthetic objects. No match returns an empty array.
curl -s "http://127.0.0.1:8000/search?q=core"/healthz200 JSONProvides a lightweight liveness response and confirms that the dataset was loaded.
{
"status": "ok",
"count": 219,
"image_mode": "local"
}DATA CONTRACT
| Field | Type | Nullable | Description |
|---|---|---|---|
slug | string | No | Canonical URL-safe identifier. |
name | string | No | Human-readable aesthetic name. |
aesthetic_url | URL string | No | Source article on the Aesthetics Wiki. |
image | string | No | Portable image filename stored in the dataset. |
source_image_url | URL string | Possible | Original source-hosted media URL. |
image_url | URL string | No | Resolved public image location for the active server mode. |
{
"slug": "acid-design",
"name": "Acid Design",
"aesthetic_url": "https://aesthetics.fandom.com/wiki/Acid_Design",
"image": "acid-design.png",
"source_image_url": "https://static.wikia.nocookie.net/.../revision/latest",
"image_url": "http://127.0.0.1:8000/images/acid-design.png"
}FAILURE CONTRACT
The requested slug is not present in the loaded dataset.
The record exists, but the configured local image file cannot be read.
A required path or query value failed request validation.
The process could not load or serialize required application data.
{
"detail": "Aesthetic not found"
}MEDIA ROUTING
The API mounts or streams files from IMAGE_DIR. JSON responses resolve to the API's own image route or static mount.
http://127.0.0.1:8000/images/acid-design.pngThe server joins IMAGE_BASE_URL with each record's portable filename.
https://cdn.example.com/aesthetics/acid-design.pngThe server exposes or redirects to source_image_url, avoiding local image storage.
https://static.wikia.nocookie.net/...BROWSER ACCESS
The landing-page explorer calls the API directly from the browser. Development deployments therefore need an origin policy that allows the page's host and HTTP method.
Use explicit allowed origins for a public deployment rather than unrestricted wildcard configuration when credentials or private endpoints are ever introduced.
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=["https://docs.example.com"],
allow_methods=["GET"],
allow_headers=["Accept", "Content-Type"],
)MACHINE DESCRIPTION
PRODUCTION RUNTIME
Use 0.0.0.0 inside a container or hosted runtime.
Terminate HTTPS at a reverse proxy or platform edge.
Use a durable volume or CDN if local files must survive redeploys.
Configure platform liveness checks against /healthz.
FROM python:3.12-slim
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir "fastapi[standard]" uvicorn
EXPOSE 8000
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8000"]services:
aesthetics-api:
build: .
ports:
- "8000:8000"
environment:
IMAGE_MODE: local
volumes:
- ./images:/app/images:rouvicorn api:app \
--host 0.0.0.0 \
--port "${PORT:-8000}" \
--workers 2OPERATIONS
For this dataset size, in-memory access is appropriate. Add response compression and cache headers at the reverse proxy when the full collection or remote images receive repeated public traffic.
DIAGNOSTICS
Confirm that Uvicorn is running, that the Base URL matches its host and port, and that browser CORS policy allows the documentation page's origin.
curl -i http://127.0.0.1:8000/healthzVerify the dataset path, JSON validity, file permissions, and that the application is started from the expected working directory.
python -m json.tool aesthetics.json > /dev/nullCheck IMAGE_MODE, confirm that each record's image filename exists under IMAGE_DIR, and inspect case sensitivity on Linux hosts.
The upstream host may reject hotlinking or apply its own CORS policy. Use a server-side redirect, local mirror, or controlled CDN where licensing allows it.