A full-stack relational database management system built from scratch with a modern web interface. This project demonstrates a complete implementation of database internals including SQL parsing, indexing, CRUD operations, and persistence.
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: Custom RDBMS (in-memory with file persistence)
- Framework: Next.js (App Router)
- Language: TypeScript
- UI Library: Mantine UI
- State Management: Zustand
- Monorepo: Turborepo with pnpm
- Containerization: Docker & Docker Compose
- Package Manager: pnpm
git clone <repository-url>
cd myrdbms#install turbo globally
npm install turbo --global
# Install pnpm globally (if not already installed)
npm install -g pnpm
# Install all dependencies
pnpm installNODE_ENV=development
PORT=3001
HOST_NAME=0.0.0.0
DATA_PATH=./dataNEXT_PUBLIC_API_URL=http://localhost:3001/api/v1# Start both frontend and backend in development mode
pnpm run devThis will start:
- API Server: http://localhost:3001
- Web Client: http://localhost:3000
Terminal 1 (Backend):
cd apps/api
pnpm run devTerminal 2 (Frontend):
cd apps/web
pnpm run dev# Build images and start containers
docker-compose up --build
# Run in detached mode
docker-compose up -d --build
# View logs
docker-compose logs -f
# Stop containers
docker-compose down
# Stop and remove volumes
docker-compose down -vVolumes:
api_data- Persists database files from/app/data
Access URLs (Docker):
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001/api/v1
Access the database via command-line interface:
# From project root
pnpm run mydb
# Output
╔═══════════════════════════════════════════════════════════════╗
║ MyRDBMS - Interactive Database Shell ║
║ Functional Relational Database System ║
╚═══════════════════════════════════════════════════════════════╝
Type 'help' for available commands or 'exit' to quit
mydb>
## Postman Collection
Import the provided Postman collection for testing:
1. Open Postman
2. Click **Import**
3. Paste the collection JSON (provided in ./docs folder in the repo)
4. Set variable `API_URL` to `http://localhost:3001/api/v1`
## Testing the System
### 1. Quick Test via REPL
```bash
pnpm run mydb
# In REPL
mydb> CREATE DATABASE testdb
mydb> USE testdb
testdb> CREATE TABLE products (id INTEGER PRIMARY KEY, name VARCHAR(100), price FLOAT)
testdb> INSERT INTO products (name, price) VALUES ('Laptop', 999.99)
testdb> SELECT * FROM products
- Navigate to http://localhost:3000
- Create database "testdb"
- Create table "products"
- Use Query Console to insert/query data
# Create database
curl -X POST http://localhost:3001/api/v1/databases \
-H "Content-Type: application/json" \
-d '{"name":"testdb"}'
# Create table
curl -X POST http://localhost:3001/api/v1/tables \
-H "Content-Type: application/json" \
-d '{
"name": "products",
"columns": [
{"name": "id", "type": "INTEGER", "primaryKey": true},
{"name": "name", "type": "VARCHAR", "maxLength": 100},
{"name": "price", "type": "FLOAT"}
]
}'
# Execute query
curl -X POST http://localhost:3001/api/v1/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM products"}'- Ensure backend is running on port 3001
- Check
.env.localhas correct API URL - Verify CORS settings in backend
- Check browser console for errors
- In-memory storage with file persistence
- Multiple databases support
- CREATE, DROP, USE database commands
- Automatic persistence on modifications
- CREATE TABLE with constraints
- DROP TABLE
- DESCRIBE table schema
- Support for PRIMARY KEY, UNIQUE constraints
- Data types: INTEGER, VARCHAR, BOOLEAN, FLOAT
- SELECT with WHERE clause
- INSERT INTO
- UPDATE with WHERE
- DELETE with WHERE
- INNER JOIN
- CREATE INDEX
- In-memory: Fast read/write operations
- Indexing: O(1) lookups for indexed columns
- Auto-save: Async file writes don't block operations
- Functional Core: Pure functions, easy to optimize
- Middleware: Lightweight request processing
- Validation: Early request validation with Zod
- Next.js: Optimized React rendering
- Zustand: Minimal state management overhead
- Mantine: Tree-shakeable component library
{
"success": true,
"statusCode": 200
"message": "Operation successful",
"data": { },
}{
"success": false,
"statusCode": 400
"message": "Error message",
}- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
MIT License - Feel free to use this project for learning and development.
For issues and questions:
- Check the troubleshooting section
- Review API documentation
- Check Docker logs
- Open an issue on GitHub
Built by Gerald with as a demonstration of database internals and full-stack development