Skip to content

ildap/what-cook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What cook

This is simple go app for finding foods that can be made from available ingredients

INSTALL

go get github.com/go-kit/kit

go get gorm.io/gorm

go get gorm.io/driver/sqlite

go get gopkg.in/validator.v2

PROJECT STRUCTURE

├── README.md
├── cmd
│   ├── main.go
│   └── wiring_test.go
├── domain
│   ├── crud_repository.go
│   ├── food.go
│   └── ingredient.go
├── food
│   ├── endpoint.go
│   ├── service.go
│   ├── service_test.go
│   └── trasnsport.go
├── gorm
│   ├── db.go
│   ├── repository.go
│   └── repository_test.go
├── helper
│   └── utils.go
├── ingredient
│   ├── endpoint.go
│   ├── service.go
│   ├── service_test.go
│   ├── transport.go
│   └── what_cook_test.db
└── what_cook.db

EXAMPLE

GET localhost:8080/food/byIngredients/
Accept: application/json

{"ingredients" :[
        "pasta","bacon"
    ]
}

request for "pasta","bacon" return carbonara(absent chicken) and omelet(has bacon but missing egg):

    {
        "Foods": [
            {
                "Food": {
                    "ID": 1,
                    "CreatedAt": "0001-01-01T00:00:00Z",
                    "UpdatedAt": "0001-01-01T00:00:00Z",
                    "DeletedAt": null,
                    "Name": "carbonara",
                    "Description": "",
                    "IngredientWeights": [...],
                },
                "HasIngredients": [
                    {
                        "ID": 1,
                        "CreatedAt": "0001-01-01T00:00:00Z",
                        "UpdatedAt": "0001-01-01T00:00:00Z",
                        "DeletedAt": null,
                        "Name": "bacon",
                        "Calories": 100
                    },
                    {
                        "ID": 2,
                        "CreatedAt": "0001-01-01T00:00:00Z",
                        "UpdatedAt": "0001-01-01T00:00:00Z",
                        "DeletedAt": null,
                        "Name": "pasta",
                        "Calories": 50
                    }
                ],
                "AbsentIngredients": [
                    {
                        "ID": 3,
                        "CreatedAt": "0001-01-01T00:00:00Z",
                        "UpdatedAt": "0001-01-01T00:00:00Z",
                        "DeletedAt": null,
                        "Name": "chicken",
                        "Calories": 80
                    },
                ]
            },
            {
                "Food": {
                    "ID": 2,
                    "CreatedAt": "0001-01-01T00:00:00Z",
                    "UpdatedAt": "0001-01-01T00:00:00Z",
                    "DeletedAt": null,
                    "Name": "omelet",
                    "Description": "",
                    "IngredientWeights": [...],
                },
                "HasIngredients": [
                    {
                        "ID": 1,
                        "CreatedAt": "0001-01-01T00:00:00Z",
                        "UpdatedAt": "0001-01-01T00:00:00Z",
                        "DeletedAt": null,
                        "Name": "bacon",
                        "Calories": 100
                    }
                ],
                "AbsentIngredients": [
                    {
                        "ID": 4,
                        "CreatedAt": "0001-01-01T00:00:00Z",
                        "UpdatedAt": "0001-01-01T00:00:00Z",
                        "DeletedAt": null,
                        "Name": "egg",
                        "Calories": 70
                    }
                ]
            }
        ],
        "Err": null
    }

bon appetit!

Releases

No releases published

Packages

No packages published

Languages