A comprehensive multi-tenant support ticket system with JWT authentication, role-based access control, tenant data isolation, and workflow integration using n8n.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ React Shell │ │ n8n Workflow │ │ MongoDB │
│ (Frontend) │◄──►│ Engine │◄──►│ Database │
│ Port: 3000 │ │ Port: 5678 │ │ Port: 27017 │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Express API │ │ ngrok Tunnel │ │ Registry │
│ (Backend) │ │ (Webhook) │ │ (Screens) │
│ Port: 5007 │ │ Port: 4040 │ │ JSON Config │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Docker and Docker Compose
- Node.js 18+ (for local development)
git clone <repository-url>
cd FlowBitdocker-compose up -dThis will start:
- MongoDB (Port 27017)
- Express API (Port 5007)
- React Frontend (Port 3000)
- n8n Workflow Engine (Port 5678)
- ngrok Tunnel (Port 4040)
# Wait for services to be ready, then run:
docker-compose exec backend npm run seed- Frontend: http://localhost:3000
- n8n: http://localhost:5678
- ngrok Dashboard: http://localhost:4040
After running the seed script, you can login with:
- Admin: admin@logisticsco.com / admin123
- User: user@logisticsco.com / admin123
- Admin: admin@retailgmbh.com / admin123
- User: user@retailgmbh.com / admin123
docker-compose exec backend npm test- Login as different tenants
- Create support tickets
- Verify tenant isolation (Tenant A cannot see Tenant B's data)
- Check admin routes (only accessible by admins)
- Monitor n8n workflow execution
- JWT-based authentication with bcrypt password hashing
- Role-based access control (Admin/User)
- Admin-only routes (
/admin/*) - JWT includes
customerId,role, andemail
- All MongoDB documents include
customerId - Jest unit tests prove tenant isolation
- Tenant A cannot access Tenant B's data
registry.jsonwith tenant-specific screen configurations/me/screensendpoint returns tenant-specific screens- Dynamic navigation based on tenant
- React shell fetches screens from
/me/screens - Sidebar renders dynamically based on tenant
- Support for Module Federation (configured)
- n8n container integrated in docker-compose
POST /api/ticketstriggers n8n workflow- n8n calls back to
/webhook/ticket-donewith secret - UI updates via polling (5-second intervals)
- Complete docker-compose setup
- All services auto-configured
- No manual steps required
# Backend
MONGO_URI=mongodb://admin:password@mongo:27017/flowbit?authSource=admin
JWT_SECRET=your-super-secret-jwt-key-change-in-production
N8N_WEBHOOK_URL=http://n8n:5678/webhook/ticket-created
WEBHOOK_SECRET=flowbit-webhook-secret-2024
# Frontend
VITE_API_BASE_URL=http://localhost:5007[
{ "tenant": "LogisticsCo", "screenUrl": "/support" },
{ "tenant": "RetailGmbH", "screenUrl": "/tickets" }
]FlowBit/
├── backend/
│ ├── controllers/ # API controllers
│ ├── middleware/ # Auth & admin middleware
│ ├── models/ # MongoDB schemas
│ ├── routes/ # API routes
│ ├── tests/ # Jest unit tests
│ ├── utils/ # JWT utilities
│ ├── registry.json # Tenant screen registry
│ └── seed.js # Database seeding
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ └── auth.js # Auth utilities
│ └── vite.config.js # Vite + Module Federation
└── docker-compose.yml # All services
- Module Federation: Currently configured but the remote SupportTicketsApp is served from the same shell for simplicity
- n8n Workflow: Basic webhook setup - in production, you'd want more sophisticated workflow logic
- Security: JWT secret is hardcoded - should use environment variables in production
- Error Handling: Basic error handling - production would need more robust error management
- WebSocket: UI updates use polling instead of WebSocket for simplicity
- ngrok: Requires auth token for production use
- Security: Use strong JWT secrets and HTTPS
- Database: Use MongoDB Atlas or managed MongoDB service
- Monitoring: Add logging and monitoring (Winston, Sentry)
- CI/CD: Add GitHub Actions for automated testing
- Load Balancing: Use nginx or similar for production deployment
- Backup: Implement database backup strategies