Skip to content

Commit 0cd7f45

Browse files
jfarcandclaude
andcommitted
docs: add Chapter 34 database system prompts and expand admin/user mode docs
- Add Chapter 34: Database System Prompts - Document prompt categories, welcome prompts, and system prompts - Explain pillar-based organization (Activity, Nutrition, Recovery) - Cover tenant isolation and admin CRUD operations - Include API endpoints and PromptManager implementation - Update Chapter 33: Frontend Development - Add comprehensive Admin vs User Mode section - Document role-based UI (user, admin, super_admin) - Detail all 9 admin tabs and 4 user settings tabs - Include ASCII diagrams for both interfaces - Add sidebar collapse functionality documentation Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent cef28f0 commit 0cd7f45

File tree

3 files changed

+814
-0
lines changed

3 files changed

+814
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- [Adding New Tools](./chapter-31-adding-new-tools.md)
5555
- [SDK Development](./chapter-32-sdk-development.md)
5656
- [Frontend Development](./chapter-33-frontend-development.md)
57+
- [Database System Prompts](./chapter-34-database-system-prompts.md)
5758

5859
# Appendices
5960

src/chapter-33-frontend-development.md

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ function App() {
150150

151151
### Dashboard Tabs
152152

153+
The Dashboard component renders different interfaces based on user role:
154+
153155
| Tab | Component | Description |
154156
|-----|-----------|-------------|
155157
| Home | `OverviewTab.tsx` | Statistics overview |
@@ -160,6 +162,228 @@ function App() {
160162
| Settings | `UserSettings.tsx` | Profile settings |
161163
| Admin | `AdminConfiguration.tsx` | Admin-only settings |
162164

165+
## Admin vs User Mode
166+
167+
Pierre has three user roles that determine the UI experience:
168+
169+
| Role | Access Level | Default Tab |
170+
|------|--------------|-------------|
171+
| `user` | User mode only | Chat |
172+
| `admin` | Admin + User modes | Overview |
173+
| `super_admin` | Full access including token management | Overview |
174+
175+
### User Mode (Regular Users)
176+
177+
**Source**: `frontend/src/components/Dashboard.tsx:207-248`
178+
179+
Regular users see a clean, focused interface:
180+
181+
```
182+
┌─────────────────────────────────────────────────────────────────┐
183+
│ Pierre Fitness Intelligence │
184+
├─────────────────────────────────────────────────────────────────┤
185+
│ │
186+
│ AI Chat Interface │
187+
│ │
188+
│ ┌──────────────────────────────────────────────────────────┐ │
189+
│ │ │ │
190+
│ │ Welcome! Ask me about your fitness data. │ │
191+
│ │ │ │
192+
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
193+
│ │ │ Training │ │ Nutrition │ │ Recovery │ │ │
194+
│ │ │ ⚡ Activity │ │ 🥗 Amber │ │ 💤 Indigo │ │ │
195+
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
196+
│ │ │ │
197+
│ │ [Message input field...] [Send] │ │
198+
│ └──────────────────────────────────────────────────────────┘ │
199+
│ │
200+
│ [⚙️ Settings] │
201+
└─────────────────────────────────────────────────────────────────┘
202+
```
203+
204+
**User mode features**:
205+
- **Chat Tab**: AI conversation with prompt suggestions organized by pillar
206+
- **Settings Tab**: Access via gear icon in chat header
207+
208+
```typescript
209+
// Dashboard.tsx - User mode check
210+
if (!isAdminUser) {
211+
return (
212+
<div className="h-screen bg-white flex flex-col overflow-hidden">
213+
{/* Minimal header */}
214+
<header className="h-12 border-b border-pierre-gray-100">
215+
<PierreLogoSmall />
216+
<span>Pierre Fitness Intelligence</span>
217+
</header>
218+
219+
{/* Chat or Settings content */}
220+
<main className="flex-1 overflow-hidden">
221+
{activeTab === 'chat' && <ChatTab onOpenSettings={() => setActiveTab('settings')} />}
222+
{activeTab === 'settings' && <UserSettings />}
223+
</main>
224+
</div>
225+
);
226+
}
227+
```
228+
229+
### User Settings Tabs
230+
231+
**Source**: `frontend/src/components/UserSettings.tsx:45-83`
232+
233+
Regular users have access to four settings tabs:
234+
235+
| Tab | Description | Features |
236+
|-----|-------------|----------|
237+
| **Profile** | User identity | Display name, email (read-only), avatar |
238+
| **Connections** | OAuth credentials | Add/remove Strava, Fitbit, Garmin, WHOOP, Terra credentials |
239+
| **API Tokens** | MCP tokens | Create/revoke tokens for Claude Desktop, Cursor IDE |
240+
| **Account** | Account management | Status, role, sign out, danger zone |
241+
242+
```typescript
243+
const SETTINGS_TABS: { id: SettingsTab; name: string }[] = [
244+
{ id: 'profile', name: 'Profile' },
245+
{ id: 'connections', name: 'Connections' },
246+
{ id: 'tokens', name: 'API Tokens' },
247+
{ id: 'account', name: 'Account' },
248+
];
249+
```
250+
251+
### Admin Mode (Admin/Super Admin)
252+
253+
**Source**: `frontend/src/components/Dashboard.tsx:250-540`
254+
255+
Admins see a full sidebar with navigation:
256+
257+
```
258+
┌──────────────┬──────────────────────────────────────────────────┐
259+
│ │ │
260+
│ [Pierre] │ Overview │
261+
│ │ │
262+
│ Overview ● │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐│
263+
│ Connections │ │ Total Users │ │ Active Keys │ │ Requests ││
264+
│ Analytics │ │ 127 │ │ 45 │ │ 12,847 ││
265+
│ Monitor │ └─────────────┘ └─────────────┘ └─────────────┘│
266+
│ Tools │ │
267+
│ Users 🔴 │ Weekly Usage Chart │
268+
│ Config │ [═══════════════════════════════════════] │
269+
│ Prompts │ │
270+
│ Settings │ Rate Limits A2A Connections │
271+
│ │ [████████░░] 80% ● Client A Connected │
272+
│ ────────── │ ● Client B Connected │
273+
│ 👤 Admin │ │
274+
│ [Sign out] │ │
275+
│ │ │
276+
└──────────────┴──────────────────────────────────────────────────┘
277+
```
278+
279+
**Admin tabs** (9 total):
280+
281+
| Tab | Component | Description |
282+
|-----|-----------|-------------|
283+
| **Overview** | `OverviewTab.tsx` | Dashboard statistics, quick links |
284+
| **Connections** | `UnifiedConnections.tsx` | A2A clients, OAuth connections |
285+
| **Analytics** | `UsageAnalytics.tsx` | Usage charts, trends |
286+
| **Monitor** | `RequestMonitor.tsx` | Real-time request logs |
287+
| **Tools** | `ToolUsageBreakdown.tsx` | Tool usage analysis |
288+
| **Users** | `UserManagement.tsx` | User list, approve/suspend (badge shows pending count) |
289+
| **Configuration** | `AdminConfiguration.tsx` | LLM providers, tenant settings |
290+
| **Prompts** | `PromptsAdminTab.tsx` | Manage AI prompts (see Chapter 34) |
291+
| **Settings** | `AdminSettings.tsx` | Auto-approval, security settings |
292+
293+
**Super admin additional tab**:
294+
295+
| Tab | Component | Description |
296+
|-----|-----------|-------------|
297+
| **Admin Tokens** | `ApiKeyList.tsx` / `ApiKeyDetails.tsx` | System API key management |
298+
299+
```typescript
300+
// Admin tabs definition
301+
const adminTabs: TabDefinition[] = [
302+
{ id: 'overview', name: 'Overview', icon: <ChartIcon /> },
303+
{ id: 'connections', name: 'Connections', icon: <WifiIcon /> },
304+
{ id: 'analytics', name: 'Analytics', icon: <GraphIcon /> },
305+
{ id: 'monitor', name: 'Monitor', icon: <EyeIcon /> },
306+
{ id: 'tools', name: 'Tools', icon: <GearIcon /> },
307+
{ id: 'users', name: 'Users', icon: <UsersIcon />, badge: pendingUsers.length },
308+
{ id: 'configuration', name: 'Configuration', icon: <SlidersIcon /> },
309+
{ id: 'prompts', name: 'Prompts', icon: <ChatIcon /> },
310+
{ id: 'admin-settings', name: 'Settings', icon: <SettingsIcon /> },
311+
];
312+
313+
// Super admin extends with token management
314+
const superAdminTabs = [
315+
...adminTabs,
316+
{ id: 'admin-tokens', name: 'Admin Tokens', icon: <KeyIcon /> },
317+
];
318+
```
319+
320+
### Role Detection
321+
322+
**Source**: `frontend/src/components/Dashboard.tsx:77-82`
323+
324+
```typescript
325+
const { user, logout } = useAuth();
326+
const isAdminUser = user?.role === 'admin' || user?.role === 'super_admin';
327+
const isSuperAdmin = user?.role === 'super_admin';
328+
329+
// Default tab based on role
330+
const [activeTab, setActiveTab] = useState(isAdminUser ? 'overview' : 'chat');
331+
```
332+
333+
### Admin-Only Features
334+
335+
**Users Tab** (`UserManagement.tsx`):
336+
- View all registered users
337+
- Approve pending registrations
338+
- Suspend/unsuspend users
339+
- View user activity details
340+
341+
**Configuration Tab** (`AdminConfiguration.tsx`):
342+
- LLM provider selection (OpenAI, Anthropic, etc.)
343+
- Model configuration
344+
- Tenant-specific settings
345+
346+
**Prompts Tab** (`PromptsAdminTab.tsx`):
347+
- Manage prompt categories
348+
- Edit welcome message
349+
- Customize system prompt
350+
- Reset to defaults
351+
352+
**Settings Tab** (`AdminSettings.tsx`):
353+
- Toggle auto-approval for registrations
354+
- System information display
355+
- Security recommendations
356+
357+
### Pending Users Badge
358+
359+
The Users tab shows a red badge when users are pending approval:
360+
361+
```typescript
362+
const { data: pendingUsers = [] } = useQuery<User[]>({
363+
queryKey: ['pending-users'],
364+
queryFn: () => apiService.getPendingUsers(),
365+
staleTime: 30_000,
366+
enabled: isAdminUser,
367+
});
368+
369+
// In tab definition
370+
{ id: 'users', name: 'Users', badge: pendingUsers.length > 0 ? pendingUsers.length : undefined }
371+
```
372+
373+
### Sidebar Collapse
374+
375+
The admin sidebar can be collapsed for more screen space:
376+
377+
```typescript
378+
const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
379+
380+
// Collapsed: 72px, Expanded: 260px
381+
<aside className={clsx(
382+
'fixed left-0 top-0 h-screen',
383+
sidebarCollapsed ? 'w-[72px]' : 'w-[260px]'
384+
)}>
385+
```
386+
163387
## Service Layer
164388

165389
### API Service (`services/api.ts`)

0 commit comments

Comments
 (0)