Skip to content

timsolov/ms-users

Repository files navigation

ms-users (WIP) - boilerplate for microservice with clean architecture

General features

  • Totally support Clean Architecture;
  • Auto-generate gRPC-server, gRPC-client, HTTP/Web server, swagger documentation from .proto files;
  • Graceful shutdown;
  • Accept interface, return struct pattern;
  • CQRS pattern for usecases;
  • PASETO token;

Directories structure

├── api
│   └── proto                     - proto files for describing API (gRPC/REST)
├── app                           - main folder of application
│   ├── common                    - commonly used packages, abstract implementations, helpers
│   ├── conf                      - conf package: here we should define ENV variables which configures this service
│   ├── delivery                  - delivery layer in Clean Arch: all interfaces for interacting with API of service (cli, grpc handlers, http handlers)
│   ├── domain                    - entities layer in Clean Arch: domain entities, domain logic, all significant variables (e.g. common errors)
│   ├── repository                - repository layer in Clean Arch: logic for working with database, cache, external services (e.g. abstraction for working with external emails service should be placed here)
│   └── usecase                   - usecases layer in Clean Arch: whole business logic should placed here and separated by folders
├── build                         - ci/cd scripts
├── cmd                           - main packages
├── docs                          - documentation
├── integration_test              - integration tests should be placed here
├── settings                      - folder additional settings files
└── third_party
    └── OpenAPI                   - OpenAPI 2.0 will stored here

Service specific features

  • Create profile with email-password identity
  • Confirmation of email-password identity
  • Repeat email confirmation for email-password identity
  • User's profile
  • Update user's profile
  • Authentication by email-password identity
    • Switch JWT token to PASETO token
  • Reset password process for email-password identity
    • Init reset password process end-point
    • Confirm reset password process and set new password end-point
  • Timeout for http handlers
  • JSONSchema configurable profile info
  • Healthcheck for all dependencies
    • PostgreSQL
    • gRPC Server
    • ms-emails
  • Status of service
  • Opentelemetry
  • Prometheus
  • Authentication by Google OAuth 2.0
  • Authentication by phone-password identity

Dependancies

  • PostgreSQL - OLTP database for storing data;
  • PgQ - PostgreSQL native queue plugin for handling outbox pattern;
  • ms-emails - service for sending emails;

Prometeus metrics

Prometeus metrics available on: http://$HTTP_HOST:$HTTP_PORT/metric/

Default: http://0.0.0.0:11000/metric/

Healthcheck

http://$HTTP_HOST:$HTTP_PORT/health/

Default: http://0.0.0.0:11000/health/

After making the request you will receive a response:

{
  "app": {
    "buildtime": "2022-07-26T19:19:51Z",
    "version": "108f44c"
  },
  "grpc_server": {
    "duration": "649.655µs",
    "status": "UP"
  },
  "postgres": {
    "duration": "1.039368ms",
    "stats": {
      "idle": 0,
      "in_use": 1,
      "max_idle_closed": 0,
      "max_idle_time_closed": 0,
      "max_life_time_closed": 0,
      "max_open_connections": 5,
      "open_connections": 1,
      "wait_count": 0,
      "wait_duration": 0
    },
    "status": "UP"
  },
  "status": "UP"
}

Status

http://$HTTP_HOST:$HTTP_PORT/status/

Default: http://0.0.0.0:11000/status/

Response values:

  1. NOT_READY - the service not ready yet it's in preparing dependancies status;
  2. UP - the service in battle mode you can use it;
  3. DOWN - the service is shuting down.

Releases

No releases published

Packages

 
 
 

Languages