How yuyuanweb/ai-retouch-agent works
AI Retouch Agent is a full-stack image-generation and editing product. The main workflow runs from a user prompt in the React app through API routes to agent planning and tool execution; results update an editable session and are shown on the canvas. Other major capabilities include image generation, selection and local edits, layers, batch processing, marketing assets, export, and progress streaming. The README documents the broad architecture; source excerpts confirm several session, storage, and tool-registry links. Unsampled implementation details are represented at their existing directory paths.
Main entry points: sessions.py Session routes · worker.py Task worker · tools Editing tools · client.ts API client
Components 25
Web app
- React app
frontend/src/App.tsx - Create and batches
frontend/src/pages/CreatePage.tsx - Canvas editor
frontend/src/components/editor/CanvasStage.tsx - API client
frontend/src/api/client.ts
API and sessions
- API routes
backend/app/main.py - Session routes
backend/app/routers/sessions.py - Authentication
backend/app/routers/auth.py - Session history
backend/app/services/sessions.py
AI and editing
- Agent service
backend/app/services/agent.py - Agent planning
backend/app/agent/graph.py - Plan validation
backend/app/agent/plan.py - Tool registry
backend/app/tools/__init__.py - Editing tools
backend/app/tools - Object selection
backend/app/services/selections.py - Layer documents
backend/app/layers.py - Image rendering
backend/app/edits/render.py - Batch processing
backend/app/services/batch.py
Async and persistence
- Progress events
backend/app/routers/events.py - Task queue
backend/app/queue.py - Task worker
backend/app/worker.py - PostgreSQL
- Redis
- S3 storage
backend/app/storage.py
Other components
- User
- DashScope AI
Connections 29
- User → React app: uses
README.md - React app → Create and batches: opens creation
README.md - React app → Canvas editor: opens editor
README.md - Create and batches → API client: requests generation
- Canvas editor → API client: requests edits
- API client → API routes: calls REST
README.md - API routes → Session routes: routes requests
backend/app/main.py - API routes → Authentication: routes auth
backend/app/main.py - Session routes → Session history: manages sessions
backend/app/routers/sessions.py - Session routes → Agent service: handles messages
backend/app/routers/sessions.py - Session routes → Object selection: handles selection
backend/app/routers/sessions.py - Agent service → Agent planning: orchestrates agent
README.md - Agent planning → Plan validation: validates plan
README.md - Agent planning → Tool registry: dispatches tools
README.md - Tool registry → Editing tools: registers tools
backend/app/tools/__init__.py - Editing tools → Layer documents: updates layers
README.md - Layer documents → Image rendering: provides composition
backend/app/edits/render.py - Object selection → DashScope AI: segments image
- Create and batches → Batch processing: submits batches
README.md - Batch processing → Task queue: enqueues work
README.md - Task queue → Task worker: dispatches tasks
README.md - Task worker → Editing tools: executes tools
README.md - Task worker → Progress events: publishes progress
README.md - Progress events → Redis: streams via pubsub
README.md - Progress events → API client: streams SSE
README.md - Session history → PostgreSQL: persists history
README.md - Session history → Layer documents: stores document
backend/app/services/sessions.py - Editing tools → S3 storage: stores image assets
backend/app/tools/context.py - Task worker → DashScope AI: calls image models