Skip to content

About

Full stack database design and querying platform that enables visual schema modeling, NL-to-SQL generation, and real time PostgreSQL management.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

360 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SchemaSense

Intelligent Database Design & Querying Platform Natural language to SQL conversion, interactive schema visualization, and real-time database management.

Live Demo React FastAPI PostgreSQL Deployed


๐ŸŽฏ Overview

SchemaSense is a full-stack database design and query platform that combines natural language processing, interactive visual editing, and real time PostgreSQL management. Users can design database schemas visually, generate SQL from plain English questions, and interact with managed databases - all without leaving the browser.

๐ŸŒ Live Demo: https://schema-sense.com


โœจ Key Features

๐Ÿค– Natural Language to SQL

  • AI-Powered Query Generation: Convert plain English questions into optimized SQL queries using OpenAI GPT-4
  • Context-Aware: Automatically analyzes your database schema to generate accurate, schema-specific queries
  • Query Validation: Real-time syntax checking and safety validation before execution

๐Ÿ“Š Interactive ER Diagram Editor

  • Visual Schema Design: Drag-and-drop interface for creating tables, columns, and relationships
  • Live DDL Generation: Automatically generates PostgreSQL DDL as you design
  • Bi-Directional Editing: Edit via visual diagram OR raw DDLโ€”changes sync in real-time
  • Relationship Management: Visual foreign key creation with automatic constraint generation

๐Ÿ—„๏ธ Managed Database Provisioning

  • One-Click Databases: Provision isolated PostgreSQL databases instantly (powered by Neon)
  • Session Isolation: Each user gets their own isolated database environment with secure credential management
  • Sample Data: Optional pre-populated sales database for testing and demos
  • Automatic Cleanup: TTL-based lifecycle management to reclaim unused resources

๐Ÿ“ˆ Query Execution & Analysis

  • Visual Query Results: Interactive table views with sortable columns
  • Execution Plans: EXPLAIN ANALYZE visualization for query optimization
  • Query History: Persistent history with search and replay functionality
  • Performance Metrics: Execution time tracking and performance insights

๐ŸŽจ Modern User Experience

  • Dark/Light Mode: System-aware theme with manual toggle
  • Responsive Design: Works seamlessly on desktop and tablet
  • Real-Time Updates: Live schema synchronization across all panels
  • Undo/Redo: Full history stack for schema modifications

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         Frontend (React)                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”‚
โ”‚  โ”‚ Query Builderโ”‚  โ”‚ ER Diagram   โ”‚  โ”‚ Schema Explorer    โ”‚     โ”‚
โ”‚  โ”‚   Panel      โ”‚  โ”‚   Editor     โ”‚  โ”‚     Panel          โ”‚     โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚
โ”‚           โ–ฒ                 โ–ฒ                  โ–ฒ                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚                 โ”‚                  โ”‚
            โ”‚  HTTPS + CORS + Session Cookies    โ”‚
            โ”‚                 โ”‚                  โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Backend API (FastAPI)                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”‚
โ”‚  โ”‚  NL-to-SQL   โ”‚  โ”‚ Schema Mgmt  โ”‚  โ”‚  DB Provisioning   โ”‚      โ”‚
โ”‚  โ”‚  (OpenAI)    โ”‚  โ”‚   Engine     โ”‚  โ”‚      Engine        โ”‚      โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ”‚
โ”‚           โ”‚                 โ”‚                  โ”‚                 โ”‚
โ”‚           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                 โ”‚
โ”‚                             โ”‚                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ”‚   PostgreSQL Cluster        โ”‚
                โ”‚   (Neon Serverless)         โ”‚
                โ”‚                             โ”‚
                โ”‚  โ€ข Admin Database           โ”‚
                โ”‚  โ€ข User Database Pool       โ”‚
                โ”‚  โ€ข Session Tracking         โ”‚
                โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Frontend

  • Framework: React 18 with Vite
  • Routing: React Router v6
  • State Management: React Context + Hooks
  • Visualization: ReactFlow for ER diagrams
  • Styling: TailwindCSS + shadcn/ui components
  • Deployment: Vercel (CDN + Edge Network)

Backend

  • Framework: FastAPI (Python 3.11+)
  • Database Driver: psycopg2 (PostgreSQL adapter)
  • AI Integration: OpenAI GPT-4 API
  • Session Management: Signed cookies with itsdangerous
  • Security: CORS, rate limiting, SQL injection prevention
  • Deployment: Render (managed containers)

Database

  • Platform: Neon Serverless PostgreSQL
  • Features: Auto-scaling, branching, connection pooling
  • Security: SSL/TLS, isolated credentials per session

Infrastructure

  • Domain: Custom domain with subdomain architecture
  • SSL: Automatic TLS certificates (Vercel + Render)
  • Session: Cookie-based with cross-subdomain support
  • Monitoring: Render metrics + custom logging

๐Ÿ” Security & Architecture Highlights

Session Isolation

Each user session gets:

  • Unique session ID: Cryptographically signed cookies
  • Isolated database credentials: Dedicated PostgreSQL role per session
  • No cross-contamination: Sessions cannot access each other's data

Production-Grade Security

  • HTTPS Everywhere: TLS 1.3 on all connections
  • CORS Protection: Strict origin validation
  • Rate Limiting: 50 requests/hour for database provisioning
  • SQL Injection Prevention: Parameterized queries only
  • Secure Cookies: HttpOnly, Secure, SameSite=Lax
  • Safari ITP Compatible: Custom domain architecture for cross-browser support

Resource Management

  • TTL Cleanup: Automatic deletion of databases after 14 days of inactivity
  • Connection Pooling: Efficient database connection management
  • Query Timeouts: 15-second statement timeout to prevent runaway queries
  • Quota Limits: 5 databases per session, 100 global maximum

๐Ÿš€ Quick Start

Option 1: Use the Live Demo

Visit https://schema-sense.com and click "Provision Database with Sample Data" to get started instantly.

Option 2: Use Personal Database

Visit https://schema-sense.com and connect your own personal PostgreSQL database and begin editing instantly.


๐Ÿ“‹ Usage Examples

Natural Language Queries

User Input:
  "Show me the top 5 customers by total revenue"

Generated SQL:
  SELECT
    c.customer_id,
    c.name,
    SUM(o.total_amount) as total_revenue
  FROM customers c
  JOIN orders o ON c.customer_id = o.customer_id
  GROUP BY c.customer_id, c.name
  ORDER BY total_revenue DESC
  LIMIT 5;

Visual Schema Design

  1. Add Table: Click "Add Table" โ†’ Enter table name
  2. Add Columns: Define column names, types, and constraints
  3. Create Relationships: Drag from foreign key column to primary key
  4. Generate DDL: Switch to DDL view to see generated SQL
  5. Apply to Database: Click "Apply Changes" to execute DDL

DDL Editing

-- Edit raw SQL in the DDL editor
CREATE TABLE products (
  product_id SERIAL PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  price DECIMAL(10, 2) NOT NULL,
  category_id INTEGER REFERENCES categories(category_id)
);

-- Changes automatically reflected in ER diagram

๐Ÿ† Technical Achievements

Cross-Browser Cookie Compatibility

  • Implemented custom domain architecture (schema-sense.com + api.schema-sense.com) to solve Safari's Intelligent Tracking Prevention (ITP)
  • Proper SameSite cookie configuration for same-site subdomain sharing
  • Session persistence across all major browsers (Chrome, Safari, Firefox, Edge)

Real-Time Schema Synchronization

  • Bi-directional editing between visual diagram and raw DDL
  • Conflict-free merging of concurrent schema changes
  • Undo/redo stack with 10-level history

Scalable Database Provisioning

  • Dynamic database creation with unique credentials per session
  • Automatic PostgreSQL role creation with secure password generation
  • Connection pooling and lifecycle management

AI Integration

  • GPT-4 integration with schema-aware prompt engineering
  • Context injection for accurate query generation
  • Fallback handling and error recovery

๐Ÿš€ Deployment

Production Setup:

  • Frontend: Vercel (automatic deployments from main branch)
  • Backend: Render (automatic deployments from main branch)
  • Database: Neon Serverless PostgreSQL (auto-scaling)

๐Ÿ“Š Performance

  • Query Execution: < 100ms for most queries (excluding complex aggregations)
  • Schema Rendering: < 200ms for diagrams with 50+ tables
  • Database Provisioning: ~3-5 seconds (includes role creation + sample data)
  • API Response Time: P95 < 300ms
  • Frontend Load Time: < 2 seconds (cached assets)

๐Ÿ™ Acknowledgments

  • OpenAI GPT-4 for natural language processing
  • Neon for serverless PostgreSQL infrastructure
  • Vercel for frontend hosting and edge network
  • Render for backend container orchestration
  • ReactFlow for ER diagram visualization

๐Ÿ”ฎ Future Enhancements

  • Multi-database support (MySQL, SQLite, MongoDB)
  • Collaborative editing (real-time multiplayer)
  • Export to ORM models (SQLAlchemy, Prisma, TypeORM)
  • Query optimization suggestions
  • Database migration history
  • Role-based access control (RBAC)
  • Jupyter notebook integration

Built with โค๏ธ using React, FastAPI, and PostgreSQL

Live Demo

About

Full stack database design and querying platform that enables visual schema modeling, NL-to-SQL generation, and real time PostgreSQL management.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages