Connect is a Python Flask project within the cloud-native ecosystem

Overview

Connect

Project 2 from Cloud-Native Nanodegree

Extracting the monolith

The first step is to understand how the current system is architected and identify clear context boundaries. There are three diagrams for that:

What is clear from the beginning is that Connection has two dependencies: Location and Person, while Location has one dependency: Person. It's possible to implement one service per entity. The frontend calls two resources: Connection Data Resource and Persons Resource. Since these two entities will probably be separated in different services, we might need a proxy available for the frontend that will redirect the requests to the microservices.

A good candidate for the first refactoring would be Connection entity, since it only imports and isn't imported by anything. But there is no simple way for it to import Location and Person, so let's think of something else.

I see Person as the most isolated entity. Location needs a Person ID in order to be created, but this has no relation with Person model and it is received directly from the request. Therefore, we can start with a Person microservice and setup a proxy. The Person microservice will be an internal service that requires fast and reliable responses, so we can use gRPC to communicate. But we can use REST to start.

Step 1: Person microservice structure

  • person_service
    • person
      • model
      • schema
      • service
      • controller
    • routes
    • config

Methods: - Create - Retrive - Retrieve All

Step 2: Create a proxy to redirect Person requests to Person microservice and the rest to the Monolith

This proxy will have the same address as the frontend is expecting and will communicate with Person service and the monolith via RESTful APIs. The monolith will have its address changed to have a smooth migration.

After that, it's clear that Location is coupled with Connection entity; we'll need to refactor and move Location logic in ConnectionService to Location methods before moving it to its own service.

Step 3: Refactor and extract Location

  • location_service
    • location
      • model
      • schema
      • service
      • controller
    • routes
    • config

Location is also an internal service and we can use gRPC for communication, but we can start with REST.

After that, we can finally get rid of the monolith and work on extracting Connection microservice. This service will require a RESTful API due to the communication with the frontend, but it'll also implement gRPC in the future to communicate with internal services.

Step 4: Extract Connection

  • connection_service
    • connection
      • model
      • schema
      • service
      • controller
    • routes
    • config

From that we have our microservices implemented and we can implement gRPC between them.

Step 5: Implement gRPC communication in the internal services

After that, we need to evaluate the performance and possible caveats in the system.

You might also like...
A Fast API style support for Flask. Gives you MyPy types with the flexibility of flask
A Fast API style support for Flask. Gives you MyPy types with the flexibility of flask

Flask-Fastx Flask-Fastx is a Fast API style support for Flask. It Gives you MyPy types with the flexibility of flask. Compatibility Flask-Fastx requir

Flask-app scaffold, generate flask restful backend

Flask-app scaffold, generate flask restful backend

Pf-flask-rest-com - Flask REST API Common Implementation by Problem Fighter Library

In the name of God, the Most Gracious, the Most Merciful. PF-Flask-Rest-Com Docu

Open-source Flask Sample built on top of flask-dance library
Open-source Flask Sample built on top of flask-dance library

Open-source Flask Sample built on top of flask-dance library. The project implements the social login for Github and Twitter - Originally coded by TestDriven.IO.

Flask-redmail - Email sending for Flask

Flask Red Mail: Email Sending for Flask Flask extension for Red Mail What is it?

Flask-template - A simple template for make an flask api

flask-template By GaGoU :3 a simple template for make an flask api notes: you ca

A boilerplate Flask API for a Fullstack Project :rocket:

Flask Boilerplate to quickly get started with production grade flask application with some additional packages and configuration prebuilt.

Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Comments
  • Tentative: extract Connection microservice

    Tentative: extract Connection microservice

    Expected output:

    • OpenAPI documentation - docs/open_api.json
    • gRPC documentation - docs/grpc.txt
    • Postman collection - docs/postman.json
    • Kubernetes manifest
    • Dockerfile
    opened by larien 0
  • Tentative: extract Location microservice

    Tentative: extract Location microservice

    Expected output:

    • OpenAPI documentation - docs/open_api.json
    • gRPC documentation - docs/grpc.txt
    • Postman collection - docs/postman.json
    • Kubernetes manifest
    • Dockerfile
    opened by larien 0
  • Tentative: extract Person microservice

    Tentative: extract Person microservice

    • [x] Implement persons-api microservice with db setup and k8s manifests
    • [ ] Migrate persons reference in monolith to this microservice
    • [ ] Remove persons monolith logic
    • [ ] Write open API docs
    • [ ] Write Postman collection
    • [ ] TODO - implement gRPC

    Expected output:

    • OpenAPI documentation - docs/open_api.json
    • gRPC documentation - docs/grpc.txt
    • Postman collection - docs/postman.json
    • Kubernetes manifest
    • Dockerfile
    opened by larien 0
  • Architecture migration to microservices

    Architecture migration to microservices

    Expected output:

    • Architecture diagram: docs/architecture_design.png
    • Justification for architecture's design decisions

    NOTE: gRPC, REST and Kafka are mandatory

    opened by larien 0
Owner
Lauren Ferreira
Creating things I'm proud of.
Lauren Ferreira
Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure.

Flask pre-setup architecture. This can be used in any flask project for a faster and better project code structure. All the required libraries are already installed easily to use in any big project.

Ajay kumar sharma 5 Jun 14, 2022
flask-apispec MIT flask-apispec (🥉24 · ⭐ 520) - Build and document REST APIs with Flask and apispec. MIT

flask-apispec flask-apispec is a lightweight tool for building REST APIs in Flask. flask-apispec uses webargs for request parsing, marshmallow for res

Joshua Carp 617 Dec 30, 2022
flask-reactize is a boostrap to serve any React JS application via a Python back-end, using Flask as web framework.

flask-reactize Purpose Developing a ReactJS application requires to use nodejs as back end server. What if you want to consume external APIs: how are

Julien Chomarat 4 Jan 11, 2022
Flask-Discord-Bot-Dashboard - A simple discord Bot dashboard created in Flask Python

Flask-Discord-Bot-Dashboard A simple discord Bot dashboard created in Flask Pyth

Ethan 8 Dec 22, 2022
Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications.

Flask Sitemapper Flask Sitemapper is a small Python 3 package that generates XML sitemaps for Flask applications. This allows you to create a nice and

null 6 Jan 6, 2023
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 310 Dec 14, 2022
Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.

Flask-Rebar Flask-Rebar combines flask, marshmallow, and swagger for robust REST services. Features Request and Response Validation - Flask-Rebar reli

PlanGrid 223 Dec 19, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 282 Feb 11, 2021
Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development.

Flask-Starter Flask-Starter is a boilerplate starter template designed to help you quickstart your Flask web application development. It has all the r

Kundan Singh 259 Dec 26, 2022
Brandnew-flask is a CLI tool used to generate a powerful and mordern flask-app that supports the production environment.

Brandnew-flask is still in the initial stage and needs to be updated and improved continuously. Everyone is welcome to maintain and improve this CLI.

brandonye 4 Jul 17, 2022