Skip to content

Latest commit

 

History

History
74 lines (62 loc) · 4.48 KB

File metadata and controls

74 lines (62 loc) · 4.48 KB

Vortex

Vortex is an application that generates endpoints to receive HTTP requests.

Instructions

Clone this repository and change directory to its root:

git clone https://github.com/JoeCardoso13/Vortex.git && cd Vortex

Then follow instructions in the README.md files from the server/ and client/ folders respectively.

Architecture

Vortex uses a hybrid PostgreSQL + MongoDB database system where PostgreSQL manages relational structure and MongoDB stores flexible request data.

                ┌─────────────────────────────────────────────────────────────┐
                │                      Incoming Request                       │
                └────────────────────────┬────────────────────────────────────┘
                                         │
                                         ▼
                              ┌──────────────────────┐
                              │  DatabaseService     │
                              │   write_req()        │
                              └─────────┬────────────┘
                                        │
                          ┌─────────────┴─────────────┐
                          │                           │
                          ▼                           ▼
                ┌──────────────────┐        ┌──────────────────┐
                │    MongoDB       │        │   PostgreSQL     │
                │                  │        │                  │
                │  Requests        │◄───────│  Requests        │
                │  Collection      │   ref  │  Table           │
                │                  │        │                  │
                │  {               │        │  ┌─────────────┐ │
                │    headers: {},  │        │  │ bin_id      │ │
                │    body: {},     │        │  │ mongodb_    │ │
                │    method: "GET",│        │  │   doc_id ───┼─┼──┐
                │    ...           │        │  └─────────────┘ │  │
                │  }               │        │                  │  │
                │                  │        │  Bins Table      │  │
                │  ObjectId:       │        │  ┌─────────────┐ │  │
                │  507f1f77bcf...  │◄───────┼──│ id          │ │  │
                │                  │        │  │ path        │ │  │
                └──────────────────┘        │  └─────────────┘ │  │
                                            └──────────────────┘  │
                                                                  │
                                            Stores as VARCHAR(24) │
                                            string reference ─────┘

How It Works

When writing a request:

  1. Full request payload (headers, body, method, etc.) is inserted into MongoDB's Requests collection
  2. MongoDB returns an ObjectId for the document
  3. A record is created in PostgreSQL's Requests table with:
    • bin_id (foreign key to the Bins table)
    • mongodb_doc_id (the MongoDB ObjectId stored as a VARCHAR(24) string)

When reading requests:

  1. PostgreSQL is queried to retrieve all mongodb_doc_id values for a specific bin
  2. Those string IDs are converted back to MongoDB ObjectIds
  3. All actual request documents are fetched from MongoDB in a single batch query

Why This Design?

This architecture provides:

  • PostgreSQL: Handles relational integrity (bins → requests relationship), efficient filtering, and joins
  • MongoDB: Stores flexible, schema-less request payloads that can vary in structure
  • Bridge: The mongodb_doc_id column in PostgreSQL connects both databases seamlessly