The company has a REST API to allow users to create accounts, add cities they're interested in, and view the current weather data in those cities. It's a very popular API used by millions of people each day, and has a diverse user base. This API is written in Python's Flask framework, and uses PostgreSQL as it's data storage layer. It's not perfect though, and there are a number of enhancements and bug fixes that need to be made to it. This is where you come in.
- Ability to pick up a codebase, understand the basics, and provide value quickly
- Knowledge of advanced data management concepts (caching, data tiering (in-db, file storage))
- Knowledge of MVC paradigm
- Create a Docker Hub account at https://hub.docker.com/signup
- Download Docker Desktop
- Run Docker Desktop locally to start up Docker to allow you to run this application
- Have a way to make API calls. We recommend Postman.
- Run
docker-compose up --build
(This will take some time to build everything up the first time you run it)
CTRL+C
from the application- Run
docker-compose down
In your favorite Postgres database viewer, you can connect to it to see the tables via:
Host: localhost
Port: 5432
Database: postgres
Username: Postgres
This database does not have password authentication enabled.
POST localhost:80/users
Request Data:
{
"name": "test"
}
Response Data
{
"name": "test"
}
GET localhost:80/users/test
Response Data:
{
"name": "test",
"cities": [
{
"name": "chicago",
"temp": 43.9,
"pressure": 1021,
"humidity": 100
}
]
}
POST localhost:80/users/test/cities
Request Data:
{
"name": "detroit"
}
Response Data
{
"name": "test",
"cities": [
{
"name": "chicago",
"temp": 43.9,
"pressure": 1021,
"humidity": 100
},
{
"name": "detroit",
"temp": 48.29,
"pressure": 1025,
"humidity": 87
}
]
}
- Implement the create user endpoint. Deal with the problem if the user already exists, and return the serialized response that uses the
to_json
method - Change the city temperature to display as a user-readable format (ex. 46.5F instead of just 46.5)
- The weather API is $1/API Call. Explain (don't code) why this is a problem and various options to solve it