database-studio
v1.0.8
Published
[](./package.json) [](#license) [
MONGODB_URL=mongodb://user:password@localhost:27017/your_database
MONGODB_URI=mongodb+srv://user:[email protected]/your_databaseOptional:
PORT=5555 # defaults to 5555Database Studio auto-detects which database to connect to based on the env variable present. If neither is set, it starts in setup mode showing configuration docs in the browser.
💻 Tech Stack
- Frontend: React 18, React Router 6, Tailwind CSS 3
- Backend: Express 5, Puppeteer
- UI Components: Radix UI, Lucide Icons
- Databases: MySQL via mysql2, MongoDB via native driver
- Build: Vite, tsup
🏗️ Architecture
client/ # React SPA
├── components/ # UI & feature components
├── pages/ # Route-level views
└── lib/ # Utilities and API wrappers
server/ # Express API
├── index.ts # Routes, license, PDF export
├── config/ # Server configuration
└── drivers/ # Database driver abstraction
├── types.ts # DbDriver interface
├── mysql.ts # MySQL implementation
├── mongodb.ts # MongoDB implementation
└── index.ts # Auto-detection factory
bin/ # CLI entry pointDriver Pattern
All database operations go through a DbDriver interface. The server auto-detects which driver to use based on environment variables — zero conditionals in route handlers.
| Method | MySQL | MongoDB |
|--------|-------|---------|
| getDatabaseName() | SELECT DATABASE() | db.databaseName |
| getTables() | SHOW TABLES | db.listCollections() |
| getTableSchema() | SHOW COLUMNS + FK query | Sample 100 docs, infer types |
| getTableData() | SELECT * LIMIT OFFSET | find().skip().limit() |
📑 PDF Export Engine
- Headless Navigation: Puppeteer visits
?view=schema&export=true - Adaptive CSS: Print-specific layout with hidden interactive elements
- Full Fidelity: Captures Tailwind styles into multi-page A4 PDF
🔒 License & Security
Requires a license key on first use. The licensing system uses RSA-256 signatures and Machine-ID hashing.
Part of the Database Studio Workspace.
