Skip to content

Repository files navigation

NoSQL Database Implementations

Five Flask APIs developed for the NoSQL Databases course at Vilnius University, Faculty of Mathematics and Informatics, in autumn 2024. The projects cover four database engines and five assignments, including one application that combines MongoDB and Redis.

Project Database Main features
Redis meter API Redis Client registration, meter readings, per-client meter sets
MongoDB orders API MongoDB Clients, products, orders, aggregation statistics
Cassandra video API Apache Cassandra Channels, video catalogue, duration queries, view counters
Neo4j flight API Neo4j Cities, airports, flights, graph-based connection search
Railway ticket system MongoDB + Redis Route storage, ticket registration, transfer suggestions, fare caching

Quick start

Requirements: Git, Python 3.12, Docker, and Docker Compose. The commands below use a POSIX shell on macOS, Linux, or WSL. Run one API at a time on port 8080, or choose a different Flask port.

Clone the repository and start the MongoDB assignment:

git clone https://github.com/lukamaga/nosql-database-implementations.git
cd nosql-database-implementations
docker compose --profile mongodb up -d
cd mongodb-orders-api
python3.12 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt
cp .env.example .env
set -a
. ./.env
set +a
python -m flask --app app:app run --host 127.0.0.1 --port 8080

The application reads environment variables. .env.example contains the settings for the local Compose services; the shell commands above export them. .env is excluded from Git.

Each project guide contains its configuration, data model, endpoint reference, and example requests.

Database services

compose.yaml starts only the databases selected by a profile. Ports bind to localhost. Named volumes retain data when containers stop.

Profile Services Default host ports
redis Redis 6379
mongodb MongoDB 27017
cassandra Cassandra 9042
neo4j Neo4j 7687 Bolt, 7474 Browser
railway MongoDB and Redis 27017, 6379
# Run from the repository root; replace cassandra with another profile as needed.
docker compose --profile cassandra up -d
docker compose logs -f cassandra
# Stop this repository's containers while retaining their volumes.
docker compose down

Wait for the selected database to finish starting before launching Flask. Cassandra may need several minutes. The Neo4j development credentials are neo4j / coursework-demo-password; these match its .env.example and are intended only for the local demonstration.

If a default port is occupied, choose another host port and update the application's connection settings. For example:

REDIS_PORT=16379 docker compose --profile redis up -d
# Set REDIS_URL=redis://localhost:16379/0 in redis-meter-api/.env.

Compose also accepts MONGO_PORT, CASSANDRA_PORT, NEO4J_BOLT_PORT, and NEO4J_HTTP_PORT. Application variables are documented in each .env.example. The Redis meter API uses logical database 0; the railway example uses database 1.

Design

  • Redis uses hashes for clients, strings for readings, and sets for meter membership.
  • MongoDB stores document collections and computes order statistics through aggregation pipelines.
  • Cassandra duplicates video data into tables shaped for lookup and duration queries, with a separate counter table.
  • Neo4j represents flights as directed relationships and searches paths of up to three flights.
  • The railway service stores routes and tickets in MongoDB and caches fares in Redis for one hour.

Scope

These are standalone coursework APIs. They have no authentication layer and retain their original endpoint conventions, including Lithuanian names in the railway service. Use the supplied local database services with demonstration data. Cleanup endpoints remove data from their configured database; Neo4j cleanup clears the default graph, and railway cleanup clears its selected Redis logical database.

This repository contains application source, dependency lists, configuration examples, and documentation. Course handouts, instructor test suites, database binaries, virtual environments, and private configuration are not included.

License

MIT.

About

Five Flask coursework APIs using Redis, MongoDB, Cassandra and Neo4j, including a MongoDB + Redis railway ticket system.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages