Implement complete database router with PostgreSQL, pgvector, MinIO, and hybrid RAG support #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements a complete Python-based database router that provides a standardized REST API for accessing structured data, vector embeddings, and object storage. The router supports seamless switching between self-hosted and cloud infrastructure through configuration-based adapters.
Implementation
Core Architecture
Built a FastAPI application with a layered architecture:
Key Features
Hybrid RAG Search
Database Adapters
Storage Adapters
Vector Embeddings
Docker Deployment
Multi-container setup with docker-compose:
database-router- FastAPI application (port 8000)postgres- PostgreSQL with pgvector extension (port 5432)minio- S3-compatible object storage (ports 9000, 9001)Supports horizontal scaling via Docker replicas for high availability.
API Endpoints
Documents (7 endpoints):
POST /documents/- Create document with auto-embeddingGET /documents/{id}- Retrieve document by IDPUT /documents/{id}- Update document and regenerate embeddingDELETE /documents/{id}- Delete documentGET /documents/- List documents with paginationPOST /documents/search/vector- Vector similarity searchPOST /documents/search/hybrid- Hybrid RAG searchObjects (5 endpoints):
POST /objects/upload- Upload file to storageGET /objects/download/{name}- Download file from storageDELETE /objects/{name}- Delete fileGET /objects/- List all objectsGET /objects/metadata/{name}- Get object metadataHealth (1 endpoint):
GET /health- System health check for database and storageConfiguration Switching
The adapter pattern allows switching between self-hosted and cloud infrastructure without code changes:
Self-Hosted (default):
Cloud:
Documentation
Comprehensive documentation included:
Quick Start
git clone https://github.com/SoftwareDevLabs/Database.git cd Database ./setup.shAccess API documentation at http://localhost:8000/docs
Technology Stack
Integration
Frontend and backend services (in separate repositories) can integrate via standardized REST API:
Validation
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.