A&D Notes

Each lambda will perform CRUD opperations on masterdb

Send email when:

Cognito

Just use the actual service

ECS development

moto - lib used to mock aws services

DynamoDB Local - mocks dynamodb

pytest - testing frame work

Lambda development

AWS SAM CLI - used to run lambdas locally

DynamoDB Local - mocks dynamodb

pytest - testing frame work

DB design

////////////////////////////////////////
// cognitov (users)
"email": "bob@bob.com",
"password": "bobRocks123",
"restaurant_id": "restaurant_bills_diner"

////////////////////////////////////////
// master db

////////////////////
// Fridge (inventory)
"{restauant_name}": { // partition-key
		"type": "fridge" // sort key
		"is_front_door_open": true,
		"is_back_door_open": false,
		"items": [ // list of all items in the fridge
        {
            "item_name": "apple",
            "desired_quantity": 15,
            "item_list": [ // number of items per expiry date and date added
                {
                    "current_quantity": 10,
                    "expiry_date": 27949012840,
                    "date_added": 27493640302,
                    "date_removed": 0,
                }
            ]
        }
    ]
}

////////////////////
// Orders
"{restauant_name}": { // partition key
		"type": "orders" // sort key
		"orders": [ // list of all orders
        {
						"id": 1,
            "delivery_date": 27321389892,
            "date_ordered": 27287316221,
            "items": [ // each item in the order
                {
                    "item_name": "apple",
                    "quantity": 5,
                }
            ],
        }
    ]
}

////////////////////
// Users
"{restauant_name}": { // partition key
		"type": "users", // sort key
		"users": [
				{
						"email": "{user_email}",
						"role": "chef",
				},
		],
}

////////////////////
// Health reports (in reality doing this in dynamo is stupid but fuck it)
// also this might require a change to the ui
// prehaps it just says the number of times it went over the expiry date
"{restauant_name}_{item_name}": { // partition key
	"type": "health_report", // sort key
	"items": [
		{
			"date_added": 219827349871,
			"date_removed": 23740173847,
			"expiry_date": 27949012840,
		},
	]
}

////////////////////
// Tokens
"{restauant_name}": { // partition key
	"type": "tokens", // sort key
	"tokens": [
				{
	          "token": "kjjd8sijfn3u9nf98fiwen29udhf2",
	          "expiry_date": 27924982131,
				},
		],
}

Interfaces for the lambdas

Orders mgr
// GET 
url: /orders/{id}

// response
{
	"status": 200,
	"order": {
				"id": 1,
        "delivery_date": 27321389892,
        "date_ordered": 27287316221,
        "items": [ // each item in the order
            {
                "item_name": "apple",
                "quantity": 5,
            }
        ],
    },
}
Fridge mgr
// GET door status
url: /fridge_status/

// responce
{
	"status": 200,
	"is_front_door_open": true,
	"is_back_door_open": false,
}

// PATCH door status
url: /set_fridge_status/
{
	"status": 200,
	"is_front_door_open": false,
}
// or (admin/delivery_man)
{
	"status": 200,
	"is_back_door_open": true,
}


////////////////////
// GET inventory
url: /get_inventory/

// response
{
	"status": 200,
	"fridge": [ // list of all items in the fridge
        {
            "item_name": "apple",
            "desired_quantity": 15,
            "item_list": [ // number of items per expiry date and date added
                {
                    "current_quantity": 10,
                    "expiry_date": 27949012840,
                    "date_added": 27493640302,
                    "date_removed": 0,
                }
            ]
        }
    ]
}

////////////////////
// PATCH quantity
url: /set_current_quantity/{item_name}/{expiry_date}/{date_added}
{
	"current_quantity": 9,
}

// response
{
	"status": 200,
}

////////////////////
// PATCH desired quantity (admin)
url: /set_desired_quantity/{item_name}
{
	"desired_quantity": 20,
}

// response
{
	"status": 200,
}

////////////////////
// DELETE item (admin)
url: /remove_item/{item_name}
{}

// response
{
	"status": 200,
}

////////////////////
// POST add new item (head chef)
url: /add_new_item/

// response
{
	"status": 200,
	"item_name": "dog",
	"desired_quantity": 12,
}
Users mgr (this could change a-lot)
////////////////////
// GET users (admin)
url: /users/
{}

// response
{
	"users": [
		{
				"name": "jason",
				"email": "jasonnn@jason.com",
				"role": "head chef",
		},
	]
}

////////////////////
// DELETE users (admin)
url: /users/{user_name}

// response
{
	"status": 200,
}

////////////////////
// PATCH users role (admin)
url: /users/{user_name}
{
	"role": "chef"
}

// reponse
{
	"status": 200,
}

////////////////////
// POST user (admin)
url: /user/
{
	"name": "jason",
	"email": "jasonnn@jason.com",
	"role": "head chef",
}

// response
{
	"status": 200,
}
Token mgr
////////////////////
// POST token
{}

// response
{
	"status": 200,
}


////////////////////
// check token is valid
{
	"token": "asdkfjsadnfkjansdfn"
}

// response
// valid
{
	"status": 200,
}
// invalid
{
	"status": 401,
}

Health report mgr
////////////////////
// GET health report (admin)
url: /health_report/{from_date}/{to_date}

// response
{
	"status": 200,
	"reports": [
		{
			"date_added": 219827349871,
			"date_removed": 23740173847,
			"expiry_date": 27949012840,
		},
	]
}