Giter VIP home page Giter VIP logo

api_gateway_python's Introduction

API Gateway Python Project

This project serves as an API Gateway implemented in Python using Flask.

Description

The API Gateway is responsible for routing incoming requests to the appropriate backend services, managing authentication and authorization, and aggregating the responses before sending them back to the client.

Features

  • Routing: Directs incoming requests to the appropriate backend service based on the request path.
  • Authentication and Authorization: Implements authentication and authorization mechanisms to ensure secure access to backend services.
  • Request Aggregation: Aggregates responses from multiple backend services and sends a single response back to the client.
  • Logging: Records request and response information for monitoring and debugging purposes.

Installation

  1. Clone the repository:
git clone https://github.com/majdrezik/api_gateway_python.git
cd api_gateway_python
  1. Install dependencies:
  pip install -r requirements.txt

Usage

  1. Run the main Flask application: (root directory)

flask run --host 172.31.255.1 --port 5000

  1. Run the services:
    • cd services/{SERVICE_NAME_1}

    • flask run --host 192.168.1.195 --port 10030

    • cd services/{SERVICE_NAME_2}

    • flask run --host 192.168.1.195 --port 10031

Make sure you assing different ports to each service

On Postman navigate to http://127.0.0.1:5000 which acts as our Entrypoint (client) and choose different apis from the list (e.g http://127.0.0.1:5000/v1/echo) This will show the starting point and the end result (starting from one url and ending in another url). You can try accessing the micro-service directly, like http://192.168.1.195:10030/ . this will fail (made a simple firewall)

Notice what will happen when we choose to hit the /v1/register API - It'll get the micro-service that's running on a totally different url

Screenshot 2024-02-13 at 3 06 38

Here's the Entrypoint of the API_GATEWAY where we can see the active APIs

Screenshot 2024-02-13 at 3 07 45

Notice what will happen when we choose to hit the /v1/echo API - It'll get the micro-service that's running on a totally different url

Screenshot 2024-02-13 at 3 06 59

When we try to access the micro-service directly, the request will be blocked. in real life this will be handled via FIREWALL or other ways, here I created a DUMMY firewall with ALLOWED LIST that only clients coming from API_GATEWAY can access (original url)

Screenshot 2024-02-13 at 3 07 18

api_gateway_python's People

Contributors

majdrezik 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.