How mfblog/webfrpc works
Project type and purpose
• This is a full-stack, single-binary application written in Go (Gin) with an embedded Vue3/TailwindCSS frontend.
• Purpose: Provide a friendly web interface to manage an FRP client (frpc) configuration (frpc.toml), automatically back up configs, restart the service, install/update the binary, and display logs/status.
File structure
Top-level files and scripts:
• main.go, go.mod/sum: Go backend entrypoint & dependencies
• build.sh, install.sh, install-service.sh, start.sh: build/deploy/install/start scripts
• DEPLOYMENT.md, LICENSE, README.md: documentation
• web/index.html: static Vue3 frontend
Key patterns & deployment artifacts:
• Embedded assets: web/ directory is embedded in the Go binary for single-file deployment.
• Service integration: systemd (install-service.sh) and journalctl for logs.
• Build variants: “embedded” vs. “normal” (with external web/ folder).
README for architectural insights
• Backend exposes REST API endpoints (/api/config, /api/status, etc.) for all UI actions.
• On startup, the backend performs system checks (directory, frpc binary, systemd service).
• On save operations, the backend: validates TOML, backs up config, writes frpc.toml, restarts frpc.service, and reports status/logs.
• Frontend is a SPA loaded from embedded assets, communicates via Axios to the Gin server.
Main components & interactions
a. Components
1. User’s browser UI (Vue3 + Tailwind)
2. Embedded web server (Go + Gin)
3. File system (config directory /usr/local/frp, TOML, backups, SSL certs)
4. FRP client process (frpc.service managed by systemd)
5. OS services: systemd & journalctl
6. Optional external network (the actual FRP server)
b. Relationships & data flows
• Browser ←→ HTTP(S) API calls → Go server
• Go server ↔ File system: read/write frpc.toml, backups, SSL files
• Go server ↔ systemd: systemctl status/restart frpc.service commands
• Go server ↔ journalctl: fetch logs for UI
• Go server ↔ External FRP server: optional connection test on save
c. Architectural patterns & design principles
• Single-page application fronted by REST API
• CLI orchestration via Go exec calls to systemd/journalctl
• Embedded static assets to simplify deployment (“build-embedded”)
• Transactional config updates: validate → backup → write → restart
d. Technologies & frameworks
• Backend: Go 1.x, Gin framework, go-toml
• Frontend: Vue3 (SPA), Tailwind CSS, Axios
• System integration: systemd (install-service.sh), bash scripts
• Build: go build with -ldflags embedding, build.sh