| Crates.io | data-modelling-api |
| lib.rs | data-modelling-api |
| version | 1.1.2 |
| created_at | 2026-01-01 18:58:31.77869+00 |
| updated_at | 2026-01-02 14:32:32.60065+00 |
| description | Data Modelling API for open data modelling based around ODCS formats |
| homepage | |
| repository | https://github.com/pixie79/data-modelling-api |
| max_upload_size | |
| id | 2017173 |
| size | 1,779,090 |
A REST API for data modeling, schema management, and collaboration built with Rust and Axum.
git clone https://github.com/pixie79/data-modelling-api.git
cd data-modelling-api
export WORKSPACE_DATA=/tmp/workspace_data
export JWT_SECRET=your-secret-key-change-in-production
export GITHUB_CLIENT_ID=your-github-client-id
export GITHUB_CLIENT_SECRET=your-github-client-secret
export FRONTEND_URL=http://localhost:8080
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/data_modelling
sqlx migrate run
# Use SQLX_OFFLINE=true to avoid database connection during compilation
# (matches CI/CD behavior - uses pre-generated query metadata)
SQLX_OFFLINE=true cargo run --bin api
Note: If you don't set SQLX_OFFLINE=true, SQLx will try to verify queries against your database at compile time. Ensure your database schema matches the migrations, or use offline mode (recommended).
The API will be available at http://localhost:8081
docker-compose up -d
http://localhost:8081The OpenAPI specification is available at:
http://localhost:8081/api/v1/openapi.jsonThe API provides health check endpoints to monitor service availability:
GET /health: Basic health check endpointGET /api/v1/health: API versioned health check endpointBoth endpoints return 200 OK if the service is running. These endpoints are useful for:
Example:
curl http://localhost:8081/health
curl http://localhost:8081/api/v1/health
curl "http://localhost:8081/api/v1/auth/github/login?redirect_uri=http://localhost:8080/callback"
curl -H "Authorization: Bearer <token>" http://localhost:8081/api/v1/workspace/info
WORKSPACE_DATA: Path to workspace data directoryJWT_SECRET: Secret key for JWT signingGITHUB_CLIENT_ID: GitHub OAuth client IDGITHUB_CLIENT_SECRET: GitHub OAuth client secretDATABASE_URL: PostgreSQL connection string (default: file-based storage)FRONTEND_URL: Frontend URL for OAuth redirects (default: http://localhost:8080)REDIRECT_URI_WHITELIST: Comma-separated allowed redirect URIsENFORCE_HTTPS_REDIRECT: Enforce HTTPS for redirects (true/false)OTEL_SERVICE_NAME: OpenTelemetry service nameOTEL_EXPORTER_OTLP_ENDPOINT: OpenTelemetry endpoint URLSet DATABASE_URL environment variable to enable PostgreSQL storage:
export DATABASE_URL=postgresql://user:password@localhost:5432/dbname
Migrations are automatically run on startup.
If DATABASE_URL is not set, the API uses file-based storage in the WORKSPACE_DATA directory.
This project uses sqlx's offline mode to avoid requiring a database connection during compilation. The .sqlx directory contains pre-generated query metadata.
⚠️ Important: Pre-commit hooks require either:
DATABASE_URL), OR.sqlx metadata files (see below)First-time setup (requires database):
# Set up database connection
export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/data_modelling
# Run migrations
cargo sqlx migrate run
# Generate offline metadata
./scripts/prepare-sqlx.sh
# Or manually: cargo sqlx prepare -- --all-features
# Commit the .sqlx directory to git
git add .sqlx
git commit -m "Add sqlx offline metadata"
Normal development (no database required after metadata is generated):
# Set SQLX_OFFLINE=true to use pre-generated metadata (recommended)
export SQLX_OFFLINE=true
# Build with offline mode
cargo build
# Run with offline mode
cargo run --bin api
# Or explicitly set it
export SQLX_OFFLINE=true
cargo build
If you don't have database access yet:
Pre-commit will fail until .sqlx metadata is generated. You can:
git commit --no-verify.sqlx directory# Run all tests sequentially (recommended for integration tests)
cargo test -- --test-threads=1
# Run specific test
cargo test --test test_name
# Format code
cargo fmt
# Lint code
cargo clippy --all-features
# Check for security vulnerabilities
cargo audit
Install pre-commit hooks:
pre-commit install
├── src/
│ ├── api/ # API implementation
│ │ ├── routes/ # Route handlers
│ │ ├── services/ # Business logic
│ │ ├── storage/ # Storage backends
│ │ └── middleware/ # Middleware
│ ├── export/ # Format exporters
│ └── lib.rs # Library root
├── migrations/ # Database migrations
├── tests/ # Test suites
└── Cargo.toml # Dependencies
data-modelling-sdk = "1.0.2" - Shared types and Git operationsaxum = "0.7" - Web frameworksqlx = "0.8" - Database toolkitutoipa = "5.0" - OpenAPI generationtokio = "1.0" - Async runtimeMIT License - see LICENSE file for details.
Contributions are welcome! Please ensure:
cargo fmtcargo clippycargo audit)For issues and questions, please open an issue on GitHub.