banshee-data/velocity.report
GitHub: banshee-data/velocity.report
隐私优先的社区交通监测系统,通过雷达和 LiDAR 采集车辆速度数据,帮助社区用数据推动街道安全改进。
Stars: 6 | Forks: 1
# velocity.report
-[-]`
- `action` 应为祈使动词(例如:`build`, `test`, `check`, `sync`)。
- `subsystem` 应命名功能面(例如:`go`, `web`, `config`)。
- `variant` 是可选的,用于缩小行为范围(例如:`strict`, `cov`, `linux`)。
对于配置一致性工作流,规范目标是动词优先的(`check-*`, `sync-*`)。保留旧别名以保持兼容性。
### 核心子系统目标
| 操作 | Go | Python | Web | 文档 | macOS |
| ------------------ | ------------------------------------------------------------- | ----------------- | -------------- | -------------- | ------------ |
| **install** | - | `install-python` | `install-web` | `install-docs` | - |
| **build** | `build-radar-*` | - | `build-web` | `build-docs` | `build-mac` |
| **dev** | `dev-go` | - | `dev-web` | `dev-docs` | `dev-mac` |
| **dev (variant)** | `dev-go-lidar`
`dev-go-lidar-both`
`dev-go-kill-server` | - | - | - | - | | **run** | - | - | - | - | `run-mac` | | **test** | `test-go` | `test-python` | `test-web` | - | `test-mac` | | **test (variant)** | `test-go-cov`
`test-go-coverage-summary` | `test-python-cov` | `test-web-cov` | - | - | | **format** | `format-go` | `format-python` | `format-web` | `format-docs` | `format-mac` | | **lint** | `lint-go` | `lint-python` | `lint-web` | - | - | | **clean** | - | `clean-python` | - | - | `clean-mac` | **跨领域格式化目标:** - `format-sql` - 格式化 SQL 文件(迁移和模式) ### 聚合目标 - `test` - 运行所有测试 (Go + Python + Web + macOS) - `format` - 格式化所有代码 (Go + Python + Web + macOS + SQL + Markdown) - `lint` - Lint 所有代码 (Go + Python + Web),如果需要格式化则失败 - `coverage` - 为所有组件生成覆盖率报告 ### 构建目标 (Go 交叉编译) - `build-radar-linux` - 为 Linux ARM64 构建 (无 pcap) - `build-radar-linux-pcap` - 为带 pcap 的 Linux ARM64 构建 - `build-radar-mac` - 为带 pcap 的 macOS ARM64 构建 - `build-radar-mac-intel` - 为带 pcap 的 macOS AMD64 构建 - `build-radar-local` - 为带 pcap 的本地开发构建 - `build-tools` - 构建 sweep 工具 - `build-deploy` - 构建 velocity-deploy 部署管理器 - `build-deploy-linux` - 为 Linux ARM64 构建 velocity-deploy - `build-web` - 构建 web 前端 - `build-docs` - 构建文档站点 ### 测试目标 - `test` - 运行所有测试 (Go + Python + Web +) - `test-go` - 运行 Go 单元测试 - `test-go-cov` - 运行带覆盖率的 Go 测试 - `test-go-coverage-summary` - 显示 cmd/ 和 internal/ 的覆盖率摘要 - `test-python` - 运行 Python PDF generator 测试 - `test-python-cov` - 运行带覆盖率的 Python 测试 - `test-web` - 运行 web 测试 - `test-web-cov` - 运行带覆盖率的 web 测试 - `test-mac` - 运行 macOS visualiser 测试 - `test-perf` - 运行性能回归测试 (NAME=kirk0) - `coverage` - 为所有组件生成覆盖率报告 ### macOS Visualiser 目标 - `build-mac` - 构建 macOS LiDAR visualiser (Xcode) - `clean-mac` - 清理 macOS visualiser 构建产物 - `run-mac` - 运行 macOS visualiser (需要 build-mac) - `dev-mac` - 终止、构建并运行 macOS visualiser - `test-mac` - 运行 macOS visualiser 测试 - `format-mac` - 格式化 macOS Swift 代码 ### Protobuf 代码生成 - `proto-gen` - 为所有语言生成 protobuf stubs - `proto-gen-go` - 生成 Go protobuf stubs - `proto-gen-swift` - 生成 Swift protobuf stubs (macOS visualiser) ### 部署目标(已弃用) - `setup-radar` - 在此主机上安装服务器 (需要 sudo,**已弃用**) - `deploy-install` - 使用 velocity-deploy 安装 (**已弃用**) - `deploy-upgrade` - 使用 velocity-deploy 升级 (**已弃用**) - `deploy-status` - 使用 velocity-deploy 检查服务状态 (**已弃用**) - `deploy-health` - 使用 velocity-deploy 运行健康检查 (**已弃用**) - `deploy-install-latex` - 在远程目标上安装 LaTeX (**已弃用**) - `deploy-update-deps` - 在远程目标上更新源码、LaTeX 和 Python 依赖 (**已弃用**) ### 格式化目标 - `format` - 格式化所有代码 (Go + Python + Web + macOS + SQL + Markdown) - `format-go` - 格式化 Go 代码 - `format-python` - 格式化 Python 代码 (black + ruff) - `format-web` - 格式化 web 代码 - `format-mac` - 格式化 macOS Swift 代码 - `format-docs` - 格式化 Markdown 文件 - `format-sql` - 格式化 SQL 文件 ### Lint 目标 - `lint` - Lint 所有代码 (Go + Python + Web),如果需要格式化则失败 - `lint-go` - 检查 Go 格式化 - `lint-python` - 检查 Python 格式化 - `lint-web` - 检查 web 格式化 ### 配置模式一致性目标 - `check-config-order` - 验证配置和文档表面的规范调优键顺序 - `sync-config-order` - 将配置/文档目标重写为规范调优键顺序 - `check-config-maths` - 根据 docs JSON, `tuning*.json` 和 Go schema 源验证 `README.maths` 键 - `check-config-maths-strict` - 严格奇偶校验模式;还需要完整的 webserver POST schema 奇偶校验 当前状态:在 CI 中是可选的,直到 webserver schema 奇偶校验积压完成。 - 兼容性别名:`config-order-check`, `config-order-sync`, `readme-maths-check`, `readme-maths-check-strict` ### 数据库迁移目标 - `migrate-up` - 应用所有待处理的迁移 - `migrate-down` - 回滚一个迁移 - `migrate-status` - 显示当前迁移状态 - `migrate-detect` - 检测 schema 版本(用于旧数据库) - `migrate-version` - 迁移到特定版本 (VERSION=N) - `migrate-force` - 强制版本(恢复用,VERSION=N) - `migrate-baseline` - 设置基线版本 (VERSION=N) - `schema-sync` - 从最新迁移重新生成 schema.sql ### PDF Generator 目标 - `pdf-report` - 从配置文件生成 PDF - `pdf-config` - 创建示例配置 - `pdf-demo` - 运行配置演示 - `pdf-test` - 运行 PDF 测试(test-python 的别名) - `pdf` - pdf-report 的便捷别名 ### 实用目标 - `set-version` - 跨代码库更新版本 (VER=0.4.0 TARGETS='--all') - `log-go-tail` - 查看最近的 Go server 日志尾部 - `log-go-cat` - 打印最近的 Go server 日志 - `log-go-tail-all` - 查看最近的 Go server 日志加调试日志尾部 - `git-fs` - 显示与 main 不同的 git 文件 ### 数据可视化目标 - `plot-noise-sweep` - 生成噪声扫描线图 (FILE=data.csv) - `plot-multisweep` - 生成多参数网格 (FILE=data.csv) - `plot-noise-buckets` - 生成每噪声柱状图 (FILE=data.csv) - `stats-live` - 捕获实时 LiDAR 快照 (INTERVAL=10 DURATION=60) - `stats-pcap` - 捕获 PCAP 回放快照 (PCAP=file.pcap INTERVAL=5) ### API 快捷目标 **Grid endpoints:** - `api-grid-status` - 获取 grid 状态 - `api-grid-reset` - 重置背景 grid - `api-grid-heatmap` - 获取 grid 热力图 **Snapshot endpoints:** - `api-snapshot` - 获取当前快照 - `api-snapshots` - 列出所有快照 **Acceptance endpoints:** - `api-acceptance` - 获取验收指标 - `api-acceptance-reset` - 重置验收计数器 **Parameter endpoints:** - `api-params` - 获取算法参数 - `api-params-set` - 设置参数 (PARAMS='{}') **Persistence and export endpoints:** - `api-persist` - 触发快照持久化 - `api-export-snapshot` - 导出特定快照 - `api-export-next-frame` - 导出下一 LiDAR 帧 **Status & data source endpoints:** - `api-status` - 获取服务器状态 - `api-start-pcap` - 开始 PCAP 回放 (PCAP=file.pcap) - `api-stop-pcap` - 停止 PCAP 回放 - `api-switch-data-source` - 切换 live/pcap (SOURCE=live|pcap) 运行 `make help` 或 `make` 查看所有可用目标及其描述。 ## 贡献 我们欢迎贡献!请参阅 **[CONTRIBUTING.md](CONTRIBUTING.md)** 了解: - 开发工作流 (Go + Python + Web) - 测试要求 - 代码风格指南 - Pull request 流程 ## 许可证 Apache License 2.0 - 详见 [LICENSE](LICENSE)。 ## 社区 [](https://discord.gg/XXh6jXVFkt) 加入我们的 Discord 社区,讨论项目、获取帮助,并为让街道更安全做出贡献。
[](https://github.com/banshee-data/velocity.report/actions/workflows/go-ci.yml)
[](https://github.com/banshee-data/velocity.report/actions/workflows/web-ci.yml)
[](https://github.com/banshee-data/velocity.report/actions/workflows/python-ci.yml)
[](https://github.com/banshee-data/velocity.report/actions/workflows/mac-ci.yml)
覆盖率: [](https://codecov.io/gh/banshee-data/velocity.report?flag=go)
[](https://codecov.io/gh/banshee-data/velocity.report?flag=web)
[](https://codecov.io/gh/banshee-data/velocity.report?flag=python)
[](https://codecov.io/gh/banshee-data/velocity.report?flag=mac)
[](https://discord.gg/XXh6jXVFkt)
一款专注于隐私保护的交通流量记录工具,专为社区变革者打造。
测量车辆速度,让街道更安全。
```
░░░░
▒▓███▓▓▓▓▒
▒▓▒▒
░▓▓▓▓▓▓▓▓▓▓▓▓░ ░▓▒▒
▒▓▓▓▓▓██████▓▓░ ▒▓██▓▒
▒▒▓▒▓▓░ ▒▓▒░
░▓▓░ ▓▒▒
░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████▓░
▓▓█▓▒▒▒▒▒▒░░░░ ░▓▓▒
░▓▓▒▓▓░ ░▒▓▓▓▓░
░░▒▒▒▒░ ░▓▒░ ▒▓▒ ▒▓▓▒ ▓▓▒ ░▒▒▓▓▒▒░
▒▓▓▓██▓▓▓██▓▓▓▓▓▒ ░▓▓░ ▒▓▓▒ ▒██▓▓█▓▓▓▓▓▓▒▓▓▒░
░▓▓▓▓▓▒░ ░ ▒▒██▓▒▒ ▒▓▒░ ░▓▓▒ ▓▓█▓█▓ ░░ ▒▒▓▒▓▒
▒▓▓▓▓░ ░░ ░▓▓░▒▓▓▒ ▒▓▒ ▓▓▓ ░▓▓▓░░▓▓░ ░░ ▒█▓▒▒
░▒█▒▓░▒ ░░ ░▓▒░ ░▓▓▒░ ░▓▓ ░████▓ ▒█▓░ ▒▓█▒ ░▓▓░ ░░ ▒░░▒█▓▒
▒▓▒▓ ▒░ ░░ ▒▓▓ ░▓▓▓░ ░▓▒ ░▓▒ ░▓▓▒ ▒▓█▒░▒ ▒█▒ ░ ▒░ ░▒▓▓▒
░▓█▓ ░▒░ ░░▒▓▒ ░▓▓▒░▒▓████▒ ▒▓▓░ ▒▓▓▒ ▒▒ ▓▓▒ ░ ░▒ ░▓▓▒░
▒▓▓▒ ░▒▒▓█▓▓▓███▓▓▓▓████▓█▓▓▒▒▓▓▓▒ ▒█▓░ ░▓▓▓▒▒▒▒ ▒▓▒▒
▒▓▓▒░░▒▒▒▓▒▒▓▓██▓▒▒░▒░░░ ▒▓▒▒▓▓▓▓▓█▓▓▓░ ▒█▓░ ░░░▒█▓▓▒▒▒░░░░░░░▒█▓░
▒▓▓▒ ░▒▒▓▒░ ▓▓▓░▒▓▓▓▓▓▒▒▓░ ▒▓▓▒▒░░░░░ ░▒▓░▒░ ▓▓▓░
░▓█▓░ ░▒░ ░▒ ▒░ ▒▓▓▒ ▒███▓▓▓░ ░▓▓▒ ░░ ░ ░▒░ ░▓▓▓░
▒▓▓▓░ ▒░ ▒ ▒░ ░▓▓▓░ ▒▓ ▓▓▓░ ▒ ░░ ░▒░ ░▓█▓░
▒▓▓▓▒░ ░▒ ░▒ ▒▓▓▒ ░▓▒ ░▒▓▓░ ░░ ░░ ▒▒▓▓▓░
▒▓▓▓▒░ ▒ ░▓▓▓▒ ▓█▓▓█░ ▒▓▓▓▒░ ▒░ ░▓█▓▓░
░▒▓██▓▒▒ ▒ ░▒▓▓█▓▒░ ░▓▓█▓▓░ ░░ ░▒▓█▓▓▓░
░░░▒▒▓▓████▓██▓▓░ ░░ ▒▓▓▓▓██▓▓▓████▓▒░
░░░░░░░░░░░░▒▒░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░ ░░░▒▒▒▒▓▒▒░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░ ░░░░ ░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░
░░░ ░░░░░░ ░░░░ ░░░░░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░░░░░░░ ░░░░
░░░ ░░░░ ░░░░ ░░░░ ░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░
```
## 概述
**velocity.report** 是一个用于社区交通监控的完整公民雷达系统。该系统由四个主要组件构成:
- **Go Server** - 高性能数据收集和 API 服务器
- **Python PDF Generator** - 基于 LaTeX 的专业 PDF 报告生成器
- **Web Frontend** - 实时数据可视化 (Svelte)
- **macOS Visualiser** - 用于 LiDAR 追踪的原生 3D 可视化工具 (M1+ Macs)
该系统从雷达/LIDAR 传感器收集车辆速度数据,将其存储在 SQLite 中,并提供多种方式来可视化和报告这些数据——同时始终保持完全的隐私(无车牌识别,无视频录制)。
## 隐私与伦理
本项目以隐私为核心设计原则:
- ✅ 无车牌识别
- ✅ 无视频录制
- ✅ 无个人身份信息
目标是在不损害个人隐私的前提下,赋能社区就街道安全做出数据驱动的决策。
## 快速开始
### Go Server 开发
```
git clone git@github.com:banshee-data/velocity.report.git
cd velocity.report
make build-radar-local
./velocity-report-local --disable-radar
```
如果存在现有的 SQLite 数据库,请将其放置在 `./sensor_data.db`(开发的默认位置)。对于生产部署,请使用 `--db-path` 标志指定不同的位置(参见部署部分)。
### PDF 报告生成
详见 **[tools/pdf-generator/README.md](tools/pdf-generator/README.md)**。
快速版本:
```
cd tools/pdf-generator
make install-python # One-time setup
make pdf-config # Create config template
make pdf-report CONFIG=config.json
```
### Web Frontend 开发
详见 **[web/README.md](web/README.md)**。
### macOS Visualiser (LiDAR 3D Tracking)
macOS 可视化工具提供 LiDAR 点云、物体追踪和调试覆盖层的实时 3D 可视化。**需要 macOS 14+ 和 Apple Silicon (M1/M2/M3) 或支持 Metal 的 Intel Mac。**
详见 **[tools/visualiser-macos/README.md](tools/visualiser-macos/README.md)**。
快速版本:
```
# 构建 visualiser
make build-mac
# 启动 synthetic data server 进行测试
go run ./cmd/tools/visualiser-server -rate 10 -points 5000
# 启动 visualiser
open tools/visualiser-macos/build/Build/Products/Release/VelocityVisualiser.app
# 或回放录制的数据
go run ./cmd/tools/visualiser-server -mode replay -log /path/to/recording.vrlog
```
**M1 功能 (里程碑 1):**
- ✅ 具有确定性回放的录制器/回放器
- ✅ 通过 gRPC 进行暂停/播放/跳转/倍速控制
- ✅ 逐帧导航
- ✅ 时间轴拖动
- ✅ 3D 相机控制(轨道、平移、缩放)
- ✅ 鼠标/触控板手势支持
## 项目结构
```
velocity.report/
├── cmd/ # Go CLI applications
│ ├── radar/ # Radar/LiDAR sensor integration
│ ├── deploy/ # Deployment management tool
│ ├── sweep/ # Parameter sweep utilities
│ ├── tools/ # Go utility tools
│ │ ├── visualiser-server/ # Synthetic data generator and replay server
│ │ ├── gen-vrlog/ # Generate sample .vrlog recordings
│ │ ├── pcap-analyse/ # PCAP packet analysis
│ │ └── ... # Other utilities
│ └── transit-backfill/ # Transit data backfill tool
├── internal/ # Go server internals (private packages)
│ ├── api/ # HTTP API endpoints
│ ├── db/ # SQLite database layer + migrations
│ ├── radar/ # Radar sensor logic
│ ├── lidar/ # LiDAR sensor logic + tracking
│ │ └── visualiser/ # gRPC streaming for 3D visualisation
│ │ └── recorder/ # Record/replay .vrlog files
│ ├── monitoring/ # System monitoring
│ ├── security/ # Path validation and security
│ ├── serialmux/ # Serial port multiplexing
│ ├── units/ # Unit conversion utilities
│ └── version/ # Version information
├── web/ # Svelte web frontend
│ ├── src/ # Frontend source code
│ └── static/ # Static assets
├── tools/ # Python tooling and native apps
│ ├── pdf-generator/ # PDF report generation (Python)
│ │ ├── pdf_generator/ # Python package
│ │ │ ├── cli/ # CLI tools
│ │ │ ├── core/ # Core modules
│ │ │ └── tests/ # Test suite
│ │ └── output/ # Generated PDFs
│ └── visualiser-macos/ # macOS LiDAR visualiser (Swift/Metal)
│ ├── VelocityVisualiser/ # SwiftUI app
│ │ ├── App/ # Application entry
│ │ ├── gRPC/ # gRPC client
│ │ ├── Rendering/ # Metal renderer
│ │ └── UI/ # SwiftUI views
│ └── VelocityVisualiserTests/ # XCTest suite
├── data/ # Sample data and alignment utilities
├── docs/ # Internal project documentation
├── public_html/ # Public documentation site (Eleventy)
├── scripts/ # Development shell scripts
└── static/ # Static server assets
```
## 架构
### 数据流
```
┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ Sensors │────►│ Go Server │◄───►│ SQLite Database │
│ (Radar / LIDAR) │ │ (API/Processing) │ │ (Time-series) │
└───────────────────┘ └───────────────────┘ └───────────────────┘
│
│
┌─────────────────┴──────────────────┐
│ │
▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ Web Frontend │ │ Python PDF Generator │
│ (Real-time via Svelte) │ │ (Offline Reports via LaTeX) │
└─────────────────────────────┘ └─────────────────────────────┘
```
### 组件
**1. Go Server** (`/cmd/`, `/internal/`)
- 从雷达/LIDAR 传感器收集数据
- 在 SQLite 中存储时间序列数据
- 提供 HTTP API 用于数据访问
- 处理后台处理任务
- 在 Raspberry Pi 上作为 systemd 服务运行
**2. Python PDF Generator** (`/tools/pdf-generator/`)
- 使用 LaTeX 生成专业的 PDF 报告
- 使用 matplotlib 创建图表和可视化
- 处理统计摘要
- 可通过 JSON 高度配置
- 完善的测试套件
**3. Web Frontend** (`/web/`)
- 实时数据可视化
- 交互式图表和图形
- 使用 Svelte 和 TypeScript 构建
- 响应式设计
详细的架构文档请参阅 **[ARCHITECTURE.md](ARCHITECTURE.md)**。
## 开发
### 前置条件
**Go 开发:**
- Go 1.25+ ([安装指南](https://go.dev/doc/install))
- SQLite3
**Python PDF 生成:**
- Python 3.11+
- LaTeX 发行版
- 参见 [tools/pdf-generator/README.md](tools/pdf-generator/README.md)
**Web Frontend:**
- Node.js 18+
- pnpm
- 参见 [web/README.md](web/README.md)
### Go Server 开发
构建开发服务器:
```
make build-radar-local
./velocity-report-local --disable-radar
```
运行测试:
```
make test
```
为生产环境构建:
```
make build-radar-linux
# 或手动操作:
GOOS=linux GOARCH=arm64 go build -o velocity-report-linux-arm64 ./cmd/radar
```
### Python PDF Generator 开发
本仓库为所有 Python 工具(PDF 生成器、数据可视化、分析脚本)使用**单一共享 Python 虚拟环境**。
**设置:**
```
make install-python # Creates .venv and installs all dependencies
```
**手动激活(可选):**
```
source .venv/bin/activate
```
**已安装内容:**
- PDF 生成:PyLaTeX
- 数据分析:pandas, numpy
- 可视化:matplotlib, seaborn
- 测试:pytest, pytest-cov
- 格式化:black, ruff
**运行 PDF Generator:**
```
make pdf-test # Run test suite
make pdf-demo # Run interactive demo
make pdf-config # Create config template
make pdf-report CONFIG=config.json # Generate PDF report
```
### 代码格式化
**选项 1:按需格式化(推荐新贡献者使用)**
```
make format # Format all code before commit
make lint # Verify formatting (what CI checks)
```
**选项 2:编辑器集成**
- VS Code:安装 Prettier, ESLint, Go 扩展
- 保存时自动格式化可处理大多数情况
**选项 3:Pre-commit hooks(推荐常规贡献者使用)**
```
pip install pre-commit
pre-commit install
```
Hooks 会在每次提交时自动格式化代码——无需手动执行 `make format`。
**提交时运行的内容(如果启用了 hooks):**
- 文件清理(尾随空格、大文件等)
- Go 格式化
- Python 格式化 (ruff + black) 用于 PDF generator 代码
- Web 格式化
**注意:** CI lint 作业仅供参考(非阻塞),因此即使格式不完美,PR 也可以合并。每周的自动化工作流会清理任何遗漏的格式问题。详见 [`.github/workflows/lint-autofix.yml`](.github/workflows/lint-autofix.yml)。
### Web Frontend 开发
```
cd web
pnpm install
pnpm dev
```
详见 **[web/README.md](web/README.md)**。
## 部署
### Go Server (Raspberry Pi)
Go server 在 Raspberry Pi 上作为 systemd 服务运行。使用新的 `velocity-deploy` 工具进行全面的部署管理。
**快速开始 - 部署到 Raspberry Pi:**
```
# 构建二进制文件和部署工具
make build-radar-linux
make build-deploy
# 部署到远程 Pi
./velocity-deploy install \
--target pi@192.168.1.100 \
--ssh-key ~/.ssh/id_rsa \
--binary ./velocity-report-linux-arm64
```
**或使用 Make 快捷方式进行本地部署:**
```
make build-radar-linux
make deploy-install
```
部署将:
- 将二进制文件安装到 `/usr/local/bin/velocity-report`
- 创建专用服务用户和工作目录
- 安装并启用 systemd 服务
- 可选择迁移现有数据库
**升级到新版本:**
```
make build-radar-linux
./velocity-deploy upgrade --target pi@192.168.1.100 --binary ./velocity-report-linux-arm64
```
**监控服务健康状态:**
```
# 全面健康检查
./velocity-deploy health --target pi@192.168.1.100
# 检查状态
./velocity-deploy status --target pi@192.168.1.100
# 查看日志
sudo journalctl -u velocity-report.service -f
```
**另见:**
- **[public_html/src/guides/setup.md](public_html/src/guides/setup.md)** - 完整的设置和部署指南
- **[cmd/deploy/README.md](cmd/deploy/README.md)** - velocity-deploy CLI 参考
**传统部署:**
旧的 `scripts/setup-radar-host.sh` 脚本仍然可用,但建议所有部署使用新的 `velocity-deploy` 工具。
### Python PDF Generator
PDF generator 通过 PYTHONPATH 作为 Python 包部署:
```
cd tools/pdf-generator
make install-python
# PDF generator 现已就绪,位于 tools/pdf-generator/pdf_generator/
```
无需安装 - 使用 [tools/pdf-generator/README.md](tools/pdf-generator/README.md) 中记录的 PYTHONPATH 方法。
## 文档
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - 系统架构和组件关系
- **[DESIGN.md](docs/ui/DESIGN.md)** - 前端和可视化设计语言(调色板、图表规则、CSS 标准)
- **[docs/COVERAGE.md](docs/COVERAGE.md)** - 代码覆盖率设置和使用指南
- **[internal/db/migrations/README.md](internal/db/migrations/README.md)** - 数据库迁移指南和参考
- **[CHANGELOG.md](CHANGELOG.md)** - 版本历史和发布说明
- **[web/README.md](web/README.md)** - Web 前端文档
- **[tools/pdf-generator/README.md](tools/pdf-generator/README.md)** - PDF generator 文档
- **[docs/README.md](docs/README.md)** - 内部项目文档
- **[public_html/README.md](public_html/README.md)** - 公共文档站点
## 测试
### Go 测试
```
make test
```
**性能回归测试:**
```
make test-perf NAME=kirk0 # Run performance test against baseline
```
这将当前性能与保存的基线进行比较。如果不存在基线,则会创建一个。
### Python 测试
```
cd tools/pdf-generator
make pdf-test
# 或启用 coverage:
make test-python-cov
```
## Make 目标
项目为所有 make 目标使用一致的命名方案:``dev-go-lidar-both`
`dev-go-kill-server` | - | - | - | - | | **run** | - | - | - | - | `run-mac` | | **test** | `test-go` | `test-python` | `test-web` | - | `test-mac` | | **test (variant)** | `test-go-cov`
`test-go-coverage-summary` | `test-python-cov` | `test-web-cov` | - | - | | **format** | `format-go` | `format-python` | `format-web` | `format-docs` | `format-mac` | | **lint** | `lint-go` | `lint-python` | `lint-web` | - | - | | **clean** | - | `clean-python` | - | - | `clean-mac` | **跨领域格式化目标:** - `format-sql` - 格式化 SQL 文件(迁移和模式) ### 聚合目标 - `test` - 运行所有测试 (Go + Python + Web + macOS) - `format` - 格式化所有代码 (Go + Python + Web + macOS + SQL + Markdown) - `lint` - Lint 所有代码 (Go + Python + Web),如果需要格式化则失败 - `coverage` - 为所有组件生成覆盖率报告 ### 构建目标 (Go 交叉编译) - `build-radar-linux` - 为 Linux ARM64 构建 (无 pcap) - `build-radar-linux-pcap` - 为带 pcap 的 Linux ARM64 构建 - `build-radar-mac` - 为带 pcap 的 macOS ARM64 构建 - `build-radar-mac-intel` - 为带 pcap 的 macOS AMD64 构建 - `build-radar-local` - 为带 pcap 的本地开发构建 - `build-tools` - 构建 sweep 工具 - `build-deploy` - 构建 velocity-deploy 部署管理器 - `build-deploy-linux` - 为 Linux ARM64 构建 velocity-deploy - `build-web` - 构建 web 前端 - `build-docs` - 构建文档站点 ### 测试目标 - `test` - 运行所有测试 (Go + Python + Web +) - `test-go` - 运行 Go 单元测试 - `test-go-cov` - 运行带覆盖率的 Go 测试 - `test-go-coverage-summary` - 显示 cmd/ 和 internal/ 的覆盖率摘要 - `test-python` - 运行 Python PDF generator 测试 - `test-python-cov` - 运行带覆盖率的 Python 测试 - `test-web` - 运行 web 测试 - `test-web-cov` - 运行带覆盖率的 web 测试 - `test-mac` - 运行 macOS visualiser 测试 - `test-perf` - 运行性能回归测试 (NAME=kirk0) - `coverage` - 为所有组件生成覆盖率报告 ### macOS Visualiser 目标 - `build-mac` - 构建 macOS LiDAR visualiser (Xcode) - `clean-mac` - 清理 macOS visualiser 构建产物 - `run-mac` - 运行 macOS visualiser (需要 build-mac) - `dev-mac` - 终止、构建并运行 macOS visualiser - `test-mac` - 运行 macOS visualiser 测试 - `format-mac` - 格式化 macOS Swift 代码 ### Protobuf 代码生成 - `proto-gen` - 为所有语言生成 protobuf stubs - `proto-gen-go` - 生成 Go protobuf stubs - `proto-gen-swift` - 生成 Swift protobuf stubs (macOS visualiser) ### 部署目标(已弃用) - `setup-radar` - 在此主机上安装服务器 (需要 sudo,**已弃用**) - `deploy-install` - 使用 velocity-deploy 安装 (**已弃用**) - `deploy-upgrade` - 使用 velocity-deploy 升级 (**已弃用**) - `deploy-status` - 使用 velocity-deploy 检查服务状态 (**已弃用**) - `deploy-health` - 使用 velocity-deploy 运行健康检查 (**已弃用**) - `deploy-install-latex` - 在远程目标上安装 LaTeX (**已弃用**) - `deploy-update-deps` - 在远程目标上更新源码、LaTeX 和 Python 依赖 (**已弃用**) ### 格式化目标 - `format` - 格式化所有代码 (Go + Python + Web + macOS + SQL + Markdown) - `format-go` - 格式化 Go 代码 - `format-python` - 格式化 Python 代码 (black + ruff) - `format-web` - 格式化 web 代码 - `format-mac` - 格式化 macOS Swift 代码 - `format-docs` - 格式化 Markdown 文件 - `format-sql` - 格式化 SQL 文件 ### Lint 目标 - `lint` - Lint 所有代码 (Go + Python + Web),如果需要格式化则失败 - `lint-go` - 检查 Go 格式化 - `lint-python` - 检查 Python 格式化 - `lint-web` - 检查 web 格式化 ### 配置模式一致性目标 - `check-config-order` - 验证配置和文档表面的规范调优键顺序 - `sync-config-order` - 将配置/文档目标重写为规范调优键顺序 - `check-config-maths` - 根据 docs JSON, `tuning*.json` 和 Go schema 源验证 `README.maths` 键 - `check-config-maths-strict` - 严格奇偶校验模式;还需要完整的 webserver POST schema 奇偶校验 当前状态:在 CI 中是可选的,直到 webserver schema 奇偶校验积压完成。 - 兼容性别名:`config-order-check`, `config-order-sync`, `readme-maths-check`, `readme-maths-check-strict` ### 数据库迁移目标 - `migrate-up` - 应用所有待处理的迁移 - `migrate-down` - 回滚一个迁移 - `migrate-status` - 显示当前迁移状态 - `migrate-detect` - 检测 schema 版本(用于旧数据库) - `migrate-version` - 迁移到特定版本 (VERSION=N) - `migrate-force` - 强制版本(恢复用,VERSION=N) - `migrate-baseline` - 设置基线版本 (VERSION=N) - `schema-sync` - 从最新迁移重新生成 schema.sql ### PDF Generator 目标 - `pdf-report` - 从配置文件生成 PDF - `pdf-config` - 创建示例配置 - `pdf-demo` - 运行配置演示 - `pdf-test` - 运行 PDF 测试(test-python 的别名) - `pdf` - pdf-report 的便捷别名 ### 实用目标 - `set-version` - 跨代码库更新版本 (VER=0.4.0 TARGETS='--all') - `log-go-tail` - 查看最近的 Go server 日志尾部 - `log-go-cat` - 打印最近的 Go server 日志 - `log-go-tail-all` - 查看最近的 Go server 日志加调试日志尾部 - `git-fs` - 显示与 main 不同的 git 文件 ### 数据可视化目标 - `plot-noise-sweep` - 生成噪声扫描线图 (FILE=data.csv) - `plot-multisweep` - 生成多参数网格 (FILE=data.csv) - `plot-noise-buckets` - 生成每噪声柱状图 (FILE=data.csv) - `stats-live` - 捕获实时 LiDAR 快照 (INTERVAL=10 DURATION=60) - `stats-pcap` - 捕获 PCAP 回放快照 (PCAP=file.pcap INTERVAL=5) ### API 快捷目标 **Grid endpoints:** - `api-grid-status` - 获取 grid 状态 - `api-grid-reset` - 重置背景 grid - `api-grid-heatmap` - 获取 grid 热力图 **Snapshot endpoints:** - `api-snapshot` - 获取当前快照 - `api-snapshots` - 列出所有快照 **Acceptance endpoints:** - `api-acceptance` - 获取验收指标 - `api-acceptance-reset` - 重置验收计数器 **Parameter endpoints:** - `api-params` - 获取算法参数 - `api-params-set` - 设置参数 (PARAMS='{}') **Persistence and export endpoints:** - `api-persist` - 触发快照持久化 - `api-export-snapshot` - 导出特定快照 - `api-export-next-frame` - 导出下一 LiDAR 帧 **Status & data source endpoints:** - `api-status` - 获取服务器状态 - `api-start-pcap` - 开始 PCAP 回放 (PCAP=file.pcap) - `api-stop-pcap` - 停止 PCAP 回放 - `api-switch-data-source` - 切换 live/pcap (SOURCE=live|pcap) 运行 `make help` 或 `make` 查看所有可用目标及其描述。 ## 贡献 我们欢迎贡献!请参阅 **[CONTRIBUTING.md](CONTRIBUTING.md)** 了解: - 开发工作流 (Go + Python + Web) - 测试要求 - 代码风格指南 - Pull request 流程 ## 许可证 Apache License 2.0 - 详见 [LICENSE](LICENSE)。 ## 社区 [](https://discord.gg/XXh6jXVFkt) 加入我们的 Discord 社区,讨论项目、获取帮助,并为让街道更安全做出贡献。
标签:EVTX分析, Go, neighborhoods, Python, Python工具, Ruby工具, SBOM分析, Svelte, 交通治理, 交通监控, 代码示例, 传感器, 公民科学, 开源硬件, 慢行街道, 数据分析, 无后门, 日志审计, 智慧城市, 测速雷达, 物联网, 社区监测, 网络安全, 车辆测速, 逆向工具, 道路安全, 隐私保护, 非身份识别