Pixel self-service discount-link extraction system remake starter.
This repository contains:
docs/pixel-site-spec.md: public-page feature inventory and API contract notes.docs/openapi.yaml: OpenAPI draft for the observed API surface.frontend/: React 19 + Vite frontend.backend/: Rust Axum backend that proxies upstream Pixel APIs and persists distribution CDK mappings in MongoDB..github/workflows/build-artifacts.yml: GitHub Actions workflow that builds and uploads frontend and backend artifacts.
Requirements:
- Node.js 24+
- npm 10+
- Rust 1.89+
- MongoDB 6+
Install frontend dependencies:
npm install --prefix frontendRun the Rust API:
cargo run --manifest-path backend/Cargo.tomlBackend environment variables:
$env:MONGODB_URI='mongodb://localhost:27017'
$env:MONGODB_DATABASE='pixel_remake'
$env:UPSTREAM_BASE_URL='https://pixel.yh-mo.xyz'The backend proxies user /api/... requests to:
https://pixel.yh-mo.xyz
Admin CDK endpoints are local backend endpoints:
GET /api/admin/cdksPOST /api/admin/cdksDELETE /api/admin/cdks/{id}
When a request body contains card_key, the backend checks MongoDB for a matching distribution CDK and forwards the corresponding upstream CDK to https://pixel.yh-mo.xyz.
The admin page (/admin) can override runtime environment variables without redeploying. Overrides are persisted in the MongoDB app_configs collection ({key, value_encrypted, updated_at}); values are AES-GCM-encrypted with ADMIN_TOKEN_ENCRYPTION_KEY and masked in the UI.
Admin config endpoints (all require an authenticated admin session):
GET /api/admin/configs— list every field with its effective value, override status, and metadata.POST /api/admin/configs— save (or clear) an override; hot-reloadable fields apply immediately.DELETE /api/admin/configs— revert an override back to its container environment value.
Fields are grouped by behavior:
- Hot reload (apply immediately):
UPSTREAM_BASE_URL,TRUST_PROXY_HEADERS,PROXY_RATE_LIMIT_PER_MINUTE,LOGIN_RATE_LIMIT_PER_MINUTE. - Restart required: all other manageable fields (OAuth, CORS, session, TTL, etc.) take effect on the next container start.
- Bootstrap only (cannot be overridden):
ADMIN_TOKEN_ENCRYPTION_KEY,MONGODB_URI,MONGODB_DATABASEmust be set via container environment variables.
Run the frontend:
npm run dev --prefix frontendThe Vite dev server proxies /api to http://127.0.0.1:8080.
For production, the Rust backend can serve frontend/dist directly. Set FRONTEND_DIST_DIR when the frontend build output is not at frontend/dist.
Frontend routes:
/: user task workspace./admin: distribution CDK management.
npm run build --prefix frontend
cargo build --manifest-path backend/Cargo.toml --releaseThe GitHub Actions workflow uploads:
frontend/distbackend/target/release/pixel-api
The Docker GHCR workflow builds one fused Docker image for GitHub Packages / GHCR:
ghcr.io/chloemlla/gggggg
Workflow behavior:
- Pull requests build the image without pushing.
- Pushes to
mainand manual runs pushlatestandsha-*tags.
Container variables:
$env:BIND_ADDR='0.0.0.0:8080'
$env:FRONTEND_DIST_DIR='/app/public'
$env:MONGODB_URI='mongodb://mongo:27017'
$env:MONGODB_DATABASE='pixel_remake'
$env:UPSTREAM_BASE_URL='https://pixel.yh-mo.xyz'
$env:APP_BASE_URL='https://your-production-domain.example'
$env:CORS_ALLOWED_ORIGINS=''
$env:ADMIN_TOKEN_ENCRYPTION_KEY='replace-with-a-long-random-secret'
$env:CDK_USAGE_LOG_TTL_SECONDS='2592000'The container starts only the Rust backend. It serves the frontend static files and handles /api/... from the same origin, so the frontend API base is detected automatically from window.location.origin.
CORS_ALLOWED_ORIGINS is intentionally blank for same-origin production deployments. Set it to a comma-separated list only when a separate trusted frontend origin must call the API with credentials.
No license file has been added yet because the repository owner has not selected a license.