lopezpedres / recalls-project

1 stars 0 forks source link

Creating APIs in Flask #5

Open lopezpedres opened 2 years ago

lopezpedres commented 2 years ago

Create only the APIS in flask to be consumed by a typescript frontend app

mate-h commented 2 years ago

This issue is too generic, so it will have to be expanded into smaller issues. The checklists on Github are a perfect way to do that.

There are a few basic steps for designing an API. Keep in mind that I don't know much about inverse supply chains in general so the use cases here are only examples that I came up with and they might not make any sense to you who studied this stuff.

  1. Identify use cases
    • what are the use cases in the real world for an inverse supply chain application?
    • who are the Actors in the system, what are their roles and how are they allowed to interact with specific datatypes?
    • what types of data will customers, companies and actors deal with?
    • write at least three examples:
    • "As a company, I want to manage the logistics of my supply chain and optimize for cost."
    • "As a supplier, I want to ship my goods and deliver my services to many companies on the platform."
    • "As a supply manager, I want to get notified if I need to backfill an order to maintain production."
  2. Data modeling
    • tools to help model the data: AirTable, app.diagrams.net, lucidchart
    • start with a high level, graph-like chart. very basic and only naming the datatypes.
    • add complexity only where needed by use cases from before
  3. API Design and implementation
    • API design follows simple CRUD (create - read - update - delete) patterns, and the REST api specification combined with a strongly typed language (e.g. python3 Protocols, typescript, Google Protobuf)
    • For postgreSQL, use a pre-built pgAdmin image to give administrator access to CRUD operations in the database. (this will save a lot of mundane work)
    • Use Role Based Access Control and a Custom UI (frontend) for specific use cases where one Actor in the system needs to input specific data - this is what we call "exposing" an API for a specific use case.
mate-h commented 2 years ago

API needs at least two main endpoints:

  1. Record batch = enter input, output and lab result. Assign unique lot code.

  2. Callback = look up all information based on lot code.

lopezpedres commented 2 years ago

Current APIs in insomnia file: Insomnia_2021-10-07.json