https://github.com/edmartt/locstorager
This microservice helps to storage locations with name, latitude and longitude
https://github.com/edmartt/locstorager
docker factory-pattern flask flask-api flask-caching flask-restful postgresql psycopg2-binary redis-cache solid-principles
Last synced: 29 days ago
JSON representation
This microservice helps to storage locations with name, latitude and longitude
- Host: GitHub
- URL: https://github.com/edmartt/locstorager
- Owner: Edmartt
- Created: 2023-06-27T04:41:08.000Z (almost 2 years ago)
- Default Branch: dev
- Last Pushed: 2023-10-17T20:38:59.000Z (over 1 year ago)
- Last Synced: 2025-02-01T18:43:33.113Z (3 months ago)
- Topics: docker, factory-pattern, flask, flask-api, flask-caching, flask-restful, postgresql, psycopg2-binary, redis-cache, solid-principles
- Language: Python
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Locstorager
locstorager is a microservice that has endpoints to store locations with name, latitude and longitude in a SQL database. The purpose is to store these locations so that later the wrapper-piper service with two ids can make a distance calculation using the Euclidean formula.
For every location saved, we need to return the location id property
## Requirements
- Python 3.11
- Docker
- Postgres## Project structure
```
.
├── config.py
├── Dockerfile
├── envrc.example
├── README.md
├── requirements.txt
├── run.py
└── src
├── database
│ ├── db_interface.py
│ ├── __init__.py
│ ├── postgres.py
│ └── schema.py
├── __init__.py
└── locations
├── cache
│ ├── cache_redis.py
│ └── __init__.py
├── data
│ ├── __init__.py
│ ├── pg_access_interface.py
│ └── pg_data_access.py
├── hooks.py
├── __init__.py
├── locs.py
├── models
│ ├── __init__.py
│ └── model.py
└── routes.py
```## Running
1. Clone the repo
```
https://github.com/Edmartt/locstorager.git
```2. Browse into the project folder
```
cd locstorager/
```## Running with Flask
1. Create virtual environment
```
python3 -m venv
```2. Activate virtual environment
```
source env/bin/activate
```3. Install dependencies
```
pip3 install -r requirements
```4. set the environment variables following the envrc.example
```
source .envrc
```5. Run
```
flask run -p
```## Running with Docker
1. Pull the image from Dockerhub
```
docker pull edmartt/locstorager
```2. set .env file following env.example
3. Create container
```
docker run --rm -p --env-file .env edmartt/locstorager
```### Note
This service requires a postgres database, and a redis instance running, so, if we send some requests for saving data in the database we'll get an error. If we try to get all the locations we'll see an erro related to REDIS, this is normal because this service is intended to be attached with docker compose in this project [wrapper-piper](https://github.com/Edmartt/wrapper-piper). You'll find the endpoint docs and the deployment with docker compose in that repo.