A boilerplate project for creating React Flow applications with Python backend support using Poetry.
- React Flow for interactive node-based diagrams
- Poetry for Python dependency management
- FastAPI backend for data persistence
- Complete project structure for quick development
- Pre-configured with essential dependencies
- Docker support for development and production
- CI/CD pipeline with GitHub Actions
react-flow-testbed/
├── .github/ # GitHub-specific configurations
│ └── workflows/ # GitHub Actions workflows
│ └── ci-cd.yml # CI/CD pipeline configuration
│
├── backend/ # Python backend code
│ ├── app.py # FastAPI application entry point
│ └── database.py # Database configuration and models
│
├── public/ # Static assets for React
│ ├── favicon.ico # Website favicon
│ ├── index.html # HTML template
│ └── manifest.json # Web app manifest
│
├── scripts/ # Helper scripts
│ └── start-dev.sh # Script to start development environment
│
├── src/ # React source code
│ ├── components/ # React components
│ │ ├── nodes/ # Custom node components
│ │ │ └── CustomNode.js # Example custom node
│ │ ├── BasicFlow.js # Basic React Flow implementation
│ │ └── NodeRegistry.js # Node types registration
│ │
│ ├── utils/ # Frontend utility functions
│ │ ├── api.js # API service for backend communication
│ │ └── flowValidator.js # Flow validation utilities
│ │
│ ├── App.css # Main application styles
│ ├── App.js # Main application component
│ └── index.js # Application entry point
│
├── utils/ # Shared utility functions
│ └── flow_parser.py # Python utility for parsing flows
│
├── .env # Environment variables
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Production Docker configuration
├── Dockerfile.dev # Development Docker configuration
├── package.json # JavaScript project configuration
└── pyproject.toml # Python project configuration
- Node.js and npm
- Python 3.12+
- Poetry (Python package manager)
- Docker (optional, for containerized development)
-
Clone this repository:
git clone https://github.com/yourusername/react-flow-testbed.git cd react-flow-testbed
-
Install frontend dependencies:
npm install
-
Install backend dependencies using Poetry:
poetry install poetry shell
-
Set up environment variables:
cp .env.example .env
Edit
.env
file to configure your environment.
-
Clone this repository:
git clone https://github.com/yourusername/react-flow-testbed.git cd react-flow-testbed
-
Build and start containers:
docker-compose up -d dev
-
Start the backend server:
# Make sure you're in the Poetry shell cd backend uvicorn app:app --reload --port 8000
-
In another terminal, start the frontend server:
npm start
-
Alternatively, use the development script:
# Make the script executable chmod +x scripts/start-dev.sh # Run the script ./scripts/start-dev.sh
-
Access the application at http://localhost:3000
# For development
docker-compose up dev
# For production
docker-compose up prod
- The interface allows you to create, save, and load flow diagrams.
- Drag nodes onto the canvas to create a flow.
- Connect nodes by dragging from one handle to another.
- Use the panel buttons to save your flow to the backend or load a previously saved flow.
You can create custom node types by:
- Creating a new component in the
src/components/nodes/
directory - Registering the node type in
src/components/NodeRegistry.js
Example custom node:
// In src/components/nodes/MyCustomNode.js
import React, { memo } from 'react';
import { Handle, Position } from 'reactflow';
function MyCustomNode({ data }) {
return (
<div style={{ background: '#f0f0f0', padding: '10px', borderRadius: '5px' }}>
<Handle type="target" position={Position.Top} />
<div>{data.label}</div>
<Handle type="source" position={Position.Bottom} />
</div>
);
}
export default memo(MyCustomNode);
// Then in src/components/NodeRegistry.js
import MyCustomNode from './nodes/MyCustomNode';
export const nodeTypes = {
customNode: CustomNode,
myCustomNode: MyCustomNode,
};
The backend provides the following endpoints:
GET /
: Check if the API is runningGET /flows
: List all saved flowsGET /flows/{flow_id}
: Get a specific flow (use "latest" for the most recent)POST /flows
: Save a new flowDELETE /flows/{flow_id}
: Delete a flow
-
Build the React frontend:
npm run build
-
Configure your production environment variables.
-
Start the backend server:
cd backend uvicorn app:app --host 0.0.0.0 --port 8000
# Build production image
docker build -t react-flow-testbed .
# Run container
docker run -p 8000:8000 react-flow-testbed
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.