Skip to content

feat: restructure into Cargo workspace for microservices - #1

Closed
raphaeldiscky wants to merge 1 commit into
mainfrom
feat/microservice-workspace
Closed

feat: restructure into Cargo workspace for microservices#1
raphaeldiscky wants to merge 1 commit into
mainfrom
feat/microservice-workspace

Conversation

@raphaeldiscky

Copy link
Copy Markdown
Owner

Summary

  • Restructure flat single-crate template into a Cargo workspace monorepo with Clean Architecture layers
  • crates/app-core: shared infrastructure (config via figment, error handling, PostgreSQL pool, JWT auth, input validation, observability)
  • crates/app-user: user domain with entity → dto → repository trait → service → handler → routes
  • crates/app-testing: testcontainers-rs helpers for integration testing against real PostgreSQL
  • services/user-service: thin binary entrypoint with AppState + FromRef DI
  • deployments/docker-compose: PostgreSQL with external network, infra composition
  • scripts/migrate.sh: per-service migration script reading DATABASE_URL from each service's .env
  • Integration tests using testcontainers (6 tests, all passing)

Architecture

crates/app-core/        → shared infrastructure (config, error, db, auth, validation)
crates/app-user/        → user domain (Clean Architecture layers)
crates/app-testing/     → testcontainers helpers
services/user-service/  → binary entrypoint
deployments/            → docker-compose files

Test plan

  • cargo clippy --workspace -- -D warnings passes clean
  • cargo nextest run --workspace — 6 integration tests pass (requires Docker)
  • task start_infra starts PostgreSQL on port 15432
  • task db:migrate runs migrations via scripts/migrate.sh
  • cargo run -p user-service starts server (requires .env with DATABASE_URL, JWT_SECRET, PORT)
  • Verify CRUD endpoints: POST/GET/PUT/DELETE /api/users
  • Verify health endpoints: GET /healthz, GET /readyz

Restructure the flat single-crate template into a Cargo workspace
monorepo with Clean Architecture layers, PostgreSQL via sqlx,
JWT auth, input validation, testcontainers, and per-service Docker builds.

- crates/app-core: shared infrastructure (config, error, db, auth, validation, observability)
- crates/app-user: user domain (entity, dto, repository trait, service, handler, routes)
- crates/app-testing: testcontainers helpers for integration tests
- services/user-service: binary entrypoint with AppState + FromRef DI
- deployments/docker-compose: PostgreSQL with external network
- scripts/migrate.sh: per-service migration script reading DATABASE_URL from .env
- Integration tests using testcontainers-rs against real PostgreSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant