-
Notifications
You must be signed in to change notification settings - Fork 2
File Structure
Project organization and key files in D1 Database Manager.
D1 Manager follows a modular structure separating frontend (React) and backend (Cloudflare Worker) code with clear organization.
d1-manager/
βββ src/ # Frontend source code
βββ worker/ # Backend source code
βββ public/ # Static assets
βββ dist/ # Build output (git-ignored)
βββ node_modules/ # Dependencies (git-ignored)
βββ .github/ # GitHub Actions workflows
βββ package.json # Project dependencies
βββ package-lock.json # Locked dependencies
βββ tsconfig.json # TypeScript root config
βββ tsconfig.app.json # Frontend TS config
βββ tsconfig.node.json # Node.js TS config
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind CSS config
βββ postcss.config.js # PostCSS configuration
βββ components.json # shadcn/ui config
βββ wrangler.toml # Worker production config
βββ wrangler.dev.toml # Development config
βββ .env.example # Environment template
βββ .gitignore # Git ignore rules
βββ README.md # Project documentation
βββ LICENSE # MIT license
βββ SECURITY.md # Security policy
βββ CONTRIBUTING.md # Contribution guide
βββ CODE_OF_CONDUCT.md # Community standards
βββ DOCKER_README.md # Docker deployment guide
βββ VERSION # Version number (1.1.1)
src/
βββ components/ # React components
β βββ ui/ # shadcn/ui base components
β β βββ button.tsx
β β βββ card.tsx
β β βββ dialog.tsx
β β βββ input.tsx
β β βββ label.tsx
β β βββ select.tsx
β β βββ checkbox.tsx
β β βββ accordion.tsx
β β βββ progress.tsx
β β βββ ...
β βββ DatabaseView.tsx # Database table list
β βββ TableView.tsx # Table data browser
β βββ QueryConsole.tsx # SQL query executor
β βββ SchemaDesigner.tsx # Visual table creator
β βββ FilterBar.tsx # Row-level filtering
β βββ ThemeToggle.tsx # Theme switcher
β βββ Header.tsx # App header
β βββ DatabaseComparison.tsx
β βββ CrossDatabaseSearch.tsx
β βββ MigrationWizard.tsx
β βββ CascadeImpactSimulator.tsx
β βββ TimeTravelInfo.tsx # Time Travel tab
β βββ ...
βββ contexts/ # React contexts
β βββ ThemeContext.tsx # Theme state management
βββ hooks/ # Custom hooks
β βββ useTheme.ts # Theme hook
βββ services/ # External services
β βββ api.ts # API client
β βββ auth.ts # Authentication helpers
βββ lib/ # Shared libraries
β βββ utils.ts # Utility functions
βββ App.tsx # Main app component
βββ main.tsx # React entry point
βββ index.css # Global styles + Tailwind
App.tsx - Main application:
- Routing logic
- Database list view
- State management
- View switching
main.tsx - Entry point:
- React initialization
- DOM rendering
- Theme provider
index.css - Global styles:
- Tailwind imports
- CSS variables for theming
- Global styles
services/api.ts - API client:
- Centralized API calls
- Type-safe methods
- Error handling
contexts/ThemeContext.tsx - Theme management:
- Light/Dark/System modes
- LocalStorage persistence
- CSS class manipulation
worker/
βββ routes/ # API route handlers
β βββ databases.ts # Database operations
β βββ tables.ts # Table operations
β βββ queries.ts # Query execution
β βββ saved-queries.ts # Saved queries
β βββ undo.ts # Undo/rollback operations
β βββ jobs.ts # Job history and events
β βββ time-travel.ts # Time Travel bookmarks
βββ utils/ # Utility functions
β βββ auth.ts # JWT validation
β βββ cors.ts # CORS headers
β βββ helpers.ts # Helper functions
β βββ database-tracking.ts # DB access tracking
β βββ undo.ts # Undo/rollback helpers
β βββ time-travel.ts # Time Travel helpers
βββ types/ # TypeScript types
β βββ index.ts # Type definitions
βββ index.ts # Worker entry point
βββ schema.sql # Metadata DB schema
index.ts - Worker entry:
- Request handling
- Route dispatching
- Error handling
- Localhost detection
routes/databases.ts - Database CRUD:
- List databases
- Create database
- Delete database
- Rename database
- Bulk operations
routes/tables.ts - Table operations:
- List tables
- Get schema/data
- Create/rename/delete
- Column management
- Dependencies
routes/queries.ts - Query execution:
- Execute SQL
- Batch queries
- Query history
- Validation
utils/auth.ts - Authentication:
- JWT validation
- Cloudflare Access integration
utils/cors.ts - CORS management:
- Allowed origins
- CORS headers
schema.sql - Metadata database:
- Query history table
- Saved queries table
- Database tracking
Purpose: Project metadata and dependencies
Key sections:
-
name: "d1-manager" -
version: "1.1.1" -
scripts: Build and dev commands -
dependencies: Runtime dependencies -
devDependencies: Development tools
Purpose: TypeScript root configuration
Settings:
- Strict mode enabled
- ES2020 target
- Module resolution: bundler
- Path aliases:
@/*βsrc/*
Purpose: Frontend TypeScript config
Includes:
-
src/directory - Vite types
- React types
Purpose: Node.js tooling TypeScript config
Includes:
vite.config.ts- Build scripts
Purpose: Vite build configuration
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
server: {
port: 5173
}
});Purpose: Tailwind CSS configuration
Settings:
- Content paths
- Theme customization
- Dark mode: 'class'
- Plugin: tailwindcss-animate
Purpose: shadcn/ui configuration
Settings:
- Style: default
- Base color: slate
- CSS variables: true
- TypeScript: true
- Alias:
@/components
Purpose: Worker production configuration
Sections:
- Worker name
- Main entry point
- D1 bindings
- Routes (optional)
- Assets binding
Purpose: Local development configuration
Settings:
- Development worker name
- Local mode enabled
- Mock D1 binding
- Port: 8787
Purpose: Environment variable template
# Worker API URL (local development)
VITE_WORKER_API=http://localhost:8787Git-ignored - Generated by npm run build
dist/
βββ assets/ # Bundled JS/CSS
β βββ index-[hash].js
β βββ index-[hash].css
β βββ ...
βββ index.html # Entry HTML
βββ ...
Purpose: Main project documentation
Sections:
- Features
- Quick start
- Installation
- Configuration
- Deployment
- API reference
Purpose: Security policy
Sections:
- Supported versions
- Reporting vulnerabilities
- Security best practices
- Known considerations
Purpose: Contribution guidelines
Sections:
- Development setup
- Coding standards
- Testing
- Pull request process
Purpose: MIT License text
Purpose: Community guidelines
Purpose: Docker deployment instructions
Purpose: Single source of truth for version number
Contents: 1.1.1
Ignores:
# Dependencies
node_modules/
# Build output
dist/
.wrangler/
# Environment
.env
wrangler.toml
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
GitHub-specific files:
- Workflows (CI/CD)
- Issue templates
- Pull request templates
- FUNDING.yml
Purpose: Linting configuration
Rules:
- TypeScript rules
- React rules
- React Hooks rules
Purpose: Code formatting (if used)
Purpose: PostCSS configuration
Plugins:
- tailwindcss
- autoprefixer
public/
βββ favicon.ico
βββ logo.svg
βββ ...
Static assets served as-is.
Format: PascalCase
Examples:
DatabaseView.tsxTableView.tsxQueryConsole.tsx
Format: camelCase
Examples:
api.tsauth.tshelpers.ts
Format: kebab-case or specific conventions
Examples:
vite.config.tstailwind.config.js.env.example
tsconfig.json:
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
}
}Usage:
// Instead of
import { Button } from '../../../components/ui/button';
// Use
import { Button } from '@/components/ui/button';- Architecture - System architecture
- Frontend Architecture - React structure
- Worker Implementation - Worker structure
- Local Development - Development setup
Need Help? See Troubleshooting or open an issue.
- Database Management
- R2 Backup Restore
- Scheduled Backups
- Table Operations
- Query Console
- Schema Designer
- Column Management
- Bulk Operations
- Job History
- Time Travel
- Read Replication
- Undo Rollback
- Foreign Key Visualizer
- ER Diagram
- Foreign Key Dependencies
- Foreign Key Navigation
- Circular Dependency Detector
- Cascade Impact Simulator
- AI Search
- FTS5 Full Text Search
- Cross Database Search
- Index Analyzer
- Database Comparison
- Database Optimization