Skip to content

Microservice backend example of a customer experience software as a service using tests and DDD + Clean code/architecture + SOLID principles.

License

Notifications You must be signed in to change notification settings

cenciati/lamb-ddd-clean-arch-solid

Repository files navigation

CI

Lamb

Lamb is a fictional software as a service for managing customer experience. It provides an efficient way to improve your customers' journey through your company's services.

This repository implements just a piece of software of what could be the solution described above. It is the implementation of an API for consulting an extract that contains information about the transactions of commentaries left by customers.

⚙️ Tech stack

  • Python >= 3.10
  • FastAPI
  • SQLAlchemy
    • PostgreSQL
  • Poetry
  • Pytest
  • Docker
  • Docker-compose
  • GitHub Actions

🚀 Getting started

Prerequisites

To run this project locally, you need to have installed all the tools listed above that were used. To facilitate this dull setup process, I made a script using GNU make So, if you already have it installed on your computer, the repository contains a Makefile with a script setting up the project step by step.

Before running the scripts, make sure you already have it installed:

  • GNU make
  • Docker
  • Docker-compose

Installation

To install the project dependencies, you just need to write the following command in your terminal:

$ git clone https://github.com/cenciati/lamb-ddd-clean-arch-solid.git
$ cd lamb-ddd-clean-arch-solid/
$ make setup

Now the API should be working on http://localhost:8000/api/v1/

In case you want to remove everything that was installed, you can write the following command:

$ make clean

How to run locally

Once you've downloaded the source code, you can also run the API locally by typing:

$ make run_api_local

📄 Documentation

Subdomain modeling

Lamb - subdomain modeling diagram

Aggregates

Lamb - aggregates diagram

Endpoints

Lamb - endpoints documentation Lamb - endpoints documentation Lamb - endpoints documentation

Examples

Request commentary POST /extract/:

{
  "content": "Nothing to complain about.",
  "rating": 8,
  "tags": [
    {
      "id": 1,
      "name": "Support",
      "sentiment": 1,
      "subtag": false
    }
  ],
  "customer_id": "d5ec36c3-fe23-484d-8358-32aec747d42a",
  "instance_slug": "lamb",
  "journey_slug": "app",
  "automatic": false
}

Response commentary GET /extract/{comment_id}/:

{
  "data": [
    {
      "id": "c3543ffe-31d7-4d4c-9bdd-098c0fac2b22",
      "content": "Nothing to complain about.",
      "rating": {
        "score": 8,
        "detractor": false
      },
      "tags": [
        {
          "id": 1,
          "name": "Support",
          "sentiment": 1,
          "subtag": false
        }
      ],
      "customer_id": "d5ec36c3-fe23-484d-8358-32aec747d42a",
      "instance_slug": {
        "name": "lamb"
      },
      "journey_slug": {
        "name": "app"
      },
      "automatic": false,
      "experience_date": "2022-09-12T17:45:39.980237"
    }
  ]
}

Request user POST /users/:

{
  "email": "johndoe@mail.com",
  "password": "bananas2000",
  "instance_slug": "lamb"
}

Response customer GET /customers/id/{customer_id}:

{
  "data": [
    {
      "id": "d5ec36c3-fe23-484d-8358-32aec747d42a",
      "full_name": "John Doe",
      "email": "johndoe@mail.com",
      "cpf": {
        "number": "01234567890"
      }
    }
  ]
}

What's next?

  • Increase test coverage
  • Improve error handling by using notification pattern
  • Implement JWT authentication
  • Code an e-mail provider
  • Deployment to the cloud

📚 References

About

Microservice backend example of a customer experience software as a service using tests and DDD + Clean code/architecture + SOLID principles.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published