This web application finds the nearest hawker center within 20km of the input location (lat, long) within Singapore .
- docker engine or docker desktop on windows/ mac Get docker
- docker-compose (should come together with docker desktop) Get compose
The web application starts by running (from within the project folder)
docker-compose up -don your shell with docker installed. Run the following from outside the project folder:
docker-compose up -f <path to folder>/docker-compose.yml -dThe first run might take some time as images are downloaded and built.
Check out the app by going to localhost:8501 in a browser.
Note: You might need to disable firewall/ set firewall rules to allow port 8501.
The application comprises 3 containers
uicontainer developed with Streamlitdbcontainer - MongoDB instance for geolocation queriesingestcontainer that downloads dataset from data.gov.sg
Use the standard docker-compose CLI to explore the project
- Display running containers:
docker-compose ps - Display logs:
docker-compose logs - Run project attached:
docker-compose up - Run tests
- UI container
docker-compose exec ui pytest - Ingest container
docker-compose exec ingest pytest
- UI container
This app uses docker containers starting from development. This ensures a consistent, standardised environment for development, testing and running the application.
- A bridge docker network is used for communication between containers
- A docker volume is mounted on mongodb container for persistent storage of db data.
- The
<project folder>/composedirectory contains the Dockerfiles and other files required for building the images.
Data is brought into the application by the ingest container. The following steps are taken:
- Data is downloaded in a stream and unzipped.
- Data is processed line by line - it is loaded as a JSON and a regex pattern is used to extract the PHOTOURL and NAME fields.
- If the pattern matches and JSON is valid, a type validator is used to validate the data.
- The data is inserted into MongoDB
- Geolocation indexes are created on the GeoJSON field
- Data in DB is persisted in a docker volume
The above steps are written as download_data and extract_data functions and tested independently. The ingest container also exposes these steps as a REST api for the user to reload data.
The web UI captures users' [lat, long] input values and queries the DB on the geolocation index. The query returns the 5 nearest locations within a (configurable) 20km radius. The UI renders the returned documents and also plots them on a map.