Skip to content

snigdhat1/Arcade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask Project

This project implements a key-value store with support for transaction and a REST API layer built using Flask. The data is persisted via SQLite3

Project Structure

Arcade/

kv_api.py  # Core Functionality           
kv_rest_api.py  # REST API    
requirements.txt    
README.md   

Setup Instructions

1. Clone the repository

git clone <your-repo-url>
cd Arcade

2. Setup virtual environment

# For Python 3.13
python3 -m venv venv
source venv/bin/activate      
# OR
venv\Scripts\activate 

3. Install requirements

pip install -r requirements.txt

Running the Application

Start Flask Server

python kv_rest_api.py

Curl Commands for KV Rest API

In another terminal, run the following curl commands.

CREATE - Set key-value pairs

curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "city", "value": "San Francisco"}'
curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "name", "value": "John"}'

READ - Get all values

curl http://127.0.0.1:5000/kv

READ - Get specific keys

curl http://127.0.0.1:5000/kv/name
curl http://127.0.0.1:5000/kv/city

READ - Get all values

curl http://127.0.0.1:5000/kv

UPDATE - Update existing key

curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "age", "value": 31}'

DELETE - Delete a key

curl -X DELETE http://127.0.0.1:5000/kv/city

TRANSACTIONS - Begin/Set/Commit/Verify Transaction

curl -X POST http://127.0.0.1:5000/transaction/begin
curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "temp", "value": "in_transaction"}'
curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "transaction_test", "value": 123}'
curl -X POST http://127.0.0.1:5000/transaction/commit
curl http://127.0.0.1:5000/kv

Rollbacks - Begin/Set/Commit/Verify Rollback

curl -X POST http://127.0.0.1:5000/transaction/begin
curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "rollback_test", "value": "should_not_persist"}'
curl -X POST http://127.0.0.1:5000/transactions/rollback
curl http://127.0.0.1:5000/kv

Error cases

curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"value": "no_key"}'
curl -X POST http://127.0.0.1:5000/kv -H "Content-Type: application/json" -d '{"key": "no_value"}'
curl http://127.0.0.1:5000/kv/nonexistent

Running Tests

pytest

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages