izzicooki commited on
Commit
beb3482
·
1 Parent(s): 33596d3

Add docs for team

Browse files
docs/architecture-overview.md ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PC Pal — Architecture Overview
2
+
3
+ ## What is PC Pal?
4
+
5
+ PC Pal is a web-based AI chat assistant that helps elderly and beginner computer users learn basic PC skills. Think of it as a patient, friendly grandchild who teaches grandparents how to use their computer — through a simple chat interface with visual guides.
6
+
7
+ A user opens the app in their browser, goes through a quick onboarding (name, device, comfort level), and then chats with the AI. The AI responds with simple language, visual step-by-step guide cards, keyboard diagrams, and progress tracking.
8
+
9
+ ---
10
+
11
+ ## How It All Fits Together
12
+
13
+ ```
14
+ ┌─────────────────────────────────────────────────────┐
15
+ │ USER'S BROWSER │
16
+ │ │
17
+ │ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
18
+ │ │ Onboarding │ │ Chat Window │ │ Visual │ │
19
+ │ │ Wizard │ │ + Messages │ │ Guides │ │
20
+ │ └──────────────┘ └──────┬───────┘ └───────────┘ │
21
+ │ │ │
22
+ │ WebSocket / REST │
23
+ └───────────────────────────┼─────────────────────────┘
24
+ │
25
+ ▼
26
+ ┌─────────────────────────────────────────────────────┐
27
+ │ EXPRESS SERVER │
28
+ │ (Node.js, port 3001) │
29
+ │ │
30
+ │ 1. Safety Monitor ──→ Check for emergencies │
31
+ │ 2. Task Classifier ──→ What kind of question? │
32
+ │ 3. Agent Orchestrator ──→ Call Claude AI + tools │
33
+ │ 4. Vocabulary Filter ──→ Simplify jargon │
34
+ │ 5. Save to Database ──→ SQLite │
35
+ │ │
36
+ │ OR (if no API key): │
37
+ │ 3. Mock Responder ──→ Pre-written demo answers │
38
+ └─────────────────────────────────────────────────────┘
39
+ ```
40
+
41
+ ---
42
+
43
+ ## The Message Pipeline
44
+
45
+ Every time a user sends a message, it flows through this pipeline:
46
+
47
+ ### Step 1: Safety Check
48
+ **File:** `server/core/safetyMonitor.js`
49
+
50
+ Before anything else, the message is scanned for emergency keywords ("fallen", "chest pain", "911") and scam patterns ("gift card", "wire transfer", "IRS"). If detected, the pipeline short-circuits and returns an immediate safety response. This runs even in demo mode.
51
+
52
+ ### Step 2: User Lookup
53
+ **File:** `server/core/userProfileManager.js`
54
+
55
+ The user's profile is loaded from the database — their name, OS type, comfort level (1-5), vocabulary level, and skill history. This information is injected into the AI's system prompt so it can personalize its responses.
56
+
57
+ ### Step 3: Mock Mode Check
58
+ **File:** `server/core/mockResponder.js`
59
+
60
+ If no API key is set (or `MOCK_MODE=true`), the pipeline skips the AI and uses pre-written pattern-matched responses instead. The mock responder still creates step sequences, logs skills, and saves notes — it exercises all the same features as the real AI.
61
+
62
+ ### Step 4: Task Classification
63
+ **File:** `server/core/taskClassifier.js`
64
+
65
+ The message is classified into a type: `learn_skill`, `troubleshoot`, `follow_up`, `accessibility`, or `unknown`. This classification is passed to the AI along with the urgency level (low/medium/high), so it knows how to prioritize its response.
66
+
67
+ ### Step 5: AI Agent (Claude)
68
+ **File:** `server/core/agentOrchestrator.js`
69
+
70
+ This is the core of the app. The AI receives:
71
+ - The user's message
72
+ - The conversation history (last 20 messages)
73
+ - The user's profile (name, OS, comfort level, skills)
74
+ - The task classification
75
+ - A system prompt with 12 tools it can call
76
+
77
+ The AI generates a response and may call tools like `show_visual_guide` or `start_step_sequence`. Tool calls are processed in a loop — the AI can call multiple tools before giving its final text answer.
78
+
79
+ ### Step 6: Vocabulary Filter
80
+ **File:** `server/core/vocabularyFilter.js`
81
+
82
+ The AI's response is filtered to replace technical jargon with simple language. "Browser" becomes "internet app", "URL" becomes "web address", "attachment" becomes "file in the email", etc. Sentences longer than 20 words are split at natural break points.
83
+
84
+ ### Step 7: Save & Respond
85
+
86
+ The response is saved to the database and sent back to the user via WebSocket (or REST). The response includes:
87
+ - `text` — the message text
88
+ - `guideId` — which visual guide to show (if any)
89
+ - `stepSequence` — step progress data (if any)
90
+ - `safetyAlert` — emergency/scam alert (if any)
91
+
92
+ ---
93
+
94
+ ## The 12 AI Tools
95
+
96
+ When the Claude AI is processing a message, it can decide to call any of these tools:
97
+
98
+ | Tool | What it does | When the AI uses it |
99
+ |------|-------------|-------------------|
100
+ | `show_visual_guide` | Shows a visual card with numbered steps and keyboard diagrams | User asks how to do a common task (copy/paste, email, etc.) |
101
+ | `start_step_sequence` | Creates a multi-step walkthrough with progress bar | Task has 3+ steps |
102
+ | `advance_step` | Moves to the next step | User says "done", "ok", "next" |
103
+ | `complete_step_sequence` | Marks task finished, logs the skill | User finishes all steps |
104
+ | `log_skill_started` | Records that a new skill lesson began | AI starts teaching a new topic |
105
+ | `suggest_next_skill` | Recommends what to learn next | User asks "what should I learn?" or finishes a skill |
106
+ | `repeat_last_step` | Re-shows the current step | User says "repeat" or seems confused |
107
+ | `adjust_vocabulary_level` | Changes jargon filtering level | User seems confused (lower) or confident (raise) |
108
+ | `save_note_for_user` | Saves a tip for later reference | AI teaches something important |
109
+ | `get_user_notes` | Shows saved tips | User asks "what have I learned?" |
110
+ | `restart_conversation` | Clears the session | User says "start over" or seems lost |
111
+ | `flag_emergency` | Logs an emergency alert | User mentions injury, falling, medical issue |
112
+
113
+ ---
114
+
115
+ ## Frontend Components
116
+
117
+ ### React App Structure
118
+
119
+ ```
120
+ App.jsx
121
+ ├── OnboardingFlow.jsx (shown first time only)
122
+ │ Step 1: Name
123
+ │ Step 2: Device type (Windows/Mac/iPhone/Android)
124
+ │ Step 3: Comfort level (1-5)
125
+ │
126
+ └── Header.jsx + ChatWindow.jsx (shown after onboarding)
127
+ ├── Message List
128
+ │ ├── MessageBubble.jsx (each message)
129
+ │ │ └── VisualGuide.jsx (if guideId present)
130
+ │ └── Typing indicator
131
+ │
132
+ ├── StepSequencePanel.jsx (if step sequence active)
133
+ │ ├── Progress bar
134
+ │ ├── Current step text
135
+ │ └── Quick-reply buttons ("Done!", "Help")
136
+ │
137
+ └── MessageInput.jsx (text input + send button)
138
+ ```
139
+
140
+ ### Visual Guide System
141
+
142
+ Visual guides are **not images** — they are styled HTML/CSS cards rendered from a data registry. This means:
143
+ - No image files to maintain
144
+ - Guides adapt to OS type (Windows vs Mac keyboard shortcuts)
145
+ - They render instantly with no loading
146
+
147
+ **File:** `client/src/components/Chat/guideRegistry.js`
148
+
149
+ Contains structured data for 10 tasks, each with Windows and Mac variants. Each step can optionally include keyboard key combinations displayed as styled `<kbd>` elements.
150
+
151
+ **File:** `client/src/components/Chat/VisualGuide.jsx`
152
+
153
+ Renders a guide card with a blue header, numbered step circles, step descriptions, and keyboard diagrams.
154
+
155
+ ### Hooks
156
+
157
+ - **`useChat.js`** — Manages the WebSocket connection, message state, typing indicators, and active step sequence. Exposes `messages`, `sendMessage`, `isConnected`, `isTyping`, `activeSequence`.
158
+ - **`useUser.js`** — Manages user profile state, localStorage persistence, and API calls for creating/updating users.
159
+
160
+ ---
161
+
162
+ ## Database
163
+
164
+ SQLite with 7 tables. The database file is created automatically at `server/db/pcpal.db` on first run.
165
+
166
+ | Table | Purpose | Key Fields |
167
+ |-------|---------|-----------|
168
+ | `users` | User profiles | name, os_type, vocabulary_level, comfort_level (1-5), onboarded |
169
+ | `conversations` | Chat sessions | user_id, task_type, status (active/completed/abandoned) |
170
+ | `messages` | Message history | conversation_id, role (user/assistant), body |
171
+ | `step_sequences` | Multi-step task tracking | conversation_id, steps (JSON array), current_index, completed |
172
+ | `skill_events` | Skill learning log | user_id, skill_name, status (started/completed), practiced_at |
173
+ | `safety_events` | Emergency/scam logs | user_id, event_type, trigger_text |
174
+ | `user_notes` | Saved tips | user_id, title, content |
175
+
176
+ ---
177
+
178
+ ## Key Design Decisions
179
+
180
+ **Why WebSocket instead of just REST?**
181
+ WebSocket lets us send a "typing" indicator before the AI responds. The AI can take 3-10 seconds, and without a typing indicator, elderly users think the app is broken. WebSocket also enables future features like proactive messages.
182
+
183
+ **Why SQLite instead of PostgreSQL?**
184
+ Zero setup. The database is a single file that's created automatically. For a prototype with <100 users, SQLite is more than enough. The same queries work with PostgreSQL if we scale later.
185
+
186
+ **Why HTML/CSS guide cards instead of screenshots?**
187
+ Screenshots go stale when OS interfaces change, require capturing and hosting image files, and can't adapt to different OS types. HTML cards are generated from data, render instantly, and automatically show the right keyboard shortcuts for Windows vs Mac.
188
+
189
+ **Why mock mode?**
190
+ An API key costs money and requires account setup. Mock mode lets the entire team test and demo the app immediately without any external dependencies.
191
+
192
+ **Why vocabulary filtering instead of just prompting the AI?**
193
+ The AI is prompted to use simple language, but it sometimes slips. The vocabulary filter is a guaranteed safety net that catches jargon in every response, regardless of what the AI says.
194
+
195
+ ---
196
+
197
+ ## How to Run
198
+
199
+ ```bash
200
+ # Install
201
+ npm install
202
+ cd client && npm install && cd ..
203
+
204
+ # Configure (demo mode — no API key needed)
205
+ cp .env.example .env
206
+
207
+ # Start both servers
208
+ npm run dev
209
+
210
+ # Open in browser
211
+ http://localhost:5173
212
+ ```
213
+
214
+ The app runs in demo mode by default. Set `MOCK_MODE=false` and add an `ANTHROPIC_API_KEY` in `.env` to use the real Claude AI.
215
+
216
+ ## How to Test
217
+
218
+ ```bash
219
+ npm test # 74 backend tests
220
+ ```
docs/file-by-file-guide.md ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PC Pal — File-by-File Guide
2
+
3
+ Every file in the project, what it does, and where it fits.
4
+
5
+ ---
6
+
7
+ ## Root Files
8
+
9
+ | File | Purpose |
10
+ |------|---------|
11
+ | `package.json` | Node.js project config. Dependencies, scripts (`npm run dev`, `npm test`) |
12
+ | `.env.example` | Template for environment variables. Copy to `.env` and fill in your keys |
13
+ | `.env` | Your actual API keys (gitignored — never committed) |
14
+ | `.gitignore` | Files git should ignore (node_modules, .env, database files) |
15
+ | `jest.config.js` | Test runner config — tells Jest to only look at `server/__tests__/` |
16
+ | `README.md` | Project overview and setup instructions |
17
+
18
+ ---
19
+
20
+ ## Server Files
21
+
22
+ ### `server/index.js` — The Entry Point
23
+ - Creates the Express HTTP server
24
+ - Sets up the WebSocket server on `/ws`
25
+ - Mounts REST routes (`/api/users`, `/api/chat`)
26
+ - Handles WebSocket message protocol: `init` → `chat` → `response`
27
+ - Includes connection cleanup, input validation, and graceful shutdown
28
+
29
+ ### `server/config.js` — Environment Config
30
+ - Loads `.env` file via dotenv
31
+ - Exports: `{ port, anthropicApiKey, geminiApiKey }`
32
+
33
+ ---
34
+
35
+ ### `server/db/` — Database
36
+
37
+ | File | What it does |
38
+ |------|-------------|
39
+ | `schema.sql` | Defines all 7 database tables. Runs automatically on startup. |
40
+ | `database.js` | Initializes SQLite via `better-sqlite3`. Enables WAL mode and foreign keys. Exports the `db` instance used by all models. |
41
+ | `pcpal.db` | The actual database file (created automatically, gitignored) |
42
+
43
+ ---
44
+
45
+ ### `server/models/` — Data Access Layer
46
+
47
+ Each model file exports an object with CRUD methods. All use synchronous `better-sqlite3` calls and `uuid` for ID generation.
48
+
49
+ | File | Table | Key Methods |
50
+ |------|-------|------------|
51
+ | `User.js` | `users` | `create`, `findById`, `findAll`, `update`, `delete` |
52
+ | `Conversation.js` | `conversations` | `create`, `findById`, `findByUserId`, `findActive`, `update`, `close`, `abandonStale` |
53
+ | `Message.js` | `messages` | `create`, `findByConversationId`, `getRecent(conversationId, limit=20)` |
54
+ | `StepSequence.js` | `step_sequences` | `create`, `findById`, `findByConversationId`, `update` — stores steps as JSON array |
55
+ | `SkillEvent.js` | `skill_events` | `create`, `findByUserId`, `findBySkillName` — tracks skill started/completed events |
56
+ | `SafetyEvent.js` | `safety_events` | `create`, `findByUserId` — logs emergency and scam detections |
57
+ | `UserNote.js` | `user_notes` | `create`, `findByUserId`, `findById`, `delete` — user's saved tips |
58
+
59
+ ---
60
+
61
+ ### `server/core/` — Business Logic (The Brain)
62
+
63
+ This is where all the important logic lives.
64
+
65
+ #### `agentOrchestrator.js` — The Main Pipeline (~450 lines)
66
+ **This is the most important file in the project.**
67
+
68
+ - Defines 12 Claude AI tools with their schemas
69
+ - `processMessage(text, userId)` — the entry point for every user message
70
+ - Pipeline: safety check → mock mode check → user lookup → session management → classification → Claude API call → tool handling loop → vocabulary filtering → save & return
71
+ - `handleFunctionCall(name, args, userId, sessionId)` — dispatches tool calls from the AI to the appropriate handler
72
+ - `buildSystemPrompt(profileString, user, classification)` — constructs the AI's personality and instructions based on user profile and comfort level
73
+ - `buildComfortGuidelines(comfortLevel)` — returns different instruction sets for comfort levels 1, 2-3, and 4-5
74
+
75
+ #### `mockResponder.js` — Demo Mode (~250 lines)
76
+ - Used when no API key is set or `MOCK_MODE=true`
77
+ - Pattern-matches user messages (e.g., "copy" → copy/paste guide, "done" → advance step)
78
+ - Returns the same response shape as the real orchestrator
79
+ - Creates real step sequences, skill events, and notes in the database
80
+ - Exercises all UI features without any external API calls
81
+
82
+ #### `safetyMonitor.js` — Emergency & Scam Detection (~100 lines)
83
+ - `checkMessage(text, userId)` — scans every message before the AI sees it
84
+ - 10 emergency keyword patterns (word-boundary regex, case-insensitive)
85
+ - 8 scam detection patterns (gift cards, wire transfers, IRS, remote access, etc.)
86
+ - Logs detections to `SafetyEvent` model
87
+ - Returns `{ safe: true/false, type: 'emergency'|'scam'|null, response: string|null }`
88
+
89
+ #### `taskClassifier.js` — Message Classification (~85 lines)
90
+ - `classifyMessage(text, userProfile)` — calls Claude API to classify the message
91
+ - Returns: `{ taskType: 'learn_skill'|'troubleshoot'|'follow_up'|'accessibility'|'unknown', topic, urgency }`
92
+ - Gracefully falls back to `unknown` on any API error
93
+ - Strips markdown code fences from Claude's response before parsing
94
+
95
+ #### `vocabularyFilter.js` — Jargon Replacement (~100 lines)
96
+ - `filterResponse(text, vocabLevel)` — replaces technical terms with plain language
97
+ - 3 levels: `basic` (all 20+ substitutions), `intermediate` (8 technical terms only), `standard` (no changes)
98
+ - Whole-word matching (won't replace "browsing" when targeting "browser")
99
+ - `enforceReadability(text)` — splits sentences >20 words at conjunctions (and, but, or, so, because)
100
+
101
+ #### `conversationState.js` — Session Management (~70 lines)
102
+ - `getOrCreateSession(userId)` — finds the user's active conversation or creates a new one
103
+ - `closeSession(sessionId)` — marks a conversation as completed
104
+ - `abandonStale()` — marks conversations with no activity for 30+ minutes as abandoned
105
+ - `addMessage(sessionId, role, body)` — adds a message to the conversation
106
+ - `getSessionMessages(sessionId, limit)` — retrieves recent messages
107
+
108
+ #### `userProfileManager.js` — Profile Logic (~110 lines)
109
+ - `getOrCreateUser(id)` — finds or creates a user record
110
+ - `updateProfile(id, fields)` — updates allowed profile fields only
111
+ - `getProfileForPrompt(id)` — returns a formatted string for injecting into the AI's system prompt, including name, OS, vocabulary level, comfort level, and skill history with relative timestamps
112
+
113
+ #### `skillProgression.js` — Learning Chains (~75 lines)
114
+ - Defines 3 skill progression chains:
115
+ - `copy_paste → send_email → attach_file`
116
+ - `open_browser → find_wifi → open_settings`
117
+ - `take_screenshot → zoom_text → use_taskbar → restart_computer`
118
+ - `getNextSkill(userId)` — walks the chains and finds the first uncompleted skill
119
+ - `getSkillStatus(userId)` — returns all skills with completion status
120
+
121
+ ---
122
+
123
+ ### `server/routes/` — REST API
124
+
125
+ | File | Endpoints |
126
+ |------|----------|
127
+ | `users.js` | `POST /api/users` (create), `GET /api/users/:id` (read), `PUT /api/users/:id` (update), `PUT /api/users/:id/onboard` (mark onboarded) |
128
+ | `chat.js` | `POST /api/chat` (REST fallback for WebSocket chat) |
129
+
130
+ ---
131
+
132
+ ### `server/__tests__/` — Backend Tests
133
+
134
+ | File | What it tests | # Tests |
135
+ |------|-------------|---------|
136
+ | `vocabularyFilter.test.js` | Word substitution, whole-word matching, readability splitting, edge cases | 46 |
137
+ | `safetyMonitor.test.js` | Emergency keywords, scam patterns, partial-word non-matching, DB logging | 22 |
138
+ | `taskClassifier.test.js` | Classification accuracy, error handling, JSON parsing, markdown stripping | 22 |
139
+
140
+ All tests mock external dependencies (Claude API, database models) so they run instantly without any setup.
141
+
142
+ ---
143
+
144
+ ## Client Files
145
+
146
+ ### `client/src/App.jsx` — Root Component
147
+ - If user is not onboarded → show `OnboardingFlow`
148
+ - If user is onboarded → show `Header` + `ChatWindow`
149
+ - Passes `userId` and `osType` to `ChatWindow`
150
+
151
+ ### `client/src/main.jsx` — Entry Point
152
+ - Imports global CSS
153
+ - Renders `App` in React StrictMode
154
+
155
+ ---
156
+
157
+ ### `client/src/hooks/`
158
+
159
+ | File | What it does |
160
+ |------|-------------|
161
+ | `useChat.js` | Manages WebSocket connection, message state, typing indicators, reconnection with backoff (max 5 attempts), and `activeSequence` state for step tracking |
162
+ | `useUser.js` | Manages user profile state, localStorage persistence, API calls for create/update/onboard |
163
+
164
+ ---
165
+
166
+ ### `client/src/components/Chat/`
167
+
168
+ | File | What it renders |
169
+ |------|----------------|
170
+ | `ChatWindow.jsx` | The main chat container — scrollable message list, typing indicator, step panel, message input |
171
+ | `MessageBubble.jsx` | A single message — user (right/blue) or assistant (left/white). Shows safety alerts and renders `VisualGuide` when a `guideId` is present |
172
+ | `MessageInput.jsx` | Large text input (56px) + Send button. Enter to submit. Disabled while typing. Auto-focus |
173
+ | `VisualGuide.jsx` | Renders a visual guide card — blue header, numbered step circles (36px), keyboard `<kbd>` diagrams. Looks up data from `guideRegistry.js` |
174
+ | `StepSequencePanel.jsx` | Step progress panel — task name, "Step X of Y", progress bar, current step text, quick-reply buttons ("Done!", "Help") |
175
+ | `guideRegistry.js` | Data file with 10 task guides (Windows + Mac variants, ~200 lines). Each step has text and optional keyboard keys |
176
+
177
+ ---
178
+
179
+ ### `client/src/components/Onboarding/`
180
+
181
+ | File | What it renders |
182
+ |------|----------------|
183
+ | `OnboardingFlow.jsx` | 3-step wizard: name → device type (large buttons) → comfort level (1-5 scale with friendly labels). Progress dots and Next/Back navigation |
184
+
185
+ ---
186
+
187
+ ### `client/src/components/Layout/`
188
+
189
+ | File | What it renders |
190
+ |------|----------------|
191
+ | `Header.jsx` | Top bar with "PC Pal" title, subtitle, and user name/OS badge |
192
+
193
+ ---
194
+
195
+ ### `client/src/styles/globals.css`
196
+ - CSS custom properties (variables) for colors, spacing, fonts, borders
197
+ - 18px base font size, 1.6 line-height
198
+ - 48px minimum touch target for all interactive elements
199
+ - High-contrast color palette
200
+ - `prefers-reduced-motion` media query for accessibility
201
+ - Focus-visible outlines for keyboard navigation
docs/getting-started-for-teammates.md ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Getting Started — For Teammates
2
+
3
+ Welcome to PC Pal! This guide will get you up and running in 5 minutes.
4
+
5
+ ---
6
+
7
+ ## What is this project?
8
+
9
+ PC Pal is a web app that helps elderly people learn to use their computer. Users chat with an AI assistant that:
10
+ - Explains things in simple language
11
+ - Shows visual guide cards with numbered steps and keyboard diagrams
12
+ - Tracks what skills they've learned
13
+ - Detects emergencies and scams
14
+
15
+ **You don't need an API key to run it.** The app has a built-in demo mode.
16
+
17
+ ---
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Clone & Install
22
+
23
+ ```bash
24
+ git clone https://github.com/your-org/COS498-Group-7-Repo.git
25
+ cd COS498-Group-7-Repo
26
+ npm install
27
+ cd client && npm install && cd ..
28
+ ```
29
+
30
+ ### 2. Create your .env file
31
+
32
+ ```bash
33
+ cp .env.example .env
34
+ ```
35
+
36
+ That's it. The defaults enable demo mode automatically.
37
+
38
+ ### 3. Start the app
39
+
40
+ ```bash
41
+ npm run dev
42
+ ```
43
+
44
+ This starts two servers:
45
+ - **Backend** on http://localhost:3001
46
+ - **Frontend** on http://localhost:5173
47
+
48
+ ### 4. Open in your browser
49
+
50
+ Go to **http://localhost:5173**
51
+
52
+ You'll see the onboarding wizard. Fill in a name, pick a device, set comfort level, and you're in the chat.
53
+
54
+ ---
55
+
56
+ ## Try These in Demo Mode
57
+
58
+ | Type this | What happens |
59
+ |-----------|-------------|
60
+ | "How do I copy and paste?" | Visual guide card appears + step-by-step walkthrough starts |
61
+ | "done" or "next" | Advances to the next step |
62
+ | "How do I take a screenshot?" | Another visual guide with keyboard shortcuts |
63
+ | "What should I learn next?" | Suggests the next skill based on your progress |
64
+ | "My notes" | Shows saved tips from your session |
65
+ | "Start over" | Clears the conversation |
66
+ | "Help" | Lists everything PC Pal can help with |
67
+ | "I've fallen" | Triggers the emergency alert system |
68
+
69
+ ---
70
+
71
+ ## Project Structure (High Level)
72
+
73
+ ```
74
+ client/ React frontend (what the user sees)
75
+ server/ Node.js backend (the brains)
76
+ core/ Business logic (AI agent, safety, vocabulary)
77
+ models/ Database access (users, messages, skills)
78
+ routes/ REST API endpoints
79
+ db/ SQLite database
80
+ docs/ Documentation (you are here)
81
+ ```
82
+
83
+ **Want more detail?** Read `docs/file-by-file-guide.md` for a breakdown of every file.
84
+
85
+ **Want the big picture?** Read `docs/architecture-overview.md` for how everything connects.
86
+
87
+ ---
88
+
89
+ ## Common Tasks
90
+
91
+ ### Run tests
92
+ ```bash
93
+ npm test
94
+ ```
95
+ 74 tests, takes about 1 second.
96
+
97
+ ### Reset the database
98
+ Delete `server/db/pcpal.db` and restart the server. A fresh database is created automatically.
99
+
100
+ ### Switch from demo mode to real AI
101
+ 1. Get an API key from [console.anthropic.com](https://console.anthropic.com/)
102
+ 2. Edit `.env`:
103
+ ```
104
+ ANTHROPIC_API_KEY=sk-ant-your-key-here
105
+ MOCK_MODE=false
106
+ ```
107
+ 3. Restart the server
108
+
109
+ ### Add a new visual guide
110
+ 1. Open `client/src/components/Chat/guideRegistry.js`
111
+ 2. Add a new entry following the existing pattern (title, Windows/Mac steps, optional keyboard keys)
112
+ 3. Add the new ID to `VALID_GUIDE_IDS` in `server/core/agentOrchestrator.js`
113
+
114
+ ### Add a new vocabulary substitution
115
+ 1. Open `server/assets/vocabulary/basicSubstitutions.json`
116
+ 2. Add a new `"technical_term": "simple replacement"` entry
117
+
118
+ ---
119
+
120
+ ## Tech Stack Summary
121
+
122
+ | What | Technology | Why |
123
+ |------|-----------|-----|
124
+ | Frontend | React + Vite | Fast dev server, component-based UI |
125
+ | Backend | Node.js + Express | JavaScript everywhere, good WebSocket support |
126
+ | Real-time | WebSocket (`ws`) | Typing indicators, instant responses |
127
+ | AI | Claude API (Anthropic) | Best at tool-use and following instructions |
128
+ | Database | SQLite | Zero setup, single file, good enough for prototype |
129
+ | Tests | Jest | Standard Node.js test runner |
130
+
131
+ ---
132
+
133
+ ## Who Built What
134
+
135
+ This is the first prototype. The core implementation includes:
136
+ - 12 AI agent tools
137
+ - 10 visual task guides (Windows + Mac)
138
+ - Safety monitoring (emergencies + scams)
139
+ - Vocabulary simplification (20+ terms)
140
+ - Comfort-level adaptive responses
141
+ - Full demo mode
142
+ - 74 automated tests
143
+
144
+ ---
145
+
146
+ ## Need Help?
147
+
148
+ - **Architecture questions** → `docs/architecture-overview.md`
149
+ - **"What does this file do?"** → `docs/file-by-file-guide.md`
150
+ - **Setup problems** → Check that Node.js v18+ is installed and both `npm install` commands ran
151
+ - **Database issues** → Delete `server/db/pcpal.db` and restart