Key Takeaways
- Sub-second rendering: Pillow composites 1920×1080 task overlays in ~300ms on modest CPU.
- Cloud-native storage: MinIO S3-compatible layer decouples media assets from compute for horizontal scaling.
- Dual-mode auth: JWT authentication enables persistent user state; anonymous mode allows instant guest generation.
- Zero-config deploy: Single
docker-compose upspins up React/Nginx, FastAPI, SQLite, and MinIO. - WhatsApp automation: Scheduled Meta Cloud API integration delivers daily wallpapers proactively.

The Engineering Challenge: Why GenshinWallCraft Was Architected
Productivity tools and desktop personalization have historically existed in separate silos. Task managers require active context switching; wallpaper engines serve static assets. GenshinWallCraft bridges this gap by treating the desktop background as a programmable surface—a daily render target for prioritized task data composited onto high-fidelity Genshin Impact artwork.
The core architectural mandate: deliver a task overlay wallpaper generator capable of server-side rendering at 1080p/4K resolution with sub-second latency, persistent multi-tenant storage, and zero-operational-overhead deployment. This demanded a stack where the image pipeline, API layer, and object storage could scale independently while remaining simple enough for a single docker-compose command.
Core Architecture & Technical Stack Deep-Dive
Multi-Container Topology
The system decomposes into four primary containers orchestrated via Docker Compose:
- Nginx Reverse Proxy (Port 5155): Terminates TLS, serves React static assets, and routes
/apiand/authtraffic to the FastAPI backend. - FastAPI Backend (Port 8009): Asynchronous Python 3.11+ service handling JWT auth, task CRUD, image generation orchestration, and MinIO presigned URL negotiation.
- React 19 + Vite SPA: Tailwind CSS v4 single-page application for task management, gallery browsing, and real-time generation preview.
- MinIO Object Storage (Port 9000/9001): S3-compatible bucket layer (
wallcraftbucket) storing source artworks and generated outputs under user-scoped prefixes.
Persistence is split: SQLite + SQLAlchemy + Alembic for relational metadata (users, tasks, generation history) and MinIO for binary blobs. This separation ensures the database remains lightweight and portable while media scales horizontally.
Graphic Rendering Pipeline: Pillow Composite Engine
The rendering engine is a synchronous Pillow (PIL) pipeline executed in a thread pool to avoid blocking the FastAPI event loop. The composite sequence:
- Base fetch: Retrieve source artwork from MinIO (cached locally via
functools.lru_cacheon bucket keys). - Canvas init: Create 1920×1080 (or 3840×2160) RGBA canvas.
- Typography layout: Calculate text wrapping, checkbox grid positions, and category headers using
ImageDraw.textbboxwith bundled Noto Sans fonts. - Layer compositing: Draw semi-transparent overlay panels, checkboxes, task text, timestamps, and watermark.
- Encode & upload: JPEG encode at 90 quality → stream upload to MinIO via
put_object→ return presigned GET URL (TTL 7 days).
Benchmark (Intel i5-12400, 16GB RAM, containerized):
| Resolution | Avg Render Time | Peak Memory | Output Size |
|---|---|---|---|
| 1920×1080 | 280–350 ms | 45 MB | ~350 KB |
| 3840×2160 | 1.1–1.4 s | 180 MB | ~1.2 MB |
Throughput: ~3 concurrent 1080p renders per CPU core before queueing latency exceeds 1s. The thread pool size is configurable via RENDER_WORKERS env var (default: CPU count).
Authentication & Authorization Flow
- Anonymous Mode: Sessionless. Frontend posts task payload to
/api/v1/generate/anonymous; backend renders, stores in MinIO underanon/{uuid}/, returns presigned URL. No DB write. - Authenticated Mode: JWT access tokens (15 min TTL) + HTTP-only refresh cookie (30 days). Protected endpoints enforce ownership via
user_idforeign keys on tasks and generation history rows.
Key Features Breakdown & Practical Benefits
Dynamic Task Overlay Compositing
Users define daily, weekly, and custom tasks with categories (Resin, Domains, Bosses, Personal). The renderer groups by category, applies priority sorting, and fits content into responsive grid columns—automatically scaling font size and checkbox density to prevent overflow.
Artwork Catalog & Asset Management
Official splash/key visuals are ingested into MinIO at build time via a seed script. The frontend gallery loads presigned URLs for instant preview. New artworks can be added by dropping files into minio/seed/ and restarting the seed container—no code changes.
Scheduled WhatsApp Delivery
A background APScheduler job (cron: 0 7 * * * Asia/Jakarta) queries active authenticated users, renders their daily task wallpaper, and pushes via Meta Cloud API WhatsApp template messages. Idempotency keys prevent duplicate sends on scheduler restart.
Generation History & Private Galleries
Every authenticated render creates a GenerationRecord row linking user, source artwork, task snapshot JSON, and MinIO object key. The gallery UI supports infinite scroll, deletion (soft-delete + MinIO object removal), and re-download via fresh presigned URLs.
Real-World Deployment & Production Topology
The provided docker-compose.yml defines networks, volumes, and healthchecks for production readiness:
services:
nginx:
image: nginx:alpine
ports: ["5155:80"]
volumes: [./nginx.conf:/etc/nginx/nginx.conf:ro]
depends_on: [backend, frontend]
backend:
build: ./backend
env_file: .env
volumes:
- ./backend:/app # dev hot-reload
- sqlite_data:/data
depends_on:
minio:
condition: service_healthy
deploy:
resources:
limits:
cpus: '2'
memory: 1G
minio:
image: minio/minio:latest
command: server /data --console-address ":9001"
ports: ["9000:9000", "9001:9001"]
volumes: [minio_data:/data]
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 10s
timeout: 5s
retries: 5
frontend:
build: ./frontend
# static files copied to nginx in multi-stage build
volumes:
sqlite_data:
minio_data:
Key production hardening measures:
- Nginx rate limiting on
/api/v1/generate/*(10 req/min/IP anonymous, 60 req/min authenticated). - MinIO bucket policies restrict
GetObjectto presigned URLs only; no public read. - SQLite WAL mode enabled via
PRAGMA journal_mode=WALfor concurrent read/write.
Leave a Reply