Refractions is an multi-agent image generation system built on Bria's FIBO text-to-image model. It transforms simple designs into full editorial photoshoots using deterministic JSON control and AI-powered parameter generation.
Unlike traditional prompt-based workflows, Refractions uses structured JSON prompts and intelligent agents to generate, critique, and refine images—delivering consistent, reproducible results for professional creative workflows.
Tech Stack:
- Backend: Python (FastAPI), Gemini (multi-agent orchestration)
- Frontend: React + TypeScript (Vite)
- Image Generation: Bria AI FIBO (JSON-native text-to-image model)
- Storage: Google Cloud Storage, MongoDB
Best JSON-Native or Agentic Workflow
Refractions showcases FIBO's JSON capabilities through:
- Deterministic JSON Control – Every parameter (camera angle, FOV, lighting, color palette) is structured and reproducible
- Multi-Agent Pipeline – AI agents plan variants, critique outputs, and auto-refine prompts based on visual analysis
- Interactive JSON Editing – Real-time structured prompt editing with diff visualization and one-click regeneration
- Upload & Generate – Provide a product image + style brief → generate 4 editorial shots (hero, detail, flatlay, environment)
- AI Critique & Auto-Refine – Agent analyzes generated images, suggests improvements, and regenerates with refined JSON prompts
- Dynamic Variants – One-click generation of lighting, camera, or composition variants with deterministic seed control
- JSON Comparison Viewer – Side-by-side diff highlighting to track prompt changes across edits
- Variant Planner – Analyzes shot type and suggests relevant parameter variants
- Visual Critic – Evaluates generated images against brand guidelines and composition rules
- Prompt Refiner – Rewrites structured prompts based on critique feedback
- Docker (for backend)
- Node.js 18+ (for frontend)
- Google Cloud credentials (for storage & Gemini)
- Bria API token (get from bria.ai)
-
Clone the repository
git clone https://github.com/daria425/refractions.git cd refractions/api -
Configure environment variables Create a
.envfile in theapi/directory:BRIA_API_TOKEN=your_bria_token STORAGE_SERVICE_ACCOUNT_KEY_PATH=./credentials/storage_service_key.json VERTEXAI_SERVICE_ACCOUNT_KEY_PATH=./credentials/vertexai_service_key.json MONGO_URI=your_mongodb_connection_string MONGO_DB_NAME=refractions
-
Add Google Cloud credentials Place your service account JSON files in
api/credentials/:storage_service_key.json(for GCS)vertexai_service_key.json(for Gemini)
-
Build and run with Docker
chmod +x build.sh clean_rebuild.sh ./clean_rebuild.sh
The API will start on
http://localhost:8000- Docs:
http://localhost:8000/docs - Health check:
http://localhost:8000/health
- Docs:
-
Navigate to frontend
cd ../frontend -
Install dependencies
npm install
-
Configure environment Create a
.envfile:VITE_API_URL=http://localhost:8000
-
Start dev server
npm run dev
Frontend runs on
http://localhost:5173
- Upload a product image and enter a style brief (e.g., "minimalist studio shot, soft shadows")
- Generate initial editorial shots (hero, detail, flatlay, environment)
- Select an image and click "Improve with AI" for auto-critique and refinement
- Edit structured prompts directly or use Auto-Edit to generate variants
- Compare JSON diffs to see exactly what changed between versions
- JSON Editor: Click "Advanced JSON Editor" → modify camera, lighting, color parameters → Apply
- Auto-Variants: Click "Auto-Edit" → select variant group (e.g., "lighting_contrast") → Generate All
- Compare JSON: Click "Compare JSON" to view side-by-side structured prompt diffs with change highlighting
User Input (image + brief)
↓
[Planning Agent] → Generate structured prompts for 4 shot types
↓
[FIBO Generator] → Render images from JSON prompts
↓
[Critique Agent] → Analyze outputs, suggest improvements
↓
[Refiner Agent] → Rewrite prompts with fixes
↓
[FIBO Regenerator] → Produce refined images
MIT