A full-stack prototype for database browsing, querying, and editing via a browser.
This repository defines the specification for a minimal, full-stack Web UI for SQLite database management, designed to be implemented end-to-end by an AI coding assistant (e.g., OpenAI Codex) using vibecoding workflows.
The goal is to let the AI coder scaffold and implement the project from zero, based solely on this README.
-
A browser-based UI to:
- Run SQL queries
- Display results in a table
- View tables & columns
- Insert / Update / Delete rows (basic CRUD)
-
A backend API that wraps SQLite through FastAPI:
- Connect to a local SQLite database file
- Execute safe SQL commands
- Provide table-metadata endpoints
- Return query results as JSON
-
A React-based frontend (JavaScript only):
- Query input editor
- Clickable table/column list
- Data grid result display
- Error display
-
A minimal, clean architecture to support simple extensions.
Codex / AI coder should generate code to match this structure:
/backend
βββ main.py # FastAPI entry
βββ db.py # SQLite connection + operations
βββ models.py # Pydantic models (if needed)
βββ requirements.txt # FastAPI, uvicorn, sqlite libs
/frontend
βββ public/
βββ src/
β βββ App.js # Main React UI
β βββ components/
β β βββ QueryEditor.js
β β βββ ResultTable.js
β β βββ SidebarTables.js
β βββ api.js # Fetch helpers for backend
βββ package.json
βββ README.md (auto-generated)
/data
βββ app.db # Default SQLite DB (AI coder creates example schema)
/README.md # This file
-
Built with Create React App (or Vite, but JavaScript only).
-
Components:
- Query editor (
textareaor CodeMirror) - Execute button
- Result table with pagination (optional)
- Sidebar listing tables from backend metadata
- Query editor (
-
Communicates using JSON APIs only.
API endpoints expected:
| Method | Path | Description |
|---|---|---|
GET |
/tables |
List all tables |
GET |
/tables/{table}/schema |
Return table schema |
POST |
/query |
Execute SQL (SELECT/INSERT/UPDATE/DELETE) |
GET |
/health |
Health check |
Requirements:
- Use sqlite3 module (standard library)
- Prevent dangerous operations (optional)
- Always return
{ "success": true/false, "data": ..., "error": ... }
AI coder should follow this pipeline to generate the full implementation:
- Validate goals in this README
- List minimal features before coding
- Create Conda/virtualenv environment for backend
- Install backend dependencies (
fastapi,uvicorn) - Create React app for frontend (
npx create-react-app frontend)
- Implement a FastAPI server
- Add SQLite wrapper
- Add /query and /tables endpoints
- Implement CORS
- Provide example database in
/data/app.db
-
Scaffold React project
-
Add API layer (
api.js) -
Implement UI components:
- Query editor
- Result table
- Sidebar for table list
-
Connect to backend
- Manual local testing in Chrome or Firefox
- Sample SQL queries
- Validate errors return cleanly
- Document startup steps
- Ensure cross-origin access works
- Provide final run instructions
These should be executable through the Web UI:
SELECT name FROM sqlite_master WHERE type='table';
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
email TEXT
);
INSERT INTO users (name, email) VALUES ('Alice', 'a@example.com');
SELECT * FROM users;After AI coder generates the code, the run procedure should be:
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8100cd frontend
npm install
PORT=3100 npm startToεε° 3000/8000 ηεΈΈη¨η«―ε£θ’«ε η¨ηζ
ε΅οΌζ¨θεη«―θΏθ‘ε¨η«―ε£ 3100οΌεΉΆθ°η¨εη«― http://localhost:8100γ
π°οΈ Remote/Cloud IDE tip: When exposing the frontend via a shared URL, override the API host by either setting
REACT_APP_API_BASE_URLbeforenpm startor appending?apiBase=<encoded backend url>to the browser URL (e.g.?apiBase=https%3A%2F%2F8100-yourworkspace.example.dev). This prevents the browser from trying to reachlocalhost:8100on your local machine.
- Export query results as CSV
- Basic authentication
- Save βquery historyβ
- Dark mode UI
- Visualization charts
MIT (or add your own license).
- Use JavaScript only in the frontend.
- Keep the code base minimal and clean.
- Write clear comments in all generated files.
- Ensure SQLite file path is configurable.
- The goal is to deliver a working prototype, not a polished product.
This repo now contains a working FastAPI + React prototype that follows all requirements outlined above.
- FastAPI app with
/health,/tables,/tables/{table}/schema, and/queryroutes. backend/db.pycentralizes SQLite access and exposes helpers for listing tables, inspecting schemas, and executing single-statement SQL safely.- Database file
data/app.dbships withusers,products, andorderstables plus seed data to explore immediately. - Responses consistently follow
{ success, data, error }, making it easy for the UI to show helpful messages.
- React app (Create React App layout) in
frontend/with components for sidebar metadata, SQL editor, and tabular results. - Reusable API client in
src/api.jsthat respectsREACT_APP_API_BASE_URL. - Responsive UI with contextual errors, schema preview, seed query templates, and success states for both read and write queries.
- Copy
frontend/.env.exampletofrontend/.envto point the UI at a different backend or port if needed.
Follow the βHow to Runβ section above. The defaults assume:
# Backend
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8100
# Frontend
cd frontend
cp .env.example .env # optional but recommended
npm install
npm start # loads PORT=3100 from .envOpen http://localhost:3100 after both servers start.
- Exercised the SQLite helper directly (see
backend/db.py) to confirm table listing, schema inspection, and select queries. - Attempted to run
npm installfor the frontend, but the command repeatedly timed out because external network access is restricted in this environment. Once dependencies are installed in an online environment,npm startandnpm testwill function as usual.
With the backend verified against the bundled database and the frontend wired to the published API contract, the prototype is ready for further manual testing in a browser.