4.3 KiB
4.3 KiB
Reason Flow Setup Guide
This guide will help you set up the Reason Flow AI engineering reasoning system.
Prerequisites
- Node.js (v16 or higher)
- PostgreSQL (v12 or higher)
- Git
Quick Start
1. Clone and Install Dependencies
git clone <repository-url>
cd reason_flow
npm run install-all
2. Environment Configuration
Option A: Interactive Setup (Recommended)
npm run env:setup
Option B: Manual Setup
cp env.example .env
# Edit .env with your configuration
3. Database Setup
npm run db:setup
4. Validate Configuration
npm run config:validate
5. Start Development Server
npm run dev
Detailed Setup
Environment Variables
The system uses environment variables for configuration. Key variables include:
Required Variables
GROQ_API_KEY- Your Groq API key for Kimi K2 modelDB_PASSWORD- PostgreSQL database passwordJWT_SECRET- Secret key for JWT tokens
Optional Variables
OPENAI_API_KEY- For additional AI capabilitiesSERP_API_KEY- For web search functionalityREDIS_URL- For caching (optional)
Database Configuration
The system supports multiple environments:
- Development:
reason_flow_dev - Test:
reason_flow_test - Production:
reason_flow_prod
API Keys Setup
- Groq API Key: Get from Groq Console
- OpenAI API Key: Get from OpenAI Platform
- SERP API Key: Get from SERP API
Available Scripts
Environment Management
npm run env:setup- Interactive environment setupnpm run env:validate- Validate environment configurationnpm run env:show- Show current configuration
Database Management
npm run db:setup- Complete database setupnpm run db:init- Initialize databasenpm run db:reset- Reset databasenpm run db:migrate- Run migrationsnpm run db:seed- Run seedersnpm run db:status- Check database statusnpm run db:info- Show database information
Development
npm run dev- Start development servernpm run dev-full- Start both backend and frontendnpm run test:groq- Test Groq API integration
Configuration
npm run config:validate- Validate all configurationnpm run config:show- Show current configuration
Environment-Specific Configuration
Development
- Debug mode enabled
- Verbose logging
- Relaxed rate limiting
- Hot reload enabled
Production
- Debug mode disabled
- Optimized logging
- Strict rate limiting
- SSL recommended
- Security headers enabled
Test
- Minimal logging
- Test database
- Mock external services
Troubleshooting
Common Issues
-
Database Connection Failed
- Check PostgreSQL is running
- Verify database credentials
- Ensure database exists
-
Groq API Errors
- Verify API key is correct
- Check API quota and limits
- Test connection:
npm run test:groq
-
Configuration Errors
- Run:
npm run config:validate - Check required variables are set
- Verify environment file exists
- Run:
Logs
- Application logs:
./logs/app.log - Error logs:
./logs/error.log - Combined logs:
./logs/combined.log
Health Checks
- API Health:
GET /api/health - Model Status:
GET /api/models/status - Database Status:
npm run db:status
Security Considerations
Production Deployment
-
Change Default Secrets
- Update JWT_SECRET
- Change admin password
- Use strong database passwords
-
Enable SSL
- Set DB_SSL=true
- Use HTTPS in production
- Configure proper CORS origins
-
Environment Variables
- Never commit .env files
- Use secure secret management
- Rotate keys regularly
Monitoring
Health Endpoints
/api/health- Basic health check/api/models/status- Model status/api/feedback/stats- Feedback statistics
Logging
- Structured JSON logging
- Log rotation configured
- Error tracking enabled
Support
For issues and questions:
- Check the logs for errors
- Validate configuration
- Test individual components
- Review the troubleshooting section
Next Steps
After setup:
- Test the API endpoints
- Upload sample documents
- Create test conversations
- Verify model responses
- Set up monitoring