Repo for the project of 2nd semester (2023-2024) course Web Information Systems and IoT of the postgraduate program Informatics and Telematics of Harokopio University.
It implements the consensual divorce web service as described in gov.gr.
- Keycloak IAM for user management
- A Postgres database for Keycloak
- A Flask for backend main app component
- A Postgres database for Flask main app data
- ...
- Microservices: Docker/Docker Compose, Keycloak, Postgres, ...
- Backend: Python, flask/flask-smorest, postgres, sqlalchemy/flask-sqlalchemy, marshmallow, python-keycloak, swagger
- Frontend: React, ...
- Notifications: ...
- Devops/Deployment: ...
Database models were created according to the logic indicated in the below diagram
(Folder models)
user
marriage
user_marriage
divorce
user_divorce
Implementation with flask-sqlalchemy
Implemented with marshmallow
(Folder schemas)
user
divorce
user_divorce
marriage
refresh
(Repopulates database. For development/presentation puprposes)
- User authentication implemented with Keycloak, along with the python library python-keycloak
- A decorator is implemented which performs user authentication and authorization based on role using Header Authorization Bearer token
- In order to do authentication/authorization from swwagger interface, click Authorize button on the top right and paste the user token
This will add the Authorization Bearer on each request header,
(Folder resources)
user
marriage
divorce
rules
refresh
/users
→ GET: Return all users in flask app db/users
→ POST: Create a user with a specific role in Keycloak/users/<user_id>
→ GET: Get an api db user's token if user is in Keycloak
/marriages
→ GET: Return all marriages
/cases
→ GET: Return all divorces/cases
→ POST: Create a divorce/cases/<case_id>
→ GET: Get a divorce/cases/<case_id>
→ PUT: Update a divorce
/rules
→ GET: Return info about all available endpoints/methods.
/refresh
→ GET: Repopulates the flask app database with users and marriages (for development/presentation purposes)
Ifdrop
query param is set toFalse
, it just returns all the users with their attributes, so we can test use cases.
Detailed documentation on endpoints and corresponding schemas available on documentation endpoints
Make .env
file as in .env.example
WORK_ENV=prod/dev
. If empty, defaults to dev
. See config.py/setup.py
for details.
With Docker (Desktop) installed, on the folder where docker-compose.yaml
is:
>>> docker-compose up
- In order to work with Keycloak, after the services are up, a realm and two clients (backend and frontend) have to be created in Keycloak and
the variablesREAL, CLIENT_ID, CLIENT_SECRET
in.env
file have to be populated with the corresponding values.
After this the services have to be restarted.