INSTALL FROM SOURCE CODE STEP BY STEP
Prerequisites
Architecture Overview
sysmex consists of two main components:
src/
├── api/ # Backend API service (Flask/Python)
└── cook-web/ # Script editor frontend (Next.js)- api: Backend API service built with Flask
- cook-web: Script editor for creating and managing courses, built with Next.js
Required Tools and Services
- Python 3.11+ for backend API
- Node.js 22.16.0 for frontend applications
- MySQL 8.0+ for database storage
- Redis for caching and session management
- Docker & Docker Compose (recommended for easy deployment)
Required API Keys
At least one LLM provider must be configured:
- OpenAI API Key
- Baidu ERNIE API credentials
- ByteDance Volcengine Ark API Key
- SiliconFlow API Key
- Zhipu GLM API Key
- DeepSeek API Key
- Alibaba Qwen API Key
Optional Services
- Alibaba Cloud OSS for file storage
- Alibaba Cloud SMS for phone verification
- Langfuse for LLM tracking
- Email SMTP for email verification
Installation Steps
Step 1: Clone the Repository
git clone https://github.com/lngyneric/ai-coach.git
cd ai-shifuStep 2: Set Up Environment Variables
Copy the full environment template (already aligned with the Docker defaults):
cp docker/.env.example.full docker/.envFor Docker-based workflows the only mandatory edit is to add at least one LLM provider key (for example OPENAI_API_KEY, ERNIE_API_KEY, GLM_API_KEY, etc.). All other variables already have safe defaults that match the bundled MySQL/Redis services.
Step 3: Configure Environment Variables
Edit the .env file and configure the required settings.
Required Variables (MUST be configured)
These variables are essential for the application to run:
-
Database Connection
SQLALCHEMY_DATABASE_URI: MySQL connection string- Example:
mysql://root:password@localhost:3306/ai-shifu?charset=utf8mb4
-
Security
SECRET_KEY: JWT signing key for authentication- Generate secure key:
python -c "import secrets; print(secrets.token_urlsafe(32))" - Important: Use different keys for dev/test/prod environments
-
LLM Provider (at least one required)
- Choose from: OpenAI, ERNIE, ARK, SiliconFlow, GLM, DeepSeek, Qwen
- See
.env.example.fullfor specific provider configurations
Configuration Reference
docker/.env.example.full: canonical template that lists every environment variable with defaults, descriptions, and grouping (Database, Redis, Auth, LLM, etc.). Copy it to.envand edit in place.- Docker reminder: the only required change for containerized installs is to set at least one LLM API key (e.g., OpenAI, ERNIE, GLM). Update database/Redis URLs only if you are not using the bundled services.
Important Notes
- All sensitive values (API keys, passwords) should be kept secure
- Never commit
.envfiles to version control - For production deployments, use environment-specific configurations
- Refer to the example files for detailed explanations of each variable
Step 4: Build Latest Docker Images & Start the Stack
- Ensure
docker/.envcontains at least one LLM API key. - Build the backend and frontend images tagged as
:latestfrom the repo root:
docker build -t aishifu/ai-shifu-api:latest -f src/api/Dockerfile .
docker build -t aishifu/ai-shifu-cook-web:latest -f src/cook-web/Dockerfile .- Start the containers with the compose bundle that tracks the
:latesttags:
cd docker
docker compose -f docker-compose.latest.yml up -ddocker-compose.latest.yml always uses the most recent images (from Docker Hub or your own local builds). Use docker-compose.yml instead if you need pinned release tags for reproducible environments.
Step 5: Manual Installation (Development)
This section covers manual installation for development purposes or when you need more control over the setup.
Step 5.1: Set Up Database Services
Start MySQL and Redis services on your local machine or use Docker:
# Using Docker for databases only
docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=ai-shifu -e MYSQL_DATABASE=ai-shifu mysql:latest
docker run -d --name redis -p 6379:6379 redis:latestStep 5.2: Configure Environment for Local Development
Update your .env file for local development:
# Update database URLs for local services
SQLALCHEMY_DATABASE_URI="mysql://root:ai-shifu@localhost:3306/ai-shifu"
# Update API base URL
REACT_APP_BASEURL="http://localhost:5800"Step 5.3: Start Backend API
cd src/api
# Copy the environment configuration from docker directory
cp ../../docker/.env .env
# Install Python dependencies
pip install -r requirements.txt
# Initialize database
flask db upgrade
# Start the API server
gunicorn -w 4 -b 0.0.0.0:5800 'app:app' --timeout 300 --log-level debugStep 5.4: Start Cook Web Frontend & CMS
cd src/cook-web
# Copy the environment configuration from docker directory
cp ../../docker/.env .env
# Install Node.js dependencies
npm install # or use pnpm install
# Start development server
npm run devCook Web (which now serves both the learner experience and authoring console) will be available at http://localhost:3000.
Troubleshooting
Common Issues
-
Database Connection Failed
- Ensure MySQL is running and accessible
- Check database credentials in
.env - Run
flask db upgradeto initialize tables
-
Redis Connection Failed
- Ensure Redis is running and accessible
- Check Redis configuration in
.env
-
LLM API Errors
- Verify API keys are correct
- Check API base URLs
- Ensure the model name matches your provider
-
Frontend Build Failures
- Ensure Node.js version is 22.16.0
- Clear node_modules and reinstall:
rm -rf node_modules && npm install - Check for environment variable issues
Log Files
- API logs: Check gunicorn output or
/var/log/ai-shifu.log - Frontend logs: Check browser console or terminal output
Access the Application
Manual Installation
- User Interface:
http://localhost:3000(or configured PORT) - Script Editor:
http://localhost:3001 - API:
http://localhost:5800
Default Login
- Use any phone number for registration/login
- Default verification code:
1024