Skip to content

SamWarden/user_service

Repository files navigation

User Service

User service is a simple CRUD Web API that adheres to the principles of Clean Architecture, uses some DDD tactical patterns and follows CQRS

List of endpoints

Endpoints

GET /healthcheck/

curl -X "GET" "http://localhost:5000/healthcheck/"
{"status": "ok"}

POST /users/

curl -X "POST" \
  "http://127.0.0.1:5000/users/" \
  -d '{
      "user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "username": "username",
      "first_name": "string",
      "last_name": "string"
  }'
{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "username": "username",
  "first_name": "string",
  "last_name": "string",
  "deleted": false
}

GET /users/

curl -X "GET" "http://127.0.0.1:5000/users/?offset=0&limit=1000&order=asc"
# Equivalent to http://127.0.0.1:5000/users/
{
  "users": [
    {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66ffa6",
      "username": "username",
      "first_name": "string",
      "last_name": "string",
      "deleted": false
    },
    {
      "id": "3fa85f64-5717-4562-b3fc-2c9f3f66ffa1",
      "first_name": "string",
      "last_name": "string",
      "deleted": true
    }
  ]
}

Dependencies

Infrastructure

Grafana stack

  • Grafana — Web view for logs
  • Loki — A platform to store and query logs
  • Vector.dev — A tool to collect logs and send them to Loki

Key python libs

  • FastAPI — Async web framework
  • SQLAlchemy 2.0 — ORM for working with database
  • Alembic — Database schema migration tool
  • DI — A dependency injection tool for easy initialization and delivery of dependencies
  • didiator — Mediator to interact with application layer and publish events
  • adaptix (dataclass_factory 3.0a0) — Library for simple model serialization and mapping
  • structlog — For better logging config
  • aio-pika — Client to interact with RabbitMQ

TODO

  • Implement outbox pattern
  • Add auto-tests
  • Configure CI