How one-and-done2022/ai-hair-mini-program works
AI Hair Remix is a WeChat mini program backed by a FastAPI service. The main user journey is to sign in, choose a hairstyle or scene (optionally use recommendations or scene understanding), upload a photo, submit a generation job, and poll for previews and results; users can then review history or purchase quota. The backend separates API handling from queued generation and media persistence, with provider routing and operational administration as supporting capabilities. The README also documents internal scene and template review pipelines; their scripts are excluded from this runtime map. Several route and service implementations were not sampled, so uncertain internal links are omitted.
Main entry points: routers Product API routes · repository.py User and job records · index.js Photo and style selection · job_queue.py Job worker
Components 27
Mini Program
- Mini program
miniapp/app.js - Photo and style selection
miniapp/pages/capture/index.js - Recommendations
miniapp/pages/recommend/index.js - Scene understanding
miniapp/pages/scene-tool/index.js - Job results
miniapp/pages/result/index.js - History
miniapp/pages/history/index.js - Quota purchase
miniapp/pages/payment/index.js
API and accounts
- Authentication API
backend/app/routers/auth.py - Product API routes
backend/app/routers - Login service
backend/app/services/auth.py - User and job records
backend/app/services/repository.py - FastAPI application
backend/app/main.py
Generation runtime
- Queue backend
backend/app/services/dispatch_queue.py - Job worker
backend/app/services/job_queue.py - Image generation
backend/app/services/generation.py - Provider routing
backend/app/services/provider_routing.py - Media storage
backend/app/services/storage.py
Styles and scenes
- Style catalog
Faceprompt/src/faceprompt/catalog.py - Catalog CLI
Faceprompt/src/faceprompt/cli.py - Template service
backend/app/services/templates.py - Image understanding
backend/app/services/image_understanding.py - Scene review pipeline
scripts/scene_pipeline.py
Operations and billing
- Payments and quota
backend/app/services/billing.py - Provider administration
backend/app/routers/provider_admin.py - Admin console
backend/app/routers/admin_console.py
Other components
- User
- Image model provider
Connections 29
- User → Mini program: uses
- Mini program → Photo and style selection: starts creation
- Photo and style selection → Authentication API: signs in
- Authentication API → Login service: authenticates
- Login service → User and job records: stores account
- Photo and style selection → Product API routes: uploads and submits
- Recommendations → Product API routes: requests suggestions
- Scene understanding → Product API routes: analyzes scene
- Product API routes → Template service: loads templates
- Product API routes → Image understanding: analyzes image
- Product API routes → Queue backend: enqueues job
- Product API routes → User and job records: records job
- Product API routes → Media storage: stores media
- Job results → Product API routes: polls job
- Job results → History: opens history
- History → Product API routes: loads records
- Quota purchase → Product API routes: purchases quota
- Product API routes → Payments and quota: handles purchase
- Queue backend → Job worker: dispatches jobs
- Job worker → User and job records: loads and updates
- Job worker → Image generation: generates images
- Image generation → Provider routing: selects provider
- Image generation → Media storage: saves results
- Provider routing → Image model provider: calls model
- Catalog CLI → Style catalog: reads catalog
- Template service → Style catalog: uses style records
- Scene review pipeline → Image understanding: extracts scene blocks
- Provider administration → Provider routing: configures routing
- Admin console → User and job records: manages records