FormChat is an intelligent chatbot system that guides users through dynamic form completion using advanced AI agents. The system leverages JSON Schema configuration with custom extensions to create sophisticated, conditional forms with real-time validation and calculations.
- Backend: LangGraph + LangChain (Multi-agent orchestration)
- Frontend: LobeChat (Modern chat interface with custom plugins)
- Database: PostgreSQL + Redis (Data persistence and caching)
- Deployment: Railway (Cloud deployment)
- Configuration: JSON Schema + Pydantic (Dynamic validation)
- π€ Multi-Agent System: Specialized agents for orchestration, validation, calculation, and file processing
- π Dynamic Forms: JSON Schema-driven forms with conditional logic and calculations
- π Plugin Architecture: Modular LobeChat plugins for enhanced functionality
- β‘ Real-time Communication: WebSocket integration for instant feedback
- π Multi-language Support: Internationalization with dynamic translation
- π RGPD Compliance: Built-in data protection and privacy controls
- π Google Integration: Automatic export to Google Sheets and Drive
- Python 3.11+
- Node.js 18+ (for LobeChat frontend)
- PostgreSQL 14+
- Redis 6+
- Clone the repository
git clone https://github.com/your-username/formchat.git
cd formchat- Backend Setup
./setup-dev.sh# Using uv (recommended)
uv venv
uv pip install -r requirements.txt
uv pip install -r requirements-dev.txt
# Or using pip
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
pip install -r requirements-dev.txt# Installation complète en mode développement
uv pip install -e ".[dev]"- Frontend Setup
cd frontend
npm install- Database Setup
# Start PostgreSQL and Redis
# Configure database connection in config/database.yaml
uv run python scripts/setup_database.py- Run the Application
# Start backend
uv run python backend/main.py
# Start frontend (in another terminal)
cd frontend
npm run devformchat/
βββ backend/ # LangGraph + LangChain backend
β βββ agents/ # Multi-agent system
β βββ config/ # JSON Schema parser and validation
β βββ models/ # Data models and schemas
β βββ services/ # Business logic services
β βββ api/ # FastAPI endpoints + WebSocket
βββ frontend/ # LobeChat frontend
β βββ plugins/ # Custom FormChat plugins
β βββ themes/ # UI themes and personas
β βββ integrations/ # LangGraph connectors
βββ config/ # Configuration files
β βββ forms/ # JSON Schema form definitions
β βββ schemas/ # Validation schemas
β βββ locales/ # Translation files
β βββ lobechat/ # LobeChat configuration
βββ storage/ # File storage and sessions
βββ deployment/ # Docker and Railway configs
βββ docs/ # Documentation
FormChat extends JSON Schema with custom properties:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "Registration Form",
"properties": {
"email": {
"type": "string",
"format": "email",
"title": "Email Address"
},
"age": {
"type": "integer",
"minimum": 18,
"maximum": 100,
"title": "Age"
}
},
"x-calculations": {
"eligibility_score": {
"formula": "age >= 18 ? 100 : 0",
"description": "Calculate eligibility based on age"
}
},
"x-conditional": {
"additional_info": {
"condition": "age >= 65",
"action": "show",
"message": "Additional information required for seniors"
}
},
"x-persona": {
"name": "Marie",
"avatar": "professional_woman",
"tone": "friendly_professional",
"language": "fr"
}
}Create a .env file in the root directory:
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/formchat
REDIS_URL=redis://localhost:6379
# AI Models
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
GOOGLE_AI_API_KEY=your_google_key
# Google Integration
GOOGLE_SHEETS_CREDENTIALS=path/to/credentials.json
GOOGLE_DRIVE_FOLDER_ID=your_folder_id
# Security
SECRET_KEY=your_secret_key
ENCRYPTION_KEY=your_encryption_key
# Deployment
RAILWAY_ENVIRONMENT=production- Form Orchestrator: Manages conversation flow and form progression
- Field Validator: Validates user input with real-time feedback
- Calculation Engine: Performs dynamic calculations based on form data
- File Processor: Handles file uploads and processing
- Export Manager: Manages data export to Google services
from backend.agents.base_agent import BaseAgent
class CustomAgent(BaseAgent):
def __init__(self, config: Dict[str, Any]):
super().__init__("custom_agent", config)
async def process(self, message: Dict[str, Any]) -> Dict[str, Any]:
# Custom processing logic
return {"result": "processed"}from frontend.plugins.base_plugin import BaseFormChatPlugin
class MyCustomPlugin(BaseFormChatPlugin):
def __init__(self, **kwargs):
super().__init__("my_custom_plugin", **kwargs)
async def process_message(self, message: Dict[str, Any]) -> Dict[str, Any]:
# Plugin logic
return {"type": "response", "content": "Plugin response"}- FormChat Agent: Main conversation handler
- File Upload: File processing and validation
- Real-time Validation: Instant field validation
- Progress Tracker: Form completion tracking
- Calculation Display: Dynamic calculation results
- Create translation file in
config/locales/ - Update language configuration in
config/lobechat/persona_configs.yaml - Test with different language personas
{
"chat": {
"welcome": "Bonjour ! Je suis {name}, votre assistante pour ce formulaire.",
"field_success": "Parfait ! Passons Γ la question suivante.",
"validation_error": "Il semble y avoir une erreur. Pouvez-vous vΓ©rifier ?"
},
"validation": {
"required": "Ce champ est obligatoire",
"email_format": "Veuillez entrer une adresse email valide"
}
}- Connect to Railway
railway login
railway link- Configure Environment Variables
railway variables set DATABASE_URL=your_production_db_url
railway variables set REDIS_URL=your_production_redis_url
# ... other variables- Deploy
railway up# Build and run with Docker Compose
docker-compose up --build- 3000 concurrent users
- < 200ms API response time
- 99.9% uptime
- Multi-language support (5+ languages)
- File upload up to 10MB
The application includes comprehensive monitoring:
- Application logs via structured logging
- Performance metrics via Prometheus
- Health checks for all services
- Error tracking and alerting
- Data encryption at rest and in transit
- User consent management
- Right to be forgotten implementation
- Data anonymization for exports
- Audit trail for all data operations
- Input validation and sanitization
- Rate limiting and DDoS protection
- Secure file upload handling
- API authentication and authorization
- Migration Guide : MIGRATION_GUIDE.md - Guide pour passer de requirements.txt Γ pyproject.toml
- Development Guide : docs/development.md - Guide de dΓ©veloppement
- API Documentation : docs/api.md - Documentation de l'API
- Plugin Development : docs/plugins.md - DΓ©veloppement de plugins
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
- π§ Email: support@formchat.ai
- π¬ Discord: FormChat Community
- π Documentation: docs.formchat.ai
- π Issues: GitHub Issues
- LangGraph for multi-agent orchestration
- LobeChat for the modern chat interface
- FastAPI for the high-performance API framework
- Railway for seamless deployment
FormChat - Making form completion intelligent and conversational π€β¨