Spaces:
Sleeping
Sleeping
File size: 19,496 Bytes
f527e03 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | Here is Claude's plan: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ PC Pal - Implementation Plan
Context
PC Pal is an AI-powered IT tutor for elderly and beginner PC users, delivered via a web chat interface. The project addresses the gap
where 57M+ Americans aged 65+ struggle with basic computer tasks but existing solutions (YouTube, IT help desks, generic AI) fail to
teach lasting skills. PC Pal provides patient, step-by-step guidance with annotated visual screenshots, vocabulary simplification, and
persistent skill tracking.
Delivery: Web UI (React) first. SMS (Twilio) and CollaborAITE integration planned for later.
Timeline: v1 by Apr 14 | v2 by Apr 21 | v3 by Apr 28
---
Tech Stack
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Component β Choice β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Frontend β React (Vite) β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Backend β Node.js + Express β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β AI β Anthropic SDK (@anthropic-ai/sdk) with tool-use β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Database β SQLite (v1/v2 via better-sqlite3), PostgreSQL for v3 β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Real-time β WebSocket (via ws or Socket.IO) for streaming chat β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Image Processing β Sharp (Node.js) for annotated screenshots (v2) β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Scheduling β node-cron (v2+ for proactive messages) β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Testing β Jest (backend), React Testing Library (frontend) β
ββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
---
Architecture - Message Flow
React Chat UI (browser)
| WebSocket or POST /api/chat
v
Express Server (server/index.js)
|
v
ConversationRouter (server/core/conversationRouter.js)
| lookup user, load/create session
v
SafetyMonitor (runs FIRST on every message)
| emergency/scam detection
v
TaskClassifier (Claude call)
| learn_skill | troubleshoot | follow_up | accessibility
v
AgentOrchestrator (Claude tool-use loop)
| system prompt with user profile, history, vocab level
| tools: get_next_step, complete_step, log_skill, flag_emergency
v
VocabularyFilter
| replace jargon, enforce sentence length
v
WebSocket/Response β React Chat UI
---
Project Structure
client/ # React frontend (Vite)
src/
App.jsx # Main app with routing
components/
Chat/
ChatWindow.jsx # Main chat container
MessageBubble.jsx # Individual message display
MessageInput.jsx # Text input + send button
StepIndicator.jsx # "Step 2 of 5" progress bar
VisualGuide.jsx # Annotated screenshot display (v2)
Onboarding/
OnboardingFlow.jsx # Name, OS, comfort level collection
Layout/
Header.jsx # App header with user info
Sidebar.jsx # Skill history panel (v3)
hooks/
useChat.js # WebSocket connection + message state
useUser.js # User profile state
styles/
globals.css # Large fonts, high contrast, elderly-friendly
main.jsx
index.html
vite.config.js
server/ # Node.js + Express backend
index.js # Express app, WebSocket setup, DB init
config.js # Environment variable loading
db/
database.js # SQLite connection + schema init
schema.sql # Table definitions
models/
User.js # User CRUD operations
Conversation.js # Conversation CRUD
Message.js # Message CRUD
SkillEvent.js # Skill event CRUD
SafetyEvent.js # Safety event CRUD
StepSequence.js # Step sequence CRUD
core/
agentOrchestrator.js # Claude tool-use agent loop
taskClassifier.js # Message classification via Claude
userProfileManager.js # User profile logic + onboarding
conversationState.js # Session lifecycle + memory
stepSequencer.js # Numbered step management
vocabularyFilter.js # Jargon replacement + readability
skillTracker.js # Skill logging + reinforcement
safetyMonitor.js # Emergency + scam detection
proactiveEngine.js # Scheduled messages (v2)
visualGuideGenerator.js # Annotated screenshots via Sharp (v2)
assets/
vocabulary/
basicSubstitutions.json # Word replacement map
screenshots/ # Pre-captured OS screenshots (v2)
routes/
chat.js # POST /api/chat (REST fallback)
users.js # GET/POST /api/users
skills.js # GET /api/users/:id/skills (v3)
__tests__/
vocabularyFilter.test.js
taskClassifier.test.js
stepSequencer.test.js
safetyMonitor.test.js
conversationFlow.test.js
package.json
.env.example
README.md
---
Database Schema (SQLite)
users
CREATE TABLE users (
id TEXT PRIMARY KEY, -- UUID
name TEXT,
os_type TEXT, -- 'Windows 10', 'Windows 11', 'macOS', 'iPhone', 'Android'
vocabulary_level TEXT DEFAULT 'basic', -- basic | intermediate | standard
accessibility_needs TEXT DEFAULT '[]', -- JSON array
comfort_level INTEGER DEFAULT 1, -- 1-5
onboarded INTEGER DEFAULT 0, -- boolean
created_at TEXT DEFAULT (datetime('now')),
updated_at TEXT DEFAULT (datetime('now'))
);
conversations
CREATE TABLE conversations (
id TEXT PRIMARY KEY,
user_id TEXT REFERENCES users(id),
task_type TEXT,
status TEXT DEFAULT 'active', -- active | completed | abandoned
context_summary TEXT, -- compressed older context
started_at TEXT DEFAULT (datetime('now')),
ended_at TEXT
);
messages
CREATE TABLE messages (
id TEXT PRIMARY KEY,
conversation_id TEXT REFERENCES conversations(id),
role TEXT NOT NULL, -- 'user' | 'assistant'
body TEXT NOT NULL,
created_at TEXT DEFAULT (datetime('now'))
);
step_sequences
CREATE TABLE step_sequences (
id TEXT PRIMARY KEY,
conversation_id TEXT REFERENCES conversations(id),
steps TEXT NOT NULL, -- JSON array of step objects
current_index INTEGER DEFAULT 0,
completed INTEGER DEFAULT 0
);
skill_events
CREATE TABLE skill_events (
id TEXT PRIMARY KEY,
user_id TEXT REFERENCES users(id),
skill_name TEXT NOT NULL,
status TEXT DEFAULT 'started', -- started | completed | abandoned
practiced_at TEXT DEFAULT (datetime('now'))
);
safety_events
CREATE TABLE safety_events (
id TEXT PRIMARY KEY,
user_id TEXT REFERENCES users(id),
event_type TEXT NOT NULL, -- emergency | scam_detected | distress
trigger_text TEXT,
created_at TEXT DEFAULT (datetime('now'))
);
---
Implementation Phases
Phase 1 β v1 by April 14 (Core Chat Loop)
Goal: User opens the web app, onboards (name + OS), and gets context-aware IT help from Claude with simplified vocabulary through a chat
interface.
Steps:
1. Project setup
- Initialize Node.js project with package.json
- Initialize React project with Vite in client/
- Create .env.example with ANTHROPIC_API_KEY
- Create server/config.js for env loading
- Create server/db/database.js + schema.sql with all tables
- Files: package.json, .env.example, server/config.js, server/db/*
2. Express server + WebSocket
- Express app in server/index.js with CORS, JSON parsing
- WebSocket server (ws library) on same port for real-time chat
- On WS connection: assign/lookup user session
- On WS message: route through processing pipeline, send response back
- REST fallback: POST /api/chat for non-WebSocket clients
- File: server/index.js, server/routes/chat.js
3. React chat UI
- ChatWindow.jsx β scrollable message list + input
- MessageBubble.jsx β styled differently for user vs assistant messages
- MessageInput.jsx β large text input, prominent send button
- useChat.js hook β manages WebSocket connection, message state, send/receive
- Elderly-friendly CSS: minimum 18px font, high contrast, large click targets, simple layout
- Files: client/src/components/Chat/*, client/src/hooks/useChat.js, client/src/styles/globals.css
4. Onboarding flow
- OnboardingFlow.jsx β large-button wizard: "What's your name?", "What computer do you use?" (Windows/Mac/iPhone/Android with icons),
"How comfortable are you with computers?" (1-5 scale)
- Saves to users table via POST /api/users
- Shown on first visit, skipped after (user ID stored in localStorage)
- Files: client/src/components/Onboarding/OnboardingFlow.jsx, server/routes/users.js
5. User profile manager
- getOrCreateUser(id), updateProfile(id, fields)
- Returns full user profile for system prompt injection
- File: server/core/userProfileManager.js, server/models/User.js
6. Task classifier
- Single Claude call with classification prompt
- Returns: learn_skill | troubleshoot | follow_up | accessibility | unknown
- Also extracts: topic, urgency
- File: server/core/taskClassifier.js
7. Agent orchestrator
- Build system prompt from user profile (name, OS, vocab level, skill history)
- Claude messages API with tool-use: log_skill_started, flag_emergency
- Load last 20 messages from DB as conversation history
- Patient, elderly-appropriate tone in system prompt
- Stream responses via WebSocket for real-time feel
- File: server/core/agentOrchestrator.js
8. Vocabulary filter
- JSON config with word substitutions (browserβinternet, attachmentβfile in the email, etc.)
- filterResponse(text, vocabLevel) β applies substitutions
- Sentence length enforcement: split sentences > 20 words
- File: server/core/vocabularyFilter.js, server/assets/vocabulary/basicSubstitutions.json
9. Conversation state
- getOrCreateSession(userId) β find active session or start new
- closeSession(sessionId) β mark completed
- Timeout: abandon sessions inactive > 30 min
- File: server/core/conversationState.js, server/models/Conversation.js
10. Safety monitor (basic)
- Emergency keyword regex: "fallen", "can't breathe", "chest pain", "help me", "911", "emergency"
- On match: immediate response + log to safety_events
- Display alert banner in chat UI
- File: server/core/safetyMonitor.js
11. Basic tests
- Test vocabulary filter substitutions
- Test safety monitor keyword detection
- Test task classifier with mocked Claude responses
- Files: server/__tests__/vocabularyFilter.test.js, server/__tests__/safetyMonitor.test.js
---
Phase 2 β v2 by April 21 (Step Sequencer + Visual Guides + Skill Tracking)
Goal: Multi-turn step-by-step walkthroughs with annotated screenshots displayed in chat.
Steps:
1. Step sequencer
- createSequence(task, userId) β Claude generates numbered steps, stored in step_sequences
- getCurrentStep(sessionId) β returns step text + "Step X of Y"
- advanceStep(sessionId) β on user confirmation ("ok", "done", "got it", "next", "yes")
- isConfirmation(text) β fuzzy match for elderly-friendly confirmations
- File: server/core/stepSequencer.js
2. Step UI component
- StepIndicator.jsx β progress bar showing "Step 2 of 5"
- Quick-reply buttons: "OK, done!", "I need help", "Go back"
- File: client/src/components/Chat/StepIndicator.jsx
3. Agent orchestrator v2 β add tool-use for steps
- New tools: create_step_sequence, get_current_step, advance_step, send_visual_guide
- Agent decides when to break a task into steps vs. quick answer
- Update: server/core/agentOrchestrator.js
4. Visual guide generator
- Pre-captured base screenshots for top 10 tasks (Windows 10/11, macOS)
- Sharp overlay: red circles, arrows, numbered callouts at JSON-defined coordinates
- Serve annotated images via Express static route /assets/guides/
- Display in VisualGuide.jsx component in chat
- Files: server/core/visualGuideGenerator.js, server/assets/screenshots/, client/src/components/Chat/VisualGuide.jsx
5. Skill tracker
- logSkill(userId, skillName, status) β write to skill_events
- getUserSkills(userId) β list all learned skills
- getSkillsForReinforcement(userId) β skills not practiced in 7+ days
- File: server/core/skillTracker.js
6. Scam detection
- Keyword patterns: gift cards, wire transfer, IRS, lottery, send money, Bitcoin
- Warn user with prominent alert in chat
- Update: server/core/safetyMonitor.js
7. Context compression
- After 20 messages in a session, call Claude to summarize older messages
- Store summary in conversations.context_summary
- Inject summary into system prompt for continuity
- Update: server/core/conversationState.js
8. Tests for v2 features
- Test step sequencer (advancement, confirmation detection, boundary conditions)
- Test full conversation flow (multi-turn mock)
- Files: server/__tests__/stepSequencer.test.js, server/__tests__/conversationFlow.test.js
---
Phase 3 β v3 by April 28 (Polish + Scaffolding Fade + Evaluation)
Goal: Fade scaffolding, accessibility improvements, skill dashboard, deployment.
Steps:
1. Scaffolding fade logic
- If user completed a skill 3+ times, agent offers: "Want to try this on your own first?"
- On success: positive reinforcement. On failure: resume guided mode
- Update: server/core/agentOrchestrator.js, server/core/skillTracker.js
2. Accessibility improvements
- Theme toggle: high contrast / large text / default
- Keyboard navigation throughout
- Larger step counts (more granular) for users with accessibility needs
- Update: client/src/styles/globals.css, client/src/components/
3. Skill history sidebar
- Sidebar.jsx β shows all learned skills with dates and practice count
- GET /api/users/:id/skills endpoint
- Files: client/src/components/Layout/Sidebar.jsx, server/routes/skills.js
4. Proactive messages (in-app)
- node-cron job checks for skill reinforcement opportunities
- Sends in-app notification: "Want to practice [skill] today?"
- File: server/core/proactiveEngine.js
5. Deployment
- Build React β static files served by Express
- Deploy to Railway or Render
- Environment variables for secrets
- Update: server/index.js (serve static), README.md
6. Evaluation prep
- Pre/post confidence survey component in React
- Conversation log export endpoint: GET /api/conversations/:id/export
- Skill completion rate metrics
---
Key Design Decisions
WebSocket for real-time chat: Streaming Claude responses token-by-token gives a natural chat feel. Fallback REST endpoint for
reliability.
SQLite for v1/v2: Zero setup, single file DB. Same query patterns transfer to PostgreSQL for production. better-sqlite3 is synchronous
but fast enough for a class project. If async needed, switch to sqlite3 with promises.
Elderly-friendly UI defaults: 18px+ base font, high-contrast colors, large buttons, minimal navigation. No complex UI patterns β just a
chat window and onboarding wizard.
Context compression at 20 messages: Bounds token cost while maintaining conversation continuity. Claude summarizes older messages into a
compact context string.
Tool-use agent loop: Claude decides when to use tools (create steps, log skills, flag emergencies) rather than hardcoded routing. More
flexible and natural conversation flow.
---
Verification Plan
Local dev
1. npm install in root and client/
2. Set .env with ANTHROPIC_API_KEY
3. npm run dev β starts Express (port 3001) + Vite dev server (port 5173) with proxy
4. Open http://localhost:5173 in browser
Automated tests
- npm test β Jest tests for backend modules
- Mock Claude API responses with Jest mocks
- React Testing Library for component tests
Manual QA checklist per version
- Onboarding wizard collects name + OS + comfort level
- Chat message sends and receives response
- Vocabulary simplification in responses
- Emergency keyword triggers safety alert
- (v2) Step-by-step flow with progress bar and confirmation
- (v2) Annotated screenshot displays in chat
- (v2) Scam detection warning displays
- (v3) Skill fade ("try on your own") after 3 completions
- (v3) Skill history sidebar shows learned skills
- (v3) Deployed and accessible via public URL |