- Go to https://github.com/WuMingDao/zenith-image-generator
- Click Fork button in the top right corner
- Clone your forked repository:
git clone https://github.com/YOUR_USERNAME/zenith-image-generator.git
cd zenith-image-generatorpnpm installcp apps/web/.env.example apps/web/.envOption A: Full stack with Cloudflare Pages
⚠️ Help Wanted: This method has compatibility issues with wrangler 4.x. PRs welcome to fix this! See issue tracker.
Option B: Frontend + API separately (Recommended)
Runs frontend and API in separate terminals.
# Step 1: Set VITE_API_URL in apps/web/.env
# VITE_API_URL=http://localhost:8787
# Step 2: Start API (Terminal 1)
pnpm dev:api
# Step 3: Start Web (Terminal 2)
pnpm dev:webAccess via http://localhost:5173
Note: Set
VITE_API_URL=http://localhost:8787inapps/web/.env
Navigate to http://localhost:5173
The project uses Vitest for testing both API and frontend code.
# Run all tests in watch mode
pnpm test
# Run tests once (CI mode)
pnpm test:run
# Run tests with coverage report
pnpm test:coverageTest Structure:
apps/api/src/openai/__tests__/- OpenAI-format route tests (/v1/*)apps/api/src/providers/__tests__/- Provider unit tests (mocked fetch)apps/api/src/middleware/__tests__/- Middleware testsapps/api/src/utils/__tests__/- Utility function testsapps/web/src/lib/__tests__/- Frontend library tests
Writing Tests:
- All external API calls are mocked - no real API quota needed
- Use
vi.stubGlobal('fetch', vi.fn())to mock fetch - Frontend tests require
@vitest-environment jsdomdirective - Run tests before submitting PRs
If you want to access the dev server from other devices on your local network (e.g., testing on mobile):
Problem: By default, both frontend and API only listen on localhost, which is not accessible from other devices.
Solution:
- Update
.env- Point API URL to your machine's LAN IP:
# apps/web/.env
VITE_API_URL=http://192.168.1.9:8787 # Replace with your IP- Update
wrangler.toml- Make API listen on all interfaces:
# apps/api/wrangler.toml
[dev]
port = 8787
ip = "0.0.0.0"
[vars]
CORS_ORIGINS = "http://localhost:5173,http://192.168.1.9:5173" # Add your LAN IP- Start with host flag:
# Terminal 1: Start API
pnpm dev:api
# Terminal 2: Start Web with LAN access
pnpm dev:web -- --host=0.0.0.0- Access from other devices:
http://192.168.1.9:5173
Tip: Find your LAN IP with
ip addr(Linux) oripconfig(Windows)
Before submitting a PR, run these checks locally:
# 1. Lint and format check
pnpm check
# 2. Run tests
pnpm test:run
# 3. Build to verify no errors
pnpm buildCI Pipeline:
All PRs automatically run through GitHub Actions CI which includes:
- Lint & format check (
pnpm check) - Type check (
tsc --noEmit) - Build all packages
- Run all tests
PRs cannot be merged until CI passes. Running checks locally saves time and CI minutes.
PR Guidelines:
- Create feature branches from
dev - Follow commit message conventions (see below)
- Update documentation if adding new features
- Add tests for new functionality
This project follows Conventional Commits. Format:
<type>(<scope>): <description>
[optional body]
Types:
| Type | Description |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation only |
style |
Code style (formatting, no logic change) |
refactor |
Code refactoring |
test |
Adding or updating tests |
chore |
Build, CI, dependencies |
perf |
Performance improvement |
Scopes:
| Scope | Description |
|---|---|
api |
Backend API (apps/api) |
web |
Frontend (apps/web) |
shared |
Shared package (packages/shared) |
ci |
GitHub Actions workflows |
deps |
Dependencies |
Examples:
feat(api): add ModelScope provider support
fix(web): resolve image download on Safari
docs: update API reference with new endpoints
test(api): add provider unit tests
refactor(shared): extract validation utilities
chore(deps): upgrade vitest to v4.0PR Title: Use the same format as commit messages.