A comprehensive visual workflow platform for creating and executing AI-powered image generation workflows using Bria AI's v2 APIs. The platform provides a node-based interface built with ReactFlow, enabling users to design complex image generation pipelines with real-time execution monitoring and approval workflows.
- Visual Workflow Builder: Drag-and-drop interface using ReactFlow for creating complex image generation workflows
- Node-Based Architecture: Support for GenerateImageV2, StructuredPromptV2, and RefineImageV2 node types
- User Approval Workflows: Interactive approval system for structured prompt generation with editing capabilities
- Real-Time Execution: Asynchronous workflow execution with live status updates and progress tracking
- Comprehensive History: Complete execution snapshots with downloadable generated images
- JWT Authentication: Secure user authentication and authorization system
- Responsive UI: Modern React interface built with Tailwind CSS and shadcn/ui components
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ React Frontend │ │ FastAPI Backend │ │ Bria AI APIs │
│ (ReactFlow) │◄──►│ (PostgreSQL) │◄──►│ (v2 Endpoints)│
└─────────────────┘ └──────────────────┘ └─────────────────┘
Backend:
- FastAPI with async/await support
- PostgreSQL with SQLAlchemy ORM
- JWT authentication with bcrypt password hashing
- Alembic for database migrations
- HTTPX for Bria API integration
- Comprehensive error handling and logging
Frontend:
- React 18 with TypeScript
- ReactFlow for visual workflow editing
- Tailwind CSS with shadcn/ui components
- React Query for server state management
- React Hook Form with Zod validation
- Axios for API communication
Infrastructure:
- Docker Compose for development environment
- PostgreSQL 15 database
- Redis for caching and session management
bria-workflow-platform/
├── backend/ # FastAPI backend application
│ ├── app/
│ │ ├── api/ # API routes and endpoints
│ │ ├── core/ # Core functionality (auth, config, deps)
│ │ ├── models/ # SQLAlchemy database models
│ │ ├── schemas/ # Pydantic models for validation
│ │ ├── services/ # Business logic layer
│ │ ├── clients/ # External API clients (Bria)
│ │ └── management/ # CLI commands and utilities
│ ├── alembic/ # Database migrations
│ ├── tests/ # Backend test suite
│ ├── requirements.txt # Python dependencies
│ └── alembic.ini # Alembic configuration
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── pages/ # Route components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── contexts/ # React context providers
│ │ ├── lib/ # Utility functions and API client
│ │ └── utils/ # Helper utilities
│ ├── public/ # Static assets
│ ├── package.json # Node.js dependencies
│ └── vite.config.ts # Vite configuration
├── logs/ # Application logs
├── docker-compose.yml # Development environment
└── README.md # This file
- Node.js 18+ and npm
- Python 3.11+
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone <repository-url> cd bria-workflow-platform
-
Start the development environment:
docker-compose up -d
-
Set up the backend:
cd backend # Create virtual environment python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Install dependencies pip install -r requirements.txt # Copy environment file and configure cp .env.example .env # Edit .env with your Bria API credentials # Run database migrations alembic upgrade head # Seed initial node types python -m app.management.commands.seed_nodes
-
Set up the frontend:
cd frontend # Install dependencies npm install # Copy environment file cp .env.example .env # Configure frontend environment variables
-
Start the development servers:
# Terminal 1: Backend cd backend uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 # Terminal 2: Frontend cd frontend npm run dev
Backend (.env):
# Database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/bria_workflow
# Security
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Bria API
BRIA_API_KEY=your-bria-api-key
BRIA_BASE_URL=https://api.bria.ai/v2
# Logging
LOG_LEVEL=INFOFrontend (.env):
VITE_API_BASE_URL=http://localhost:8000
VITE_APP_NAME=Bria Workflow PlatformNote: This application is deployed on Render's free tier. The server may go to sleep after periods of inactivity, causing the first request to take 50-60 seconds to load. Please be patient while the server wakes up.
-
Backend API:
http://localhost:8000- Interactive API docs:
http://localhost:8000/docs - ReDoc documentation:
http://localhost:8000/redoc
- Interactive API docs:
-
Frontend Application:
http://localhost:3000 -
Database:
localhost:5432- Username:
postgres - Password:
postgres - Database:
bria_workflow
- Username:
The application is containerized and ready for production deployment. Ensure you:
- Set secure environment variables
- Configure proper database connections
- Set up SSL/TLS certificates
- Configure reverse proxy (nginx/Apache)
- Set up monitoring and logging
cd backend
# Run all tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
# Run specific test file
pytest tests/test_workflow_endpoints.py
# Run property-based tests
pytest tests/ -k "property"cd frontend
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run with coverage
npm test -- --coverage
# Run property-based tests
npm test -- --testNamePattern="Property"# Run integration tests
python backend/tests/test_integration_e2e.py
npm test frontend/src/test/integration-e2e.test.tsxPOST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginGET /api/v1/auth/me- Get current user
GET /api/v1/workflows- List user workflowsPOST /api/v1/workflows- Create new workflowGET /api/v1/workflows/{id}- Get workflow detailsPUT /api/v1/workflows/{id}- Update workflowDELETE /api/v1/workflows/{id}- Delete workflow
POST /api/v1/workflows/{id}/runs- Execute workflowGET /api/v1/workflow-runs- List workflow runsGET /api/v1/workflow-runs/{id}- Get run detailsPOST /api/v1/workflow-runs/{id}/approve- Approve structured prompt
GET /api/v1/nodes- List available node typesPOST /api/v1/nodes- Create custom node type (admin)
Generates images using Bria's image generation API.
Inputs:
prompt(string): Text description for image generationimages(array): Reference images for style/contentstructured_prompt(object): Structured prompt from StructuredPromptV2 node
Outputs:
image(string): Generated image URLseed(number): Random seed used for generationstructured_prompt(object): Generated structured prompt
Creates structured prompts with user approval workflow.
Inputs:
prompt(string): Base text promptimage(string): Reference image for prompt generation
Outputs:
structured_prompt(object): User-approved structured prompt
Special Behavior: Pauses execution for user review and approval.
Refines existing images while preserving structure.
Inputs:
image(string): Image to refineprompt(string): Refinement instructionsstructured_prompt(object): Optional structured prompt
Outputs:
image(string): Refined image URLstructured_prompt(object): Generated structured prompt
-
Database Connection Errors
- Ensure PostgreSQL is running:
docker-compose ps - Check connection string in
.env - Verify database exists:
docker-compose exec postgres psql -U postgres -l
- Ensure PostgreSQL is running:
-
Bria API Integration Issues
- Verify API key in backend
.env - Check API endpoint availability
- Review logs in
logs/app.log
- Verify API key in backend
-
Frontend Build Errors
- Clear node_modules:
rm -rf node_modules && npm install - Check Node.js version compatibility
- Verify environment variables
- Clear node_modules:
-
Authentication Problems
- Check JWT secret key configuration
- Verify token expiration settings
- Clear browser localStorage/cookies
Application logs are available in:
logs/app.log- General application logslogs/errors.log- Error-specific logs- Browser console - Frontend debugging
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
npm test && pytest - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Backend: Black, isort, flake8, mypy
- Frontend: ESLint, Prettier, TypeScript strict mode
- Testing: Comprehensive unit and property-based tests required
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Check the API Documentation
- Review the troubleshooting section
- Check existing GitHub Issues
- Create a new issue with detailed information