An api that returns what restaurants are open per sample data of restaurants previously provided.
Initial POC, and, if time, follow-on versions
Use Case | What restaurants are open at this time? |
SLA/KPI | N/A |
Auth | N/A |
CI-CD | N/A |
Deploy Constraints | Deployed locally only |
Host | https://localhost:{TBD} |
GET Endpoint | /restaurant/open/{datetime} |
Containerize the above via Docker
Use Case | What restaurants are open at this time? |
SLA/KPI | N/A |
Auth | N/A |
CI-CD | GitHub Actions |
Deploy Constraints | None |
Host | https://www.codeonward.com |
GET Endpoint | /restaurant/open/{datetime} |
- The endpoint must accept a datetime string
- The endpoint must return a list of open restaurants by name
- The endpoint will return an error to the client if the restaurant name is unrecognized
- The endpoint will return an error to the client on all other unrecoverable errors
- A restaurant is considered closed if the day-of-week is not included in the data for that restaurant
- If the given time is at the closing time of a restaurant, it is not included
- When parsing the given hours of operation, any parsing error will cause the restaurant to be unrecognized
- Unrecognized restaurants will return an error to the client
- The data given in CSV format will not have "broken" ranges, e.g. "Mon-Wed 11:00 am - 1pm" with "Mon-Wed 5pm-8pm"
- The data will never have hours of operation that span midnight
- Use python and the python standard library
- This solution must include testing (of course! Here to be checked off)
This example solution is using, loosely, the IDesign software methodology. For more information, see Righting Software.
The api router is very thin, and routes to the IDesign managers directly. Managers only communicate with engines and accessors. Managers can talk with other managers, but engines and accessors do not talk to other engines.
TODO: update the following with a diagram specific to this solution
One example of IDesign:
The main area of volatility is in the data: the hours a particular restaurant is open.
-
If a set csv of data was a fixed technical requirement, parsing the hours-open into a list of start-end times would happen outside of the main GET request, perhaps with an internal endpoint
-
Even better, an internal endpoint that takes the name of the restaurant with its new open hours would be saved into a database meeting/supporting our non-existent SLAs or KPIs.
- A python library for APIs will be used: Flask
- The given data in csv format will be parsed on startup into a json format such that each restaurant will have a list of open and closed day-of-week with time
{[
"Caffe Luna": [
{ "Mon": { "Open": "11:00", "Closed": "13:00" }},
{ "Tue": { "Open": "11:00", "Closed": "13:00" }}
],
"Neo": [
{ "Fri": { "Open": "18:00", "Closed": "24:00" }},
{ "Sat": { "Open": "14:00", "Closed": "24:00" }}
],
]}