Skip to content

Basic MVP code that exposes a REST API for Tangara's air quality sensors, which are installed throughout Cali, Colombia.

License

Notifications You must be signed in to change notification settings

sebaxtian/tangara-api-mvp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tangara-api-mvp

Basic MVP code that exposes a REST API for Tangara's air quality sensors, which are installed throughout Cali, Colombia.

How to use

Please read and execute each step below:

Step 1

Create and use Python virtual environment:

$promt> python -m venv .venv
$promt> source .venv/bin/activate

Step 2

Install all Python requirements:

$promt> python -m pip install -U pip
$promt> pip install -r requirements.txt

Optional

Generate a requirements file and then install from it in another environment:

$promt> pip freeze > requirements.txt

Data Base SQLite

There is an SQLite database available to use out of the box.

All entities, relations and data are ready to use from the SQLite database file located in ./db/tangara-mvp.db and you don't need to change anything, because the API REST uses this SQLite database.

Optional, if you need to explore the database, I recommend you use: DB Browser for SQLite because it is easy to use, all that you need to do is open the SQLite database file from DB Browser and that's all.

Also, there are JSON ./db/json/ and CSV ./db/csv/ files for each entity on the database, therefore you can use the data for your own project, we support open knowledge that's important to the community open source.

Finally, we have exported an SQL file ./db/tangara-mvp.sql to recreate all the entities of our database in another SQL engine, like PostgreSQL or MySQL.

Notebooks

Jupyter Notebooks are helpful to explore some features and explain them to the team and easy to use before coding those features into the API, the purpose of the notebooks created in ./notebooks is only to explore, test, and explain those features to the team. You dont need change anything here.

Redis CLI

Redis is an open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine.

In development mode we need to install Redis CLI to debug our code and do some test. We will use Redis Server on a Docker configuration, that will be explaned later.

Downloading the source files:

$promt> wget https://download.redis.io/redis-stable.tar.gz

Compiling Redis CLI:

$promt> tar -xzvf redis-stable.tar.gz
$promt> cd redis-stable/
$promt> make redis-cli

Installing Redis CLI:

$promt> sudo cp src/redis-cli /usr/local/bin/

Connecting to the Redis server locally:

$promt> redis-cli -h 0.0.0.0 -p 6379

Redis Server

In development mode we are going to use a Docker container, to achieve that, we need just download the official Redis Docker Image, then we run a docker command to run a Redis Server container.

Downloading the official Redis Docker image:

$promt> docker pull redis:7-alpine

Run Redis Server container:

$promt> docker run --name tangara-redis -p 6379:6379 -d redis:7-alpine

Finally, we are ready to use a Redis Server in our project.

How to run

Development Mode

$promt> uvicorn app.main:app --reload

Testing

$promt> pytest -v -s -W ignore::trio.TrioDeprecationWarning -W ignore::DeprecationWarning

That's all for now ...


License

GPL-3.0 License

About me

https://about.me/sebaxtian

About

Basic MVP code that exposes a REST API for Tangara's air quality sensors, which are installed throughout Cali, Colombia.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published