Database schema explorer with ER diagram visualization and health metrics.
DB Insight Visualizer is a web-based tool for exploring and analyzing database schemas. It provides interactive ER (Entity-Relationship) diagram visualization, detailed table and column metadata inspection, and comprehensive health scoring to help DBAs and developers understand and improve their database designs.
- Automatic discovery of all tables, columns, types, primary keys, foreign keys, and indexes
- Support for SQLite databases (extensible to other databases)
- Full metadata extraction with row counts and column positions
- Interactive Entity-Relationship diagrams drawn on HTML5 Canvas
- Table boxes showing column names, types, PK/FK indicators
- Bezier curve arrows connecting related tables
- Cardinality indicators (1:N) on relationship lines
- Color-coded columns: blue for PKs, purple for FKs, green for indexed
- Zoom in/out controls for large schemas
Comprehensive schema health analysis with six key metrics:
| Metric | Description | Weight |
|---|---|---|
| PK Coverage | Percentage of tables with primary keys | 20% |
| FK Density | Average FK relationships per table | 15% |
| Nullable Ratio | Percentage of non-nullable columns (lower is healthier) | 15% |
| Index Coverage | Percentage of FK columns that are indexed | 20% |
| Naming Convention | Consistency of snake_case/camelCase naming | 15% |
| Type Consistency | Same column name uses same type across tables | 15% |
- Overall health score with visual gauge
- Radar chart showing all six health dimensions
- Table count, relationship count, column count statistics
- Recent scan history with timestamps
- Actionable recommendations for schema improvement
- Register multiple database profiles
- Trigger on-demand schema scans
- View scan history with comparison over time
- Built-in sample e-commerce database for demo
| Component | Technology |
|---|---|
| Backend | Python 3.10+ / FastAPI |
| Frontend | Vanilla JavaScript SPA |
| Database | SQLite (metadata store) |
| Visualization | HTML5 Canvas |
| Testing | pytest + httpx |
| Deployment | Docker / Docker Compose |
- Python 3.10 or higher
- SQLite3 (usually pre-installed)
# Clone the repository
git clone https://github.com/ravikishan/db-insight-visualizer.git
cd db-insight-visualizer
# Run the start script
chmod +x start.sh
./start.sh# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create sample database
mkdir -p seed_data instance
sqlite3 seed_data/sample.db < seed_data/sample_db.sql
# Start the server
uvicorn app:app --host 0.0.0.0 --port 8025 --reloaddocker-compose up --buildThe application will be available at http://localhost:8025.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/databases |
List all database profiles |
| POST | /api/databases |
Register a new database profile |
| GET | /api/databases/{id} |
Get a specific database profile |
| DELETE | /api/databases/{id} |
Delete a database profile |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/databases/{id}/scan |
Trigger a schema scan |
| GET | /api/databases/{id}/tables |
Get table metadata from latest scan |
| GET | /api/databases/{id}/relationships |
Get FK relationships from latest scan |
| GET | /api/databases/{id}/health |
Get health metrics from latest scan |
| GET | /api/databases/{id}/scans |
Get scan history |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/health |
Application health check |
| Hash Route | View | Description |
|---|---|---|
#/ |
Dashboard | Health gauges, stats, radar chart |
#/databases |
Database List | Manage database profiles |
#/schema/:id |
ER Diagram | Interactive schema visualization |
#/table/:id/:name |
Table Detail | Column list with metadata |
#/health/:id |
Health Report | Detailed health metrics and recommendations |
The included sample database models a typical e-commerce system with 8 tables:
users - User accounts
categories - Product categories (self-referencing)
products - Product catalog
addresses - User shipping addresses
orders - Customer orders
order_items - Line items in orders
reviews - Product reviews
payments - Payment records
All tables have proper primary keys, foreign keys, and indexes to demonstrate a well-structured relational database schema.
db-insight-visualizer/
|-- app.py # FastAPI application entry point
|-- config.py # Application configuration
|-- requirements.txt # Python dependencies
|-- Dockerfile # Container image definition
|-- docker-compose.yml # Container orchestration
|-- start.sh # Quick start script
|-- models/
| |-- __init__.py # Model exports
| |-- database.py # SQLAlchemy engine and session
| |-- schemas.py # ORM models (DatabaseProfile, TableMeta, etc.)
|-- routes/
| |-- __init__.py # Route package
| |-- api.py # REST API endpoints
| |-- views.py # SPA page serving
|-- services/
| |-- __init__.py # Service exports
| |-- introspector.py # Schema introspection engine
| |-- health_scorer.py # Health scoring calculations
|-- frontend/
| |-- index.html # SPA entry page
| |-- static/
| |-- css/app.css # Application styles
| |-- js/app.js # SPA JavaScript application
|-- tests/
| |-- conftest.py # Test fixtures
| |-- test_api.py # API endpoint tests
| |-- test_models.py # Model tests
| |-- test_services.py # Service logic tests
|-- seed_data/
| |-- sample_db.sql # Sample database schema and data
|-- .github/
| |-- workflows/
| |-- ci.yml # CI pipeline
| Score Range | Grade | Description |
|---|---|---|
| 80-100 | Excellent | Schema follows best practices |
| 60-79 | Good | Minor improvements recommended |
| 40-59 | Fair | Several areas need attention |
| 0-39 | Poor | Significant schema issues detected |
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=. --cov-report=term-missing
# Run specific test file
pytest tests/test_services.py -v- Extend
SchemaIntrospectorwith a new connection method - Implement the same interface (get_tables, get_columns, get_foreign_keys, etc.)
- Add the database type to
config.py
- Add the scoring method to
HealthScorer - Update
full_report()to include the new metric - Update the weight configuration in
config.py - Update the frontend radar chart labels
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - Modern Python web framework
- SQLAlchemy - Python SQL toolkit
- SQLite - Embedded relational database
Built with care for database administrators and developers who want to understand and improve their database schemas.