Skip to content

satyam0777/polyglotdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PolyglotDB

Demonstrates real-world backend architecture using multiple databases in a single system

A single Express.js API powered by multiple databases, each chosen deliberately based on its strengths.

Built to understand database design decisions from first principles, not just syntax.


Core Idea

Different problems require different data models.

Instead of forcing one database to do everything, this system uses polyglot persistence
choosing the right database for each use case.


Tech Stack & Responsibilities

Database Responsibility Why
PostgreSQL Users, Orders, Payments ACID transactions, strong consistency
MongoDB Product Catalog Flexible schema
Redis Sessions, Caching TTL-based expiry, ultra-fast
Cassandra Activity Logs High write throughput
Neo4j Recommendations Graph traversal

Key Insight

"What are your access patterns?"

  • Transactions → PostgreSQL
  • Flexible data → MongoDB
  • Speed → Redis
  • High writes → Cassandra
  • Relationships → Neo4j

API Endpoints

Endpoint Database Description
POST /auth/login Redis Session with TTL
GET /users/:id PostgreSQL Indexed read
GET /products MongoDB Flexible schema
POST /orders Multi-DB Transaction + logs + graph
POST /activity Cassandra Event logging
GET /recommend/:userId Neo4j Graph traversal

Example: Multi-Database Flow

When placing an order:

  • PostgreSQL → transaction
  • Cassandra → logging
  • Neo4j → relationship update

Order Flow


API Screenshots

Login (Redis)

Login API


User (PostgreSQL)

User API


Products (MongoDB)

Products API


Activity (Cassandra)

Activity API


Full API Documentation

APIs


Full Documentation

Explore complete API flows, screenshots, and explanations:

🔗 Documentation

Deep Dive Blog Series

This project was built in phases — each database explored in depth:

  1. 🔗 https://satyam-dev-7.vercel.app/blog/why-i-built-one-app-with-six-databases
  2. 🔗 https://satyam-dev-7.vercel.app/blog/postgresql-indexes-deep-dive-polyglotdb-phase-1
  3. 🔗 https://satyam-dev-7.vercel.app/blog/acid-transactions-postgresql-polyglotdb-phase-1
  4. 🔗 https://satyam-dev-7.vercel.app/blog/redis-is-not-a-database-its-a-decision
  5. 🔗 https://satyam-dev-7.vercel.app/blog/why-mongodb-exists-and-when-its-the-wrong-choice
  6. 🔗 https://satyam-dev-7.vercel.app/blog/cassandra-thinking-in-queries-not-tables-polyglotdb

Running Locally

docker compose up -d
node src/index.js

About

Multi-database backend architecture showcasing real-world system design using PostgreSQL, MongoDB, Redis, Cassandra, and Neo4j.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors