How xxnuo/mtranserver works
Project type and purpose
• This is a full-stack, offline‐first translation server written in Go, with a companion React/TypeScript Web UI.
• It exposes a CLI, a REST API (with both generic translate endpoints and plugin-compatible endpoints), and an optional Web UI. It downloads and manages local translation models, serves translation requests at ~50 ms, and requires no GPU.
File structure
• Top-level code:
• cmd/mtranserver/main.go: entrypoint for the CLI/HTTP server
• bin/: command-line helpers (hash/update generators)
• internal/: core Go packages
– config: app configuration and environment
– logger: logging initialization
– server: HTTP server setup and routing
– handlers: HTTP handler functions for /translate, /languages, plugin APIs, health/version
– middleware: auth, CORS, request logging
– manager: worker pool, model-loading daemon, client API
– downloader: fetching models from remote sources
– services: translation engine wrapper, language detection
– models: domain models (records, cached data)
– utils: common utilities (file, port, version)
• data/: sample data, JSON record store
• ui/: React/TypeScript Web UI (Vite)
• docs/: static documentation site
• Dockerfile, compose.yml, GitHub workflows: CI/CD and containerization
README for additional insights
• The server supports:
• Core translation API (/translate, /translate/batch)
• System health/version (/health, /version)
• Plugin compatibility endpoints (/imme, /kiss, /deepl, /google/*, /hcfy)
• Configurable via flags or env vars (model directory, UI toggle, offline mode, API token)
• Models are auto-downloaded on first use by internal/downloader and cached in MT_MODEL_DIR.
• UI is served (either statically or via embedded files) when “–ui” is enabled.