Complete workflow management application with password-protected access, Firebase hosting, Supabase database, and Cloudflare Workers API.
visual-workflow-router/
βββ src/
β βββ app/
β β βββ pass/page.tsx # Password gate
β β βββ workflows/page.tsx # Workflow library
β β βββ api/pass/route.ts # Password verification
β β βββ globals.css
β β βββ layout.tsx
β β βββ page.tsx
β βββ lib/
β β βββ supabase.ts # Supabase client
β β βββ api.ts # API utilities
β β βββ utils.ts # Helper functions
β βββ types/index.ts # TypeScript types
β βββ components/ # UI components (empty, ready for you)
β βββ middleware.ts # Route protection
βββ cloudflare-workers/
β βββ workflow-api/
β βββ src/index.ts # API endpoints
β βββ wrangler.toml # Worker config
β βββ package.json
β βββ tsconfig.json
βββ supabase/
β βββ migrations/
β βββ 001_initial_schema.sql # Database schema + sample data
βββ public/ # Static assets
βββ package.json
βββ next.config.js
βββ tsconfig.json
βββ tailwind.config.js
βββ firebase.json
βββ .env.local.example
npm install
cd cloudflare-workers/workflow-api && npm install && cd ../..# Copy example file
cp .env.local.example .env.local
# Generate password hash
echo -n "YourSecurePassword" | openssl dgst -sha256 -hex
# Copy the hex output
# Edit .env.local and add:
# - NEXT_PUBLIC_SUPABASE_URL
# - NEXT_PUBLIC_SUPABASE_ANON_KEY
# - NEXT_PUBLIC_CF_WORKER_URL
# - ACCESS_PASSWORD_HASH (the hash you just generated)- Create project at https://supabase.com
- Go to SQL Editor
- Paste and run
supabase/migrations/001_initial_schema.sql - Verify: You should see 3 workflows in the
workflowtable - Copy URL and anon key to
.env.local
cd cloudflare-workers/workflow-api
# Login
wrangler login
# Create KV namespace for rate limiting
wrangler kv:namespace create "KV_RATE_LIMIT"
# Copy the ID and update wrangler.toml
# Set secrets
wrangler secret put SUPABASE_URL
wrangler secret put SUPABASE_SERVICE_ROLE_KEY
wrangler secret put OPENAI_API_KEY
wrangler secret put ACCESS_PASSWORD_HASH
wrangler secret put ACCESS_COOKIE_SECRET
# Deploy
wrangler deploy
# Copy the worker URL to .env.local as NEXT_PUBLIC_CF_WORKER_URL
cd ../..npm run devVisit http://localhost:3000
The app is protected with a password gate:
- First visit redirects to
/pass - Enter password (hash stored in
ACCESS_PASSWORD_HASH) - Cookie set for 30 days
- Access granted to all routes
To test: Use the password you hashed in step 2.
# Install Firebase CLI
npm install -g firebase-tools
# Login
firebase login
# Initialize (select hosting, set public dir to "out")
firebase init hosting
# Build and deploy
npm run build
firebase deployYour app will be live at https://your-project.web.app
The migration creates these tables:
workflow- Workflow metadatanode- Workflow nodes (action, decision, exception, human, terminal)edge- Connections between nodestag- Tags for categorizationworkflow_tag- Workflow-tag relationshipsnode_tag- Node-tag relationshipsrun- Simulation runsrun_event- Events during runs
Sample data included: 3 workflows with nodes and edges.
Your Cloudflare Worker provides:
GET /health # Health check
GET /workflows # List all workflows
GET /workflows/:id # Get single workflow
To add more endpoints: Edit cloudflare-workers/workflow-api/src/index.ts
The foundation is complete! Add these features:
# React Flow is already installed
# Create src/app/workflows/[id]/page.tsx
# - Add React Flow canvas
# - Load/save nodes and edges
# - Drag-and-drop editing# Install shadcn/ui
npx shadcn-ui@latest init
npx shadcn-ui@latest add sheet tabs input textarea
# Create src/components/workflow/NodeDrawer.tsx# Add to Worker: POST /ai/workflow/generate
# Use OpenAI to generate workflow from prompt
# Frontend: Modal with text input -> create workflow# Add to Worker: POST /ai/workflow/report
# Generate reports using docx library
# Upload to Supabase Storage
# Return download link# Test password API
curl -X POST http://localhost:3000/api/pass \
-H "Content-Type: application/json" \
-d '{"password":"test"}'
# Test Worker (after deploy)
curl https://workflow-api.your-subdomain.workers.dev/health
curl https://workflow-api.your-subdomain.workers.dev/workflows# Frontend (.env.local)
NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbG...
NEXT_PUBLIC_CF_WORKER_URL=https://workflow-api.xxx.workers.dev
ACCESS_PASSWORD_HASH=abc123...
ACCESS_COOKIE_NAME=vwf_access
# Worker (via wrangler secret)
SUPABASE_URL
SUPABASE_SERVICE_ROLE_KEY
OPENAI_API_KEY
ACCESS_PASSWORD_HASH
ACCESS_COOKIE_SECRET- β SHA-256 password hashing
- β Constant-time comparison
- β HttpOnly cookies
- β Secure cookie flags (production)
- β Middleware route protection
- β 30-day session expiry
"Missing Supabase environment variables"
- Check
.env.localexists and has correct values - Restart dev server:
npm run dev
Password not working
- Regenerate hash:
echo -n "YourPassword" | openssl dgst -sha256 -hex - Update
.env.local - Clear browser cookies
Worker not responding
- Check deployment:
wrangler deployments list - View logs:
wrangler tail - Verify secrets:
wrangler secret list
Build errors
- Clear cache:
rm -rf .next out - Reinstall:
rm -rf node_modules && npm install
See also:
- Enhanced Specification (../enhanced-workflow-spec.md)
- Installation Checklist (../installation-checklist.md)
- Quick Reference (../quick-reference.md)
- β Password gate with 30-day session
- β Workflow library with search
- β Database schema with sample data
- β Cloudflare Worker API
- β TypeScript throughout
- β Tailwind CSS styling
- β Firebase hosting config
- β Next.js static export
npx shadcn-ui@latest init
npx shadcn-ui@latest add button card dialog input label select table tabs toast sheet dropdown-menu badge alertThis is a complete working foundation. All core infrastructure is ready. Build your features on top!
Built with: Next.js β’ React β’ TypeScript β’ Tailwind CSS β’ Supabase β’ Cloudflare Workers β’ Firebase
Update
Visual Workflow Router is a web application designed to create, visualize, and manage workflows. This project provides a user-friendly interface for defining workflows, including nodes and edges, and rendering them as graphs.
- Project scaffolding with a modular architecture
- Base data schema for workflows, nodes, and edges
- Design tokens for consistent styling
- Local storage management for saving and loading workflow data
- Initial graph rendering capabilities
- Node.js (version 14 or higher)
- npm (Node Package Manager)
- Clone the repository:
git clone https://github.com/yourusername/visual-workflow-router-v0.1.git - Navigate to the project directory:
cd visual-workflow-router-v0.1 - Install the dependencies:
npm install
To start the development server, run:
npm run dev
The application will be available at http://localhost:3000.
src/app: Contains the main application layout and API routes.src/components: Contains reusable components for the application, including graph rendering and UI elements.src/hooks: Custom hooks for managing application state and local storage.src/lib: Utility functions and configurations for interacting with the backend and managing data.src/schema: SQL schema definitions for the database.src/styles: CSS files for design tokens and global styles.db/migrations: Database migration scripts.scripts: Utility scripts for repository setup and data seeding.tasks: Documentation for project tasks and features.tests: Unit tests for ensuring application functionality.
- Repository Setup: Follow the instructions in
tasks/01-repo-setup.mdto set up the repository. - Design Tokens: Implement design tokens as described in
tasks/02-design-tokens.md. - Base Data Schema: Define the base data schema for workflows in
tasks/03-base-data-schema.md. - Local Storage: Implement local storage functionality as outlined in
tasks/04-local-storage.md. - First Graph Render: Follow the steps in
tasks/05-first-graph-render.mdto render the first graph.
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.