Giter VIP home page Giter VIP logo

customer-platform's Introduction

Customer Platform

A system for managing customers and their purchased items, demonstrates distributed, data oriented design.

customer_platform drawio (2)

** In the actual configuration some services that should be private are currently exposed to the host machine for debugging purposes

These are the main components of the platform:

  • customer-bff-service - A client-facing web server, serves a specfiic frontend, for example a mobile application. It exposes a REST API and is a Kafka Producer. When deployed, this service is reachable from outside the container network on port 5000.

  • customer-management-service - The system's core service, manages the entities of the system in a relational database using SQLAlchemy. It exposes an internal REST API, interacts with the database using SQLAlchemy ORM and consumes messages from "purchases" topic. In dev stage, the service seeds it's own data for testing purposes. When deployed, it is not exposed to requests from outside the container network.

  • Kafka Broker - A Pub-Sub system messaging system for data streaming, processing and async communication.

  • Zookeeper - Provides state management for Kafka

  • CustomerDB - PostgreSQL

  • Airflow - A task management platform for developing, scheduling and monitoring batch-oriented workflows. Deployed separately from the other components (as it consists of 7 containers). loads a "calc_total_spent" DAG that periodically updates the database with customers' total spent sum.

  • Grafana - A monitoring platform for datasources. Displays the calculated data from customer_total_spent

  • customer-frontend - A simple react application that allows for purchasing and viewing purchased items, deployed independently.

Deployment

To Deploy the platoform, only docker is required:

  1. Clone this repository
  2. A a bridge network is required for communication with airflow later on:
docker network create customer-airflow-bridge
  1. Run the docker-compose file (with DOCKER_DEFAULT_PLATFORM is set to amd64 in case you're running an ARM CPU):
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker-compose up -d --build

Screenshot 2023-03-11 at 11 39 44

Screenshot 2023-03-11 at 11 39 56

** The target platform is needed because even if you run a compatability layer like Rosetta 2, some libraries such as kafka-python are not designed for inter-communication between different architectures

If you wish to deploy the services independently:

customer-bff-service - https://github.com/Tavh/customer-platform/blob/main/customer-bff-service/README.md

customer-management-service - https://github.com/Tavh/customer-platform/blob/main/customer-management-service/README.md

Performing requests:

There should already be prepared data in the database because of the seeder in 'customer-management-service'

Fetching a customer's purchases:

curl -X GET http://localhost:5000/customers/1/purchases

Screenshot 2023-03-12 at 0 04 56

Making a purchase

curl -X POST http://localhost:5000/customers/1/purchase/1

Screenshot 2023-03-12 at 0 05 10

By inspecting the logs in customer-management-service, we can see that the message was succesfully consumed and a purhcase record was inserted to the database:

docker-compose logs customer-management-service

Screenshot 2023-03-11 at 11 48 00

Screenshot 2023-03-11 at 11 46 56

Airflow:

Screenshot 2023-03-11 at 19 51 34

Airflow is deployed with a different docker-compose, for instructions, go to: https://github.com/Tavh/customer-platform/blob/main/airflow/README.md

Grafana

Screenshot 2023-03-11 at 18 25 52

Grafana is deployed with the main docker-compose, but the datasource and dashboard are configured separately, reffer to:

https://github.com/Tavh/customer-platform/blob/main/grafana/README.md

Frontend

Screenshot 2023-03-11 at 19 46 46

The frontend is a simple react app, for guidance go to: https://github.com/Tavh/customer-platform/blob/main/customer-frontend/README.md

customer-platform's People

Contributors

tavh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.