A modern, AI-powered node-based workflow builder for creating and managing prompt flows with a beautiful glassmorphism UI.
- Drag-and-drop interface powered by React Flow
- Two node types: Prompt Nodes and Task Nodes
- Visual connections between nodes with conditional transitions
- Real-time edge synchronization with node changes
- Google Gemini integration for intelligent flow creation
- Natural language prompts to generate workflows
- Context-aware suggestions based on existing flow
- Automatic node positioning and connection logic
- Inline text editing for titles and prompts
- Variable system with
{{variable}}syntax - Conditional transitions with custom conditions
- Connection status indicators with purple glow effects
- Drag-and-drop connections via transition handles
- Simple task management with title and description
- Clean, focused interface for general tasks
- Consistent styling with the overall theme
- Local storage persistence - flows survive page refreshes
- Save/Load functionality with one-click operations
- JSON export/import for flow data
- Circular dependency validation to prevent invalid flows
- Collapsible sidebar with quick actions
- Triple-dot menus for node-specific actions
- Plus icons for quick addition of variables/transitions
- Toast notifications for all user feedback
- Keyboard shortcuts (Enter to save, Escape to cancel)
- Framework: Next.js 15.5.0
- UI Library: React 19.1.0
- Styling: Tailwind CSS 4
- Flow Editor: React Flow 12.8.4
- Icons: React Icons 5.5.0
- AI Integration: Google Generative AI 0.24.1
- Notifications: React Toastify 11.0.5
- Node.js 18.18.0 or higher
- npm, yarn, pnpm, or bun
-
Clone the repository
git clone <repository-url> cd sarvam-frontend
-
Install dependencies
npm install # or yarn install # or pnpm install
-
Set up environment variables
# Create .env file echo "GEMINI_API_KEY=your_gemini_api_key_here" > .env
-
Start the development server
npm run dev # or yarn dev # or pnpm dev
-
Open your browser Navigate to http://localhost:3000
- Visit Google AI Studio
- Sign in with your Google account
- Create a new API key
- Copy the key to your
.envfile
-
Add a Prompt Node
- Click "Add Prompt Node" in the sidebar
- Edit the title by clicking on it
- Add your prompt text in the text area
- Add variables using the
{{variable}}syntax
-
Add Variables
- Click the "+" icon next to "Variables"
- Type the variable name and press Enter
- Variables automatically appear in your prompt
-
Create Transitions
- Click the "+" icon next to "Transitions"
- Edit the condition text (e.g., "user says yes")
- Drag from the green handle to connect to another node
-
Add Task Nodes
- Click "Add Task Node" in the sidebar
- Add a description for the task
- Connect it to other nodes as needed
-
Type a natural language prompt in the sidebar input
- Example: "Create a customer support flow"
- Example: "Add a welcome node at the beginning"
-
Click Generate and watch the AI create your flow
-
The AI will:
- Preserve your existing nodes
- Add new nodes with proper positioning
- Create logical connections
- Add appropriate variables and transitions
- Save Flow: Click the save icon in the sidebar
- Clear Flow: Click the trash icon (with confirmation)
- Auto-save: Flows are automatically saved to local storage
components/
βββ nodes/
β βββ BaseNode.js # Reusable node functionality
β βββ PromptNode.js # AI prompt nodes
β βββ TaskNode.js # General task nodes
βββ FlowCanvas.js # React Flow container
βββ Sidebar.js # Navigation and controls
pages/
βββ index.js # Main dashboard
βββ _app.js # App wrapper with toast container
βββ api/
βββ ai-generate.js # Gemini AI integration
utils/
βββ toast.js # Toast notification utilities
// Reusable hook for all node types
export const useBaseNode = (id, data) => {
// Common state and handlers
return { isEditing, handleUpdate, handleDelete, ... };
};
// Reusable UI components
export const BaseNodeContainer = ({ children, ... }) => { ... };
export const BaseNodeHeader = ({ title, menuItems, ... }) => { ... };// Configurable AI prompt at top of file
const AI_SYSTEM_PROMPT = `
You are a React Flow diagram assistant...
{{currentFlow}}
{{userPrompt}}
`;
// Template-based prompt generation
const flowContext = AI_SYSTEM_PROMPT
.replace('{{currentFlow}}', JSON.stringify(currentFlow, null, 2))
.replace('{{userPrompt}}', prompt);-
Create a new node component:
import { useBaseNode, BaseNodeContainer, BaseNodeHeader } from './BaseNode'; export default function CustomNode({ id, data }) { const baseNode = useBaseNode(id, data); return ( <BaseNodeContainer> <BaseNodeHeader title={data.title} menuItems={[]} /> {/* Custom content */} </BaseNodeContainer> ); }
-
Register in FlowCanvas.js:
const nodeTypes = { promptNode: PromptNode, taskNode: TaskNode, customNode: CustomNode, // Add your new node type };
Edit the AI_SYSTEM_PROMPT constant in pages/api/ai-generate.js:
const AI_SYSTEM_PROMPT = `
You are a specialized assistant for...
// Modify the prompt to change AI behavior
`;npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server- Components: Use the base node architecture for consistency
- Styling: Follow the glass theme patterns
- State Management: Use React hooks and local state
- API Routes: Keep AI logic in dedicated API routes
- Toast Messages: Use the toast utility for all user feedback
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- React Flow for the excellent flow editor
- Google Gemini for AI capabilities
- Tailwind CSS for the utility-first styling
- Next.js for the robust framework
- React Icons for the beautiful icon set
Built with β€οΈ using modern web technologies
For questions or support, please open an issue on GitHub.