Getting Started with OpenEV Data API¶
This guide covers the API-specific setup. For general environment setup (cloning repositories and opening the workspace), see the Governance Getting Started Guide.
Prerequisites¶
Ensure you have completed the Governance Getting Started Guide and have:
- All repositories cloned in the
open-ev-data/directory - The multi-repository workspace open in VS Code or Cursor
- Rust toolchain installed (1.92.0+)
Verify Rust installation:
Build¶
From the open-ev-data-api directory:
For production builds:
Run tests to verify installation:
Run the ETL Pipeline¶
The ETL reads layered JSON from the Dataset repository and generates output artifacts.
cargo run -p ev-etl -- \
--input ../open-ev-data-dataset/src \
--output ./output \
--formats json,sqlite
Available formats: json, sqlite, postgresql, csv, xml
Generated files:
| File | Description |
|---|---|
output/vehicles.json | Canonical JSON with all vehicles |
output/vehicles.db | SQLite database |
output/statistics.json | Processing statistics |
Verify output:
cat output/vehicles.json | jq '.vehicle_count'
sqlite3 output/vehicles.db "SELECT COUNT(*) FROM vehicles;"
Run the API Server¶
Or with hot-reload:
The server starts at http://localhost:3000.
Test endpoints:
curl http://localhost:3000/api/v1/health
curl http://localhost:3000/api/v1/makes/list
curl http://localhost:3000/api/v1/vehicles/list
curl http://localhost:3000/api/v1/vehicles/code/tesla:model_3:2024:model_3
curl "http://localhost:3000/api/v1/vehicles/search?q=dolphin"
Swagger UI is available at: http://localhost:3000/docs
Development Workflow¶
- Edit vehicle JSON files in
open-ev-data-dataset/src - Run ETL to regenerate artifacts
- Restart the API server
- Test changes via API endpoints
For hot-reload during development:
Docker¶
Development Build¶
For local development (builds inside the container):
docker build -t ev-server -f docker/Dockerfile.dev .
docker run -p 3000:3000 -v $(pwd)/output/vehicles.db:/app/vehicles.db:ro ev-server
Or use Docker Compose:
Production Build¶
For CI/CD and production deployments (uses pre-compiled binaries):
cargo build --release
docker build -t ev-server -f docker/Dockerfile .
docker run -p 3000:3000 -v $(pwd)/output/vehicles.db:/app/vehicles.db:ro ev-server
The production Dockerfile expects binaries to be pre-built in target/release/, which significantly reduces build time and image size.
Command Reference¶
| Command | Description |
|---|---|
cargo build --all | Build all crates |
cargo test --all | Run all tests |
cargo fmt --all | Format code |
cargo clippy --all | Run linter |
cargo run -p ev-etl -- --help | ETL options |
cargo run -p ev-server -- --help | Server options |
Troubleshooting¶
| Issue | Solution |
|---|---|
cargo: command not found | Install Rust via rustup.rs |
| Database not found | Run ETL first to generate output/vehicles.db |
| Port already in use | Use PORT=8080 cargo run -p ev-server |