A visual flow builder for creating automation workflows for social media customer service, starting with Instagram comment and DM auto-replies using AI.
socialmediaFlow/
βββ backend/ # FastAPI Python Application
β βββ app/
β β βββ api/ # API route handlers
β β βββ core/ # Core application logic
β β βββ models/ # SQLAlchemy models
β β βββ schemas/ # Pydantic schemas
β β βββ main.py # FastAPI application
β βββ requirements.txt
βββ frontend/ # React + TypeScript Application
β βββ src/
β β βββ components/ # React components
β β β βββ nodes/ # Node components and renderers
β β β βββ edges/ # Edge components for connections
β β β βββ inspector/ # Node inspector and property panels
β β βββ pages/ # Page components
β β βββ services/ # API client services
β β βββ store/ # State management
β β βββ types/ # TypeScript definitions
β βββ package.json
βββ Doc/ # Documentation
βββ Makefile # Development commands
- Python 3.8+
- Node.js 16+
- npm or yarn
- Clone the repository
git clone <repository-url>
cd socialmediaFlow- Install dependencies
make install- Set up environment variables
cp .env.example .env
# Edit .env with your configurationStart both backend and frontend:
make devOr start them separately:
Backend only:
make dev-backend
# Runs on http://localhost:8000Frontend only:
make dev-frontend
# Runs on http://localhost:5173Once the backend is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
β Basic Authentication System
- Simple cookie-based authentication (no JWT)
- User registration and login
- Session management
β Flow Management
- Create, read, update, delete flows
- Basic flow data storage
- User-specific flow isolation
β Frontend Interface
- React + TypeScript + Material-UI
- Authentication pages
- Dashboard with flow listing
- Responsive design
- App.tsx: Main application component with routing
- FlowBuilder.tsx: Core flow builder page with React Flow integration
- CustomNodes.tsx: Node type definitions and rendering components
- NodeInspector.tsx: Property panel and node configuration UI
- Local Component State: React's useState for component-specific state
- React Flow State: useNodesState and useEdgesState hooks for flow canvas
- API Services: Axios-based services for backend communication
- Main Canvas: React Flow integration with drag-and-drop support
- Node Library: Sidebar with available node types categorized by function
- Flow Controls: Save, load, and execute flow operations
- Node Types: Trigger, Processor, and Action categories
- Node Instances: Runtime instances with settings and data
- Node Ports: Input and output connection points with data typing
- Property Panel: Dynamic form generation from JSON Schema
- Data Viewer: Input/output data visualization
- Execution History: Node execution status and history
-
Trigger Nodes: Start flow execution (e.g., Instagram comment received)
- Example:
instagram-comment- Triggered when a new Instagram comment is received
- Example:
-
Processor Nodes: Process data (e.g., AI text generation)
- Example:
ai-response- Generates AI responses based on input text
- Example:
-
Action Nodes: Perform actions (e.g., post reply)
- Example:
instagram-reply- Posts a reply to an Instagram comment
- Example:
Each node type consists of:
- Metadata: ID, name, description, version, icon, color
- Ports: Input and output connection points with data types
- Settings Schema: JSON Schema defining configuration options
- Execution Logic: Backend implementation for node functionality
Add a new node type definition in the frontend:
// In a service or directly in FlowBuilder.tsx for testing
const myCustomNode: NodeType = {
id: 'my-custom-node',
name: 'My Custom Node',
description: 'Description of what this node does',
category: NodeCategory.PROCESSOR, // or TRIGGER or ACTION
version: '1.0.0',
icon: 'code', // Material-UI icon name
color: '#3F51B5', // Custom color
ports: {
inputs: [
{
id: 'input1',
name: 'input1',
label: 'Input 1',
description: 'First input description',
dataType: NodeDataType.STRING,
required: true
}
],
outputs: [
{
id: 'output1',
name: 'output1',
label: 'Output 1',
description: 'First output description',
dataType: NodeDataType.STRING,
required: true
}
]
},
settingsSchema: {
type: 'object',
properties: {
// Define settings properties with JSON Schema
mySetting: {
type: 'string',
title: 'My Setting',
description: 'Description of this setting'
}
},
required: ['mySetting']
}
};Implement the node type in the backend API:
@startuml title ChatInput Node Implementation Sequence
actor User as "User" participant FlowBuilder as "FlowBuilder.tsx" participant NodeComponentFactory as "NodeComponentFactory.tsx" participant ChatInputNode as "ChatInputNode.tsx" participant NodeService as "nodeService.ts" participant NodeAPI as "nodes.py (API)" participant NodeRegistry as "node_registry.py" participant ChatInputTrigger as "chat_input.py"
User -> FlowBuilder: Adds ChatInput node FlowBuilder -> NodeComponentFactory: getComponentForNodeType("chat_input") NodeComponentFactory -> registry: getNodeComponent("chat_input") registry --> NodeComponentFactory: returns ChatInputNode NodeComponentFactory --> FlowBuilder: ChatInputNode component FlowBuilder -> ChatInputNode: Renders node
User -> ChatInputNode: Configures node\n(sets prompt, variables) User -> FlowBuilder: Executes flow FlowBuilder -> ChatInputNode: handleExecute() ChatInputNode -> NodeService: executeNode(nodeConfig, inputs) NodeService -> NodeAPI: POST /api/v1/nodes/execute NodeAPI -> NodeRegistry: get_node_handler("chat_input") NodeRegistry --> NodeAPI: returns ChatInputTrigger NodeAPI -> ChatInputTrigger: execute(**inputs) ChatInputTrigger --> NodeAPI: returns output NodeAPI --> NodeService: API response NodeService --> ChatInputNode: execution result ChatInputNode --> FlowBuilder: execution complete FlowBuilder --> User: Shows result @enduml
Test your node in the flow builder:
- Ensure backend API is running with your node registered
- Refresh the flow builder UI to load the new node type
- Drag your node from the sidebar onto the canvas
- Configure settings in the node inspector
- Connect it to other nodes
- Test execution
β Phase 1: Basic Structure
- Implement basic app structure
- Set up authentication
- Create flow builder UI foundation
π Phase 2: Node System
- Implement backend node registry system
- Add basic trigger nodes for Instagram
- Build node execution engine
- Connect frontend to backend node API
π Phase 3: Flow Execution
- Implement flow validation
- Create flow execution engine
- Add real-time execution monitoring
- Implement error handling and recovery
π Phase 4: Advanced Features
- Instagram API integration
- LLM and RAG nodes for AI responses
- Flow templates and sharing
- Production deployment and scaling
- FastAPI: Modern, high-performance web framework for building APIs
- SQLAlchemy: SQL toolkit and ORM for database interactions
- SQLite: Lightweight database for development (PostgreSQL for production)
- Pydantic: Data validation and settings management
- React: UI library for building component-based interfaces
- TypeScript: Typed JavaScript for better developer experience
- Material-UI: Component library implementing Material Design
- @xyflow/react: React Flow library for node-based interfaces (previously react-flow-renderer)
- Axios: HTTP client for API requests
- Zustand: Lightweight state management
- AJV: JSON Schema validation for node settings
- Vite: Modern frontend build tool
- ESLint & Prettier: Code quality and formatting
- Docker & Docker Compose: Containerization and local development
- Jest & React Testing Library: Testing framework
- Follow the existing code structure
- Add tests for new features
- Update documentation as needed
- Use conventional commit messages
[Add your license here]