🎩 Magic - Next Generation Enterprise AI Application Innovation Engine
Magic is a powerful enterprise-grade AI application innovation engine designed to help developers quickly build and deploy AI applications. It provides a complete development framework, rich toolchain, and best practices, making AI application development simple and efficient.
✨ Features
- 🚀 High-Performance Architecture: Developed with PHP+Swow+hyperf, providing excellent performance and scalability
- 🧩 Modular Design: Flexible plugin system, supporting rapid extension and customization
- 🔌 Multi-Model Support: Seamless integration with mainstream AI models, including GPT, Claude, Gemini, etc.
- 🛠️ Development Toolchain: Complete development, testing, and deployment toolchain
- 🔒 Enterprise-Grade Security: Comprehensive security mechanisms, supporting organizational structure and permission management
🚀 Quick Start
I. System Requirements
- Supported Operating Systems: macOS, Linux, or Windows
- Docker and Docker Compose installed (refer to section 3.3 for Docker installation)
- Network connection (for pulling images and detecting public IP)
- Git installed (for cloning Magic code)
II. Installation Steps
2.1 Clone the Project
git clone git@github.com:dtyq/magic.git
cd magic
2.2. Configuration Files
Main Configuration Files
- .env: Main environment variables configuration file
- config/.env_super_magic: Super Magic service configuration file (if you choose to install)
- config/.env_magic_gateway: Magic Gateway configuration file (if you choose to install Super Magic)
- config/.env_sandbox_gateway: Sandbox Gateway configuration file (if you choose to install Super Magic)
- For macOS/Linux, missing files will be automatically copied during installation; Windows users need to manually copy and modify them
Manually Configure Files and Modify Required Values
### To use Magic, copy .env.example to .env
sudo cp .env.example .env
Magic Environment Variables Configuration Reference:
https://docs.letsmagic.cn/en/development/deploy/environment.html
### To use Super Magic services, copy the following files:
sudo cp config/.env_super_magic.example config/.env_super_magic
sudo cp config/.env_magic_gateway.example config/.env_magic_gateway
sudo cp config/.env_sandbox_gateway.example config/.env_sandbox_gateway
Super Magic Environment Variables Configuration Reference:
https://docs.letsmagic.cn/en/development/deploy/super-magic.html
Configure IP (Optional)
For remote server deployment, edit the .env file and replace localhost with your server IP in the following entries:
MAGIC_SOCKET_BASE_URL=ws://<server_IP>:9502
MAGIC_SERVICE_BASE_URL=http://<server_IP>:9501
If you choose to install Super Magic service, ensure the following configuration files exist:
- config/.env_super_magic
- config/.env_magic_gateway
- config/.env_sandbox_gateway
If config/.env_super_magic doesn't exist but config/.env_super_magic.example does, follow the prompts to copy and edit the file.
2.3. Starting Services on macOS/Linux
macOS/Linux
Run the installation script:
sudo ./bin/magic.sh start
Windows
Windows users can skip the magic.sh script and use docker compose commands directly: Alternatively, you can download the Git GUI tool for an installation experience similar to Mac/Linux.
# Create necessary network
docker network create magic-sandbox-network
# Start basic services
docker compose up
To start Super Magic related services:
docker compose --profile magic-gateway --profile sandbox-gateway up
2.4. Installation Process Guide
macOS/Linux
The script will guide you through the following steps:
Language Selection
- Choose 1 for English
- Choose 2 for Chinese
Deployment Method Selection
Choose 1 for local computer deployment (using default localhost configuration)
Choose 2 for remote server deployment (will detect public IP and ask if you want to use it)
Note: The script will check if magic-sandbox-network has been created locally. If not, it will automatically execute:
docker network create magic-sandbox-network
Super Magic Service Installation
- Choose 1 to install Super Magic service (requires pre-configuration of files in the config/ directory)
- Choose 2 to not install Super Magic service
2.5 First Run
After the first run, the system will create a bin/magic.lock file (macOS/Linux), and subsequent startups will skip the installation configuration process.
III. Usage
3.1 Common Commands
macOS/Linux
sudo ./bin/magic.sh [command]
Available commands:
- start: Start services in foreground
- daemon: Start services in background
- stop: Stop all services
- restart: Restart all services
- status: Display service status
- logs: Display service logs
- super-magic: Start only Super Magic service (foreground)
- super-magic-daemon: Start only Super Magic service (background)
- help: Display help information
Windows
Windows users use docker compose commands directly:
# Start services in foreground
docker compose up
# Start services in background
docker compose up -d
# Stop services
docker compose down
# Restart services
docker compose restart
# Check service status
docker compose ps
# View logs
docker compose logs -f
# Use Super Magic service (foreground)
docker compose --profile magic-gateway --profile sandbox-gateway up
# Use Super Magic service (background)
docker compose --profile magic-gateway --profile sandbox-gateway up -d
3.2 Examples
Start Services
macOS/Linux:
./bin/magic.sh start
Windows:
docker compose up
Start Services in Background
macOS/Linux:
./bin/magic.sh daemon
Windows:
docker compose up -d
Check Service Status
macOS/Linux:
./bin/magic.sh status
Windows:
docker compose ps
View Logs
macOS/Linux:
./bin/magic.sh logs
Windows:
docker compose logs -f
3.3 Installing Docker
macOS
Download and install Docker Desktop for Mac
Launch the Docker Desktop application
Linux
- Visit https://docs.docker.com/engine/install/
- Follow the installation instructions for your Linux distribution. Here's an example for Ubuntu:
sudo apt update
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Start Docker service after installation:
sudo systemctl start docker
Windows
Visit https://docs.docker.com/desktop/install/windows-install/
Download and install Docker Desktop for Windows
Launch the Docker Desktop application
Make sure WSL 2 backend is enabled in settings
IV. Troubleshooting
Common Issues
Docker Not Running
- Ensure Docker service is started
- macOS: Open Docker Desktop application
- Linux: Run
sudo systemctl start docker
- Windows: Open Docker Desktop application, check system tray icon
Port Conflicts
- Check if other services are using the ports configured
- Modify port configurations in the .env file
Missing Configuration Files
- Follow the prompts to copy example configuration files and make necessary edits
Network Issues
- Ensure access to Docker Hub to pull images
- Check if firewall settings are blocking Docker network access
Windows-Specific Issues
- Ensure WSL 2 support is enabled
- If permission issues occur, try running the command prompt as administrator
- Check if Windows Firewall is blocking Docker network traffic
Log Viewing
- For super-magic issues, check container logs starting with sandbox-agent
- For API issues, check magic-service container logs
- For frontend UI issues, check magic-web container logs
- For cross-origin and other network issues, check magic-caddy container logs
V. Uninstallation
To uninstall Magic system:
Stop and remove all containers
macOS/Linux:
bash./bin/magic.sh stop
Windows:
bashdocker compose down
Remove Docker network (if needed)
bashdocker network rm magic-sandbox-network
Delete persistent file directory ./volumes
📚 Documentation
For detailed documentation, please visit Magic Documentation Center.
🤝 Contribution
We welcome contributions in various forms, including but not limited to:
- Submitting issues and suggestions
- Improving documentation
- Submitting code fixes
- Contributing new features
📞 Contact Us
- Email: bd@dtyq.com
- Website: https://www.letsmagic.cn
🙏 Acknowledgements
Thanks to all developers who have contributed to Magic!