TODO is a simple web application which displays tasks that "should be done".
These tasks can be created/updated/deleted only via API /api/v1
using
proper API Key
. This API is documented with Swagger
documentation. Purpose of this application is mainly to leverage it as
a basic application which can be then mananaged with IaC/GitOps approach.
Last release is always automatically deployed as live demo in Fly.io 🚀:
TODO's tasks in live demo are managed via TODO Terraform provider and Terraform manifests are stored in repository jakuboskera/infra/todo.
As you can see, tasks which are defined in this Terraform manifest are same as tasks in live demo.
See Manage TODO application via Terraform provider.
- 📖 TOC
- 🏁 Get started
- 🎉 Run in docker using docker-compose
- 😎 Manage TODO application via Terraform provider
- Develop
-
Clone this repo
git clone git@github.com:jakuboskera/todo.git
-
Navigate to a folder
todo
cd todo
-
Issue
make
command to see available targets, which you can usemake
- docker
- docker-compose
make run
Application is by default accessible on http://localhost:5000.
The application needs environment variable API_KEY
with some secret.
This secret is then used for securing API endpoints for adding, updating
or deleting tasks. By default the secret is 12345678
(configured in
.env file). So requests for interacting with these endpoints
need to have HTTP header X-API-KEY
with value which is equal to
the environment variable API_KEY
, otherwise the HTTP error code 401
is returned to the client.
make clean
There was created a TODO Terraform provider for this application, which can be used for managing a TODO instance. So you can create/update/delete a TODO tasks using Terraform manifests.
-
Run TODO application localy using docker-compose
-
Go to http://localhost:5000 and check that there are no tasks created
-
Create this terraform manifest to create two tasks
# main.tf terraform { required_providers { todo = { source = "jakuboskera/todo" version = "0.2.0" } } } provider "todo" { url = "http://localhost:5000" api_key = "12345678" } resource "todo_task" "coding" { text = "Create the best application ever" } resource "todo_task" "girlfriend" { text = "Find a kind and pretty girlfriend" is_done = true }
-
Initialize this Terraform project
terraform init
-
Create tasks in TODO application
terraform apply -auto-approve
-
Go to http://localhost:5000 and check if these tasks were created:
- Create the best application ever
Find a kind and pretty girlfriend
-
Now you can change a text of this task, modify status, add another tasks, etc.
-
After that you can delete tasks by
terraform destroy -auto-approve
This will run application localy using SQLite as database.
export FLASK_APP=$PWD/main.py
export FLASK_DEBUG=True
export API_KEY=12345678 # used in X-API-KEY header when creating/updating/deleting tasks in API
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
flask db upgrade
flask run
If you will do a changes to DB schema don't forget to run
flask db migrate