|
| 1 | +# ObjectStack Console |
| 2 | + |
| 3 | +The official **ObjectStack Platform Console** - a metadata-driven admin interface for managing data and configuration. |
| 4 | + |
| 5 | +## 🎯 Overview |
| 6 | + |
| 7 | +ObjectStack Console provides a modern, responsive admin interface that: |
| 8 | + |
| 9 | +- **Auto-generates UI** from your metadata definitions |
| 10 | +- **CRUD Operations** with built-in validation |
| 11 | +- **Dynamic Navigation** based on registered objects |
| 12 | +- **Real-time Updates** with optimistic UI patterns |
| 13 | +- **Dark Mode Support** via shadcn/ui theming |
| 14 | + |
| 15 | +## 🏗️ Architecture |
| 16 | + |
| 17 | +The console supports two runtime modes: |
| 18 | + |
| 19 | +### MSW Mode (Default) |
| 20 | + |
| 21 | +Runs the ObjectStack Runtime directly in the browser using MSW (Mock Service Worker), enabling full offline development. |
| 22 | + |
| 23 | +```mermaid |
| 24 | +graph TD |
| 25 | + Console["Console App"] -->|REST API| Network["Browser Network"] |
| 26 | + Network -->|Intercepted by| SW["Service Worker (MSW)"] |
| 27 | + SW -->|Delegates to| Kernel["ObjectStack Kernel"] |
| 28 | + Kernel -->|Uses| Driver["In-Memory Driver"] |
| 29 | + Kernel -.->|Reads| Config["objectstack.config.ts"] |
| 30 | +``` |
| 31 | + |
| 32 | +### Server Mode |
| 33 | + |
| 34 | +Connects to a real ObjectStack server for production use or integration testing. |
| 35 | + |
| 36 | +```mermaid |
| 37 | +graph TD |
| 38 | + Console["Console App"] -->|REST API| Server["ObjectStack Server"] |
| 39 | + Server -->|Processes| Kernel["ObjectStack Kernel"] |
| 40 | + Kernel -->|Uses| Driver["Database Driver"] |
| 41 | +``` |
| 42 | + |
| 43 | +## 🚀 Quick Start |
| 44 | + |
| 45 | +```bash |
| 46 | +# Install dependencies |
| 47 | +pnpm install |
| 48 | + |
| 49 | +# Start development server (MSW mode) |
| 50 | +pnpm dev |
| 51 | + |
| 52 | +# Start in server mode (connects to real backend) |
| 53 | +VITE_RUNTIME_MODE=server VITE_SERVER_URL=http://localhost:5000/api/v1 pnpm dev |
| 54 | +``` |
| 55 | + |
| 56 | +The console will be available at `http://localhost:3000`. |
| 57 | + |
| 58 | +## ⚙️ Environment Variables |
| 59 | + |
| 60 | +| Variable | Default | Description | |
| 61 | +|----------|---------|-------------| |
| 62 | +| `VITE_RUNTIME_MODE` | `msw` | Runtime mode: `msw` or `server` | |
| 63 | +| `VITE_SERVER_URL` | `http://localhost:5000/api/v1` | Server URL (server mode only) | |
| 64 | + |
| 65 | +Copy `.env.example` to `.env.local` to customize: |
| 66 | + |
| 67 | +## 📁 Project Structure |
| 68 | + |
| 69 | +``` |
| 70 | +apps/console/ |
| 71 | +├── src/ |
| 72 | +│ ├── App.tsx # Main application component |
| 73 | +│ ├── main.tsx # Entry point with MSW bootstrap |
| 74 | +│ ├── index.css # Tailwind CSS configuration |
| 75 | +│ ├── components/ |
| 76 | +│ │ ├── app-sidebar.tsx # Dynamic navigation sidebar |
| 77 | +│ │ ├── site-header.tsx # Page header with breadcrumbs |
| 78 | +│ │ ├── ObjectDataTable.tsx # Auto-generated data tables |
| 79 | +│ │ ├── ObjectDataForm.tsx # Auto-generated forms |
| 80 | +│ │ └── ui/ # shadcn/ui components |
| 81 | +│ ├── hooks/ # Custom React hooks |
| 82 | +│ ├── lib/ # Utilities |
| 83 | +│ └── mocks/ # MSW configuration |
| 84 | +├── objectstack.config.ts # Metadata definitions |
| 85 | +└── package.json |
| 86 | +``` |
| 87 | + |
| 88 | +## 🎨 UI Components |
| 89 | + |
| 90 | +Built with [shadcn/ui](https://ui.shadcn.com/) and Tailwind CSS v4: |
| 91 | + |
| 92 | +- **Sidebar** - Collapsible navigation with object list |
| 93 | +- **DataTable** - Sortable, filterable data grid |
| 94 | +- **DataForm** - Dynamic form generation from field metadata |
| 95 | +- **Toast** - Notification system for user feedback |
| 96 | + |
| 97 | +## 🔧 Configuration |
| 98 | + |
| 99 | +The console reads metadata from `objectstack.config.ts`: |
| 100 | + |
| 101 | +```typescript |
| 102 | +import { defineStack } from '@objectstack/spec'; |
| 103 | +import { ObjectSchema, Field } from '@objectstack/spec/data'; |
| 104 | + |
| 105 | +export const Account = ObjectSchema.create({ |
| 106 | + name: 'account', |
| 107 | + label: 'Account', |
| 108 | + fields: { |
| 109 | + name: Field.text({ label: 'Name', required: true }), |
| 110 | + industry: Field.select({ |
| 111 | + label: 'Industry', |
| 112 | + options: ['Technology', 'Finance', 'Healthcare'] |
| 113 | + }), |
| 114 | + } |
| 115 | +}); |
| 116 | + |
| 117 | +export default defineStack({ |
| 118 | + objects: [Account] |
| 119 | +}); |
| 120 | +``` |
| 121 | + |
| 122 | +## 📦 Dependencies |
| 123 | + |
| 124 | +- **React 18** - UI framework |
| 125 | +- **Vite** - Build tool |
| 126 | +- **Tailwind CSS v4** - Styling |
| 127 | +- **shadcn/ui** - Component library |
| 128 | +- **MSW** - API mocking for development |
| 129 | +- **@objectstack/client** - API client |
| 130 | +- **@objectstack/runtime** - In-browser kernel |
| 131 | + |
| 132 | +## 🛠️ Development |
| 133 | + |
| 134 | +```bash |
| 135 | +# Type checking |
| 136 | +pnpm typecheck |
| 137 | + |
| 138 | +# Run tests |
| 139 | +pnpm test |
| 140 | + |
| 141 | +# Build for production |
| 142 | +pnpm build |
| 143 | + |
| 144 | +# Preview production build |
| 145 | +pnpm preview |
| 146 | +``` |
| 147 | + |
| 148 | +## 📄 License |
| 149 | + |
| 150 | +MIT - See [LICENSE](../../LICENSE) for details. |
0 commit comments