Code Monkey home page Code Monkey logo

backend-challenge's Introduction

๐Ÿ’• ECG Analyzer Service

ECG Analyzer is distributed, scalable, secure and containerized web application built on top of FastAPI and Celery. For the sake of this challenge, it can be deployed locally with Docker Compose and provides a friendly API Documentation.

Getting Started

The service has been designed with scalability in mind, that's why Celery is the core here. FastAPI (with uvicorn workers) and Celery (with native worker approach) can be horizontally scaled whenever is needed. At the same time the API level just enqueue the tasks in the Celery broker (RabbitMQ) and perform some basic DB transactions.

The business logic is decoupled from the API and attached to the Celery Workers (or RabbitMQ consumers), which are the responsible for analyzing an ECG and performing the operations. In order to perform actions in a completely asynchronous manner, you will find some Celery Canvas implementations.

Prerequisites

  • Docker / Docker Compose
  • .env file (Following good practices it has not been included in the repo but can be found here). Copy this file to the project root.

Services

Service Name Description
api FastAPI service
analyzer Celery service
rabbitmq RabbitMQ service used as a broker within Celery
redis Redis service used as a backend within Celery
db PostgreSQL database service
pgadmin (Optional) PGAdmin service (UI for PostgreSQL database)

Proposed Architecture/Workflow for Production approach

Workflow/Architecture

Database: SQL Tables and relationships

SQL Tables

  • User passwords are hashed and persisted using Argon2.

Running the application

Once all prerequisites are satisfied, navigate to the root directory of the project and run the following commands in order to deploy the services locally:

Building containers:

docker compose build

Running containers:

docker compose up

Analyzer core

Providing an Analyzer interface (Abstract Class) is key for supporting new analyzers in the future. The interface and its implementation can be found on: ./src/analyzer.py.

There are 2 implementations that could analyze signals and return the count of zero-crossings.

API

ECG API has been designed with versioning pattern, so can easily be extended in the future with more functionalities. Explore the API and its endpoints using OpenAPI and Redoc documentation:

The authentication type is Basic Authentication (username and password)

Admin: Creating users

  1. Authenticate as Admin with Basic Auth (credentials can be found on the .env file)
  2. Perform a POST request to /v1/admin/register_user with the username and password to create.
  3. This user can now perform ECG submissions and result retrievals (check API documentation).

Running the tests

pip install -r requirements-dev.txt
pytest ./tests

backend-challenge's People

Contributors

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