Giter VIP home page Giter VIP logo

dema-ai-code-challenge's Introduction

Scope & Limitations

For tech stack of this solution, I took the freedom to choose a few libraries and frameworks that I haven't used before but I wanted to try out, such as FastAPI, Tortoise ORM and Aerich.

Regarding the exercise's scope, I decided to focus on architecting all the pieces and implementing the core features, but I left aside automated testing, custom error handling and other details that would be necessary for a production-ready solution.

What was done

  • List inventory, including pagination and filtering by name, category and subcategory
  • Update inventory - update a product's name, quantity, category and/or subcategory
  • GraphQL API

What's missing

  • The GraphQL API returns products, but does not have GraphQL native pagination or filtering. The GraphQL API is implemented using Strawberry, which is a very simple and lightweight library, and it is very easy to integrate with FastAPI.
  • Bulk update support for Update Inventory
  • Sorting support for List Inventory

Setup

Requirements:

  • Python 3.7+ (tested with Python 3.11.6)

This project was created using poetry:

pip install poetry

# Install the dependencies
poetry install

# Start a virtual environment to run the server
poetry shell

Run the server

uvicorn app.main:app --root-path app/ --reload

Importing data from the csv files:

python scripts/import_data.py -d

Database migrations

The database already contains all the necessary data, changes can be done with Aerich

# To create a new migration
aerich migrate

# To upgrade the database
aerich upgrade

GraphQL

Start the server:

strawberry server app.graphql:schema

The graphql playground will be available at http://localhost:8000/graphql

Sample HTTP requests

# Get all products
curl -X GET "http://localhost:8000/products?page_size=15"
curl -X GET "http://localhost:8000/products?page_size=15&category=clothing"
curl -X GET "http://localhost:8000/products?page_size=15&sub_category=blouse"

# Update a product
curl -X PUT -H 'Content-Type: application/json' -d '{"name": "foobar"}' "http://localhost:8000/products/prod1548%23prod104001000080"

dema-ai-code-challenge's People

Contributors

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