Code Monkey home page Code Monkey logo

movies-service-api's Introduction

Async API for movies Service

Core Stack

  • FastAPI
  • PostgreSQL
  • Elasticsearch
  • Redis
  • Pytest & aiohttp

About

The project follows a microservice architecture. This particular service (Movies Service) is responsible for implementing API endpoints to access data from the data warehouse. It utilizes Elasticsearch as the data source and Redis as a caching.

The ETL data warehouse service is a separate service. It is responsible for continuously extracting, transforming and loading data from PostgreSQL into the Elasticsearch DB.

Auth Service is an implicit dependency for this service, as some API endpoints may require authentication. The authentication is based on JWT tokens. Instead of constantly querying the authentication service for each user access attempt, the service validates the provided JWT token using a shared secret with the authentication service. This approach allows the service to authenticate users without needing to interact with the authentication service every time.

Services interaction scheme:

services-integration_schema.svg

Requirements

  1. ETL & data warehouse service

  2. Auth Service

Installation & Launching

  1. Before running this service, start the dependent services specified in the requirements.

  2. Configure & activate virtual environment using provided requirements.txt or Pipfile.

  3. Configure environment in ./fastapi-solutions/.env

    • Use .env.sample to set expected environment in .env
  4. Use docker-compose to launch project:

    docker-compose up
  5. The service is available on localhost: 80.

Tests

Tests are written using pytest and aiohttp libraries.

Configuration:

  1. Configure & activate virtual environment using provided requirements.txt.

    pip install -r ./fastapi-solution/tests/functional/requirements.txt
  2. Setup environment in the file fastapi-solution/tests/.env

    • Use fastapi-solution/tests/.env.sample to set expected environment in .env

Tests launch:

  1. Build & Run Test docker-compose docker-compose.test.yaml

    docker-compose -f docker-compose.test.yaml up --build
  2. Run tests:

    pytest fastapi-solution/tests --docker-compose=docker-compose.test.yaml --docker-compose-no-build --use-running-containers -v

Debugging

Project debugging

  1. Configure launcher .vscode\launch.json

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Python: Remote Attach",
          "type": "python",
          "request": "attach",
          "port": 5678,
          "host": "localhost",
          "pathMappings": [
            {
              "localRoot": "${workspaceFolder}/fastapi-solution",
              "remoteRoot": "/opt/app"
            }
          ]
        }
      ]
    }
  2. Launch debugging docker-compose docker-compose.debug.yaml

    docker-compose -f docker-compose.debug.yaml up --build
  3. Launch the before configured launcher (remote attach)

  4. The service is available on localhost:8000

Tests debugging

  1. Setup configuration in VsCode Settings:

    {
      "python.testing.pytestArgs": [
        "--rootdir",
        "fastapi-solution/tests",
        "--docker-compose=docker-compose.test.yaml",
        "--docker-compose-no-build",
        "--use-running-containers",
        "-v"
      ],
      "python.analysis.extraPaths": ["fastapi-solution/src/"],
      "python.testing.unittestEnabled": false,
      "python.testing.pytestEnabled": true,
    }

movies-service-api's People

Contributors

evgeneration avatar vogelfenx avatar iggishal 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.