# Contributing Guide Language: [δΈ­ζ–‡](CONTRIBUTING.md) | [English](CONTRIBUTING.en.md) Thanks for your interest in contributing to DS2API! ## Development Setup ### Prerequisites - Go 1.26+ - Node.js `20.19+` or `22.12+` (for WebUI development) - npm (bundled with Node.js) ### Backend Development ```bash # 1. Clone git clone https://github.com/CJackHwang/ds2api.git cd ds2api # 2. Configure cp config.example.json config.json # Edit config.json with test accounts # 3. Run backend go run ./cmd/ds2api # Local access: http://127.0.0.1:5001 # Actual bind: 0.0.0.0:5001, so LAN access is available via your private IP ``` ### Frontend Development (WebUI) ```bash # 1. Navigate to WebUI directory cd webui # 2. Install dependencies npm install # 3. Start dev server (hot reload) npm run dev # Default: http://localhost:5173, auto-proxies API to backend ``` WebUI tech stack: - React + Vite - Tailwind CSS - Bilingual language packs: `webui/src/locales/zh.json` / `en.json` ### Docker Development ```bash docker-compose -f docker-compose.dev.yml up ``` ## Code Standards | Language | Standards | | --- | --- | | **Go** | Run `gofmt` and ensure `go test ./...` passes before committing | | **JavaScript/React** | Follow existing project style (functional components) | | **Commit messages** | Use semantic prefixes: `feat:`, `fix:`, `docs:`, `refactor:`, `style:`, `perf:`, `chore:` | ## Submitting a PR 1. Fork the repo 2. Create a branch (e.g. `feature/xxx` or `fix/xxx`) 3. Commit changes 4. Push your branch 5. Open a Pull Request > πŸ’‘ If you modify files under `webui/`, no manual build is needed β€” CI handles it automatically. > If you want to verify the generated `static/admin/` assets locally, you can still run `./scripts/build-webui.sh`. ## Build WebUI Manually build WebUI to `static/admin/`: ```bash ./scripts/build-webui.sh ``` ## Running Tests ```bash # Go + Node unit tests (recommended) ./tests/scripts/run-unit-all.sh # End-to-end live tests (real accounts) ./tests/scripts/run-live.sh ``` ## Project Structure ```text ds2api/ β”œβ”€β”€ app/ # Shared HTTP handler assembly (local + serverless) β”œβ”€β”€ cmd/ β”‚ β”œβ”€β”€ ds2api/ # Local/container entrypoint β”‚ └── ds2api-tests/ # End-to-end testsuite entrypoint β”œβ”€β”€ api/ β”‚ β”œβ”€β”€ index.go # Vercel Serverless Go entry β”‚ β”œβ”€β”€ chat-stream.js # Vercel Node.js stream relay β”‚ └── (rewrite targets in vercel.json) β”œβ”€β”€ internal/ β”‚ β”œβ”€β”€ account/ # Account pool and concurrency queue β”‚ β”œβ”€β”€ adapter/ β”‚ β”‚ β”œβ”€β”€ openai/ # OpenAI adapter β”‚ β”‚ β”œβ”€β”€ claude/ # Claude adapter β”‚ β”‚ └── gemini/ # Gemini adapter β”‚ β”œβ”€β”€ admin/ # Admin API handlers β”‚ β”œβ”€β”€ auth/ # Auth and JWT β”‚ β”œβ”€β”€ claudeconv/ # Claude message conversion β”‚ β”œβ”€β”€ compat/ # Go-version compatibility and regression helpers β”‚ β”œβ”€β”€ config/ # Config loading, validation, and hot-reload β”‚ β”œβ”€β”€ deepseek/ # DeepSeek client, PoW WASM β”‚ β”œβ”€β”€ js/ # Node runtime stream/compat logic β”‚ β”œβ”€β”€ devcapture/ # Dev packet capture β”‚ β”œβ”€β”€ format/ # Output formatting β”‚ β”œβ”€β”€ prompt/ # Prompt building β”‚ β”œβ”€β”€ server/ # HTTP routing (chi router) β”‚ β”œβ”€β”€ sse/ # SSE parsing utilities β”‚ β”œβ”€β”€ stream/ # Unified stream consumption engine β”‚ β”œβ”€β”€ testsuite/ # Testsuite framework and scenario orchestration β”‚ β”œβ”€β”€ translatorcliproxy/ # CLIProxy bridge and stream writer β”‚ β”œβ”€β”€ util/ # Common utilities β”‚ β”œβ”€β”€ version/ # Version parsing and comparison β”‚ └── webui/ # WebUI static hosting β”œβ”€β”€ webui/ # React WebUI source β”‚ └── src/ β”‚ β”œβ”€β”€ app/ # Routing, auth, config state β”‚ β”œβ”€β”€ features/ # Feature modules β”‚ β”œβ”€β”€ components/ # Shared components β”‚ └── locales/ # Language packs β”œβ”€β”€ scripts/ # Build and test scripts β”œβ”€β”€ tests/ β”‚ β”œβ”€β”€ compat/ # Compatibility fixtures and expected outputs β”‚ β”œβ”€β”€ node/ # Node-side unit tests β”‚ └── scripts/ # Test script entrypoints (unit/e2e) β”œβ”€β”€ plans/ # Plans, gates, and manual smoke-test records β”œβ”€β”€ static/admin/ # WebUI build output (not committed) β”œβ”€β”€ Dockerfile # Multi-stage build β”œβ”€β”€ docker-compose.yml # Production β”œβ”€β”€ docker-compose.dev.yml # Development └── vercel.json # Vercel config ``` ## Reporting Issues Please use [GitHub Issues](https://github.com/CJackHwang/ds2api/issues) and include: - Steps to reproduce - Relevant log output - Environment info (OS, Go version, deployment method)