Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/scylladb/shopping-cart

Sample ecommerce shopping cart app with ScyllaDB and Python
https://github.com/scylladb/shopping-cart

api cassandra ecommerce fastapi nosql python scylladb

Last synced: 3 months ago
JSON representation

Sample ecommerce shopping cart app with ScyllaDB and Python

Awesome Lists containing this project

README

        

# Ecommerce API - ScyllaDB & FastAPI sample application
This is a sample ecommerce application built with [ScyllaDB](https://www.scylladb.com/) and [FastAPI](https://fastapi.tiangolo.com/).

## Prerequisites
* [CQLSH](https://cassandra.apache.org/doc/stable/cassandra/tools/cqlsh.html)
* Python 3
* [ScyllaDB Cloud account](https://cloud.scylladb.com)

## Get started

Clone the repository:

```
git clone https://github.com/zseta/shopping-cart
cd shopping-cart
```

## Create database schema

Connect to your ScyllaDB Cloud cluster using CQLSH and create the schema:

```
cqlsh -u scylla -p -f schema.cql xxxx.xxxx.xxxx.clusters.scylla.cloud
```

## Set up API server

Create a new virtual environment:
```
virtualenv env
source env/bin/activate
```

Install Python requirements (FastAPI with Uvicorn server and ScyllaDB driver):
```
pip install fastapi "uvicorn[standard]" scylla-driver
```

Modify `config.py` to match your database credentials:

```python
HOST="node-0.aws-us-east-1.xxxx.clusters.scylla.cloud"
USER="scylla"
PASSWORD="xxxxxx"
DATACENTER="AWS_US_EAST_1"
KEYSPACE="ecommerce"
```

Run the server:
```
uvicorn main:app --reload
```

Visit API docs: http://127.0.0.1:8000/docs

![fast api docs](images/apidocs.png)