This project implements a Key-Value Store API with advanced features such as tenant isolation, JWT-based authentication, batch operations, and automatic TTL expiration. It is designed to be powerful, easy to use, and secure.
- CRUD Operations: Create, read, update, and delete key-value pairs.
- Batch Operations: Handle multiple key-value pairs in a single request.
- Time-to-Live (TTL): Automatically expire keys after a certain period.
- Multi-Tenancy: Supports isolated data storage for multiple users.
- JWT Authentication: Secure the API with JSON Web Tokens.
- Python 3.8 or higher
- Virtual environment manager (e.g., virtualenv or conda)
git clone https://github.com/melbinjp/Key_value_datastore
cd Key_value_datastore
Create and activate a virtual environment:
# On macOS and Linux:
python3 -m venv env
source env/bin/activate
# On Windows:
python -m venv env
.\env\Scripts\activate
pip install -r requirements.txt
alembic upgrade head
Start the Flask application:
flask run
Each endpoint is secured with JWT authentication, and a valid token must be included in the header of each request.
- POST
/login
:- Input:
{"username": "user", "password": "password"}
- Returns: A JWT token used for authenticated requests.
- Input:
- POST
/api/object
:- Header:
Authorization: Bearer YOUR_JWT_TOKEN
- Request:
{ "key": "exampleKey", "data": {"info": "exampleData"}, "ttl": 3600 }
- Response:
{ "message": "Key-Value pair created" }
- Header:
- GET
/api/object/<key>
:- Header:
Authorization: Bearer YOUR_JWT_TOKEN
- Response:
{ "key": "exampleKey", "data": {"info": "exampleData"} }
- Header:
- DELETE
/api/object/<key>
:- Header:
Authorization: Bearer YOUR_JWT_TOKEN
- Response:
{ "message": "Key-Value pair deleted" }
- Header: