================================================================================
CONNECTICUT ELDERLY SERVICES PCA TRAINING PLATFORM - FILE INDEX
================================================================================

📁 DIRECTORY STRUCTURE & FILE DESCRIPTIONS

ROOT FILES
──────────
✓ app.js                    Main Express.js server file (startup file for cPanel)
✓ package.json              Node.js dependencies and project metadata
✓ .env.example              Environment variables template (copy to .env)
✓ README.md                 Quick start guide and feature overview
✓ SETUP.md                  Detailed setup guide for non-programmers
✓ PROJECT_SUMMARY.md        Technical overview and complete file inventory
✓ FILE_INDEX.txt            This file


lib/ - APPLICATION LOGIC
─────────────────────────
✓ db.js                     SQLite database operations (agencies, learners, progress)
✓ modules.js                12 training modules with full lesson content
✓ examContent.js            19-section final exam with 100+ questions
✓ certificate.js            PDF certificate generation using PDFKit
✓ email.js                  Email notifications (optional, pre-configured)


routes/ - API ENDPOINTS
──────────────────────
✓ learner.js                Module viewing, quiz submission, learner flow
✓ exam.js                   Exam delivery, scoring, results, certificates
✓ admin.js                  Admin authentication, dashboard, agency management


views/ - HTML TEMPLATES (EJS)
─────────────────────────────
✓ layout.ejs                Base template with header/footer (all pages extend this)
✓ index.ejs                 Home page with module list and CTA buttons
✓ start.ejs                 Name and agency code entry form
✓ error.ejs                 Error page for exceptions

modules/
  ✓ module.ejs              Module lesson display with embedded quiz form
  ✓ complete.ejs            Module completion confirmation page

exam/
  ✓ exam.ejs                19-section final exam interface

result/
  ✓ result.ejs              Pass/fail results with section breakdown

admin/
  ✓ login.ejs               Admin login page
  ✓ dashboard.ejs           Admin panel with stats, learner roster, agencies


public/ - STATIC FILES
──────────────────────
css/
  ✓ style.css               Complete responsive CSS (37 KB)
                            - Professional design (navy + gold)
                            - Mobile-first responsive layout
                            - Card components with shadows
                            - Progress bars with animations
                            - Print-friendly certificate styles
                            - All styling, no Tailwind/CDN dependencies

js/
  ✓ main.js                 Client-side JavaScript utilities
                            - Modal handling
                            - Form validation
                            - Toast notifications
                            - Progress animations

certificates/
  (auto-created on first run)
  - Stores generated PDF certificates


data/ - DATABASE
────────────────
  (auto-created on first run)
  ✓ training.db             SQLite3 database file (contains all learner data)


TRAINING CONTENT DETAILS
========================

12 TRAINING MODULES (in lib/modules.js)
────────────────────────────────────────
1. Emergency Response (11 lesson points, 5-question quiz)
2. Universal Precautions (10 points, 5 questions)
3. Communication (10 points, 5 questions)
4. Monitoring Condition Changes (10 points, 5 questions)
5. Positioning (6 points, 5 questions)
6. Safe Lifting (10 points, 5 questions)
7. Safe Transfers (5 points, 5 questions)
8. Medication Safety (9 points, 5 questions)
9. Professional Boundaries (10 points, 5 questions)
10. Brain Injury, Dementia & Behavior (14 points, 5 questions)
11. Reporting Abuse & Neglect (5 points, 5 questions)
12. Personal Care - Bathing, Hair & Mouth Care (20 points, 5 questions)

TOTAL: 12 modules × 5 questions = 60 knowledge check questions


19 FINAL EXAM SECTIONS (in lib/examContent.js)
───────────────────────────────────────────────
Each section is a true/false exam with multiple questions:

1. Preventing Emergency Situations (16 questions)
2. Universal Precautions (10 questions)
3. Communication (10 questions)
4. Change in an Individual's Condition (10 questions)
5. Positioning (11 questions)
6. Lifting (10 questions)
7. Transfers (5 questions)
8. Medication (9 questions)
9. Caregiver Boundaries (10 questions)
10. Individuals with Acquired Brain Injury (14 questions)
11. Reporting Abuse, Neglect, Exploitation and Abandonment (5 questions)
12. Bathing (5 questions)
13. Bathing Individuals with Dementia or Cognitive Deficits (5 questions)
14. How to Give a Bed Bath (5 questions)
15. Washing Hair (5 questions)
16. How to Wash Hair in Bed (5 questions)
17. Mouth Care (5 questions)
18. Mouth Care for Individuals with Dementia or Cognitive Impairment (5 questions)
19. Dressing (5 questions)

TOTAL: 100+ exam questions across 19 sections


KEY FEATURES BY FILE
====================

LEARNER FLOW:
- routes/learner.js         Module navigation, quiz submission
- routes/exam.js            Exam delivery, scoring
- views/modules/            Module and quiz pages
- views/exam.ejs            Final exam
- views/result.ejs          Results display

ADMIN FEATURES:
- routes/admin.js           Admin authentication
- views/admin/dashboard.ejs Admin panel
- lib/db.js                 Learner data retrieval

CERTIFICATE GENERATION:
- lib/certificate.js        PDF generation
- lib/email.js              Email notifications
- public/certificates/      PDF storage

DATABASE:
- lib/db.js                 All database operations
- data/training.db          SQLite file (auto-created)


CONFIGURATION FILES
===================

.env.example → Copy to .env and edit:
  - PORT                    Server port (default: 3000)
  - SESSION_SECRET          Session encryption key
  - ADMIN_PASSWORD          Admin login password
  - EMAIL_*                 Email configuration (optional)

package.json:
  - dependencies            Node packages to install


GETTING STARTED
===============

1. Read: README.md (quick overview)
2. Read: SETUP.md (detailed setup instructions)
3. Run: npm install
4. Run: npm start
5. Visit: http://localhost:3000
6. Login Admin: http://localhost:3000/admin/login


CUSTOMIZATION POINTS
====================

Change Organization Name:
  - views/layout.ejs (header)
  - lib/certificate.js (certificate text)

Change Colors:
  - public/css/style.css (CSS variables at top)

Add/Remove Modules:
  - lib/modules.js (add module objects)
  - Update any hardcoded module counts

Change Admin Password:
  - .env file (ADMIN_PASSWORD variable)

Add Agencies:
  - Routes/admin.js POST endpoint
  - Or through admin dashboard

Modify Quiz/Exam:
  - lib/modules.js (for module quizzes)
  - lib/examContent.js (for final exam)


TECHNICAL SPECIFICATIONS
========================

Backend:
  - Node.js v14+ with Express.js
  - SQLite3 database
  - EJS templating

Frontend:
  - Pure HTML/CSS (no framework)
  - Vanilla JavaScript
  - No build step required

Session:
  - express-session (in-memory)
  - Can be switched to store-based

PDF:
  - PDFKit library
  - Professional certificate generation

Email:
  - Nodemailer (optional)
  - Gmail, corporate SMTP supported


DATABASE SCHEMA
===============

agencies table:
  - id (INTEGER PRIMARY KEY)
  - name (TEXT)
  - code (TEXT UNIQUE)
  - created_at (DATETIME)

learners table:
  - id (INTEGER PRIMARY KEY)
  - agency_id (FOREIGN KEY)
  - name (TEXT)
  - email (TEXT)
  - started_at (DATETIME)
  - completed_at (DATETIME)
  - passed (BOOLEAN)
  - score_json (TEXT) - JSON of section scores
  - certificate_url (TEXT)

module_progress table:
  - id (INTEGER PRIMARY KEY)
  - learner_id (FOREIGN KEY)
  - module_num (INTEGER)
  - completed_at (DATETIME)
  - UNIQUE(learner_id, module_num)


SECURITY FEATURES
=================

Session Management:
  - express-session for learner authentication
  - Secure cookie handling
  - Session timeout (24 hours default)

Admin Protection:
  - Password-protected login
  - Admin middleware for dashboard routes

Exam Security:
  - Server-side scoring (answers never sent to client)
  - No correct answers exposed in responses
  - Section-by-section pass/fail evaluation
  - Score stored only after passing

No External Dependencies:
  - SQLite (embedded)
  - No external API calls
  - No CDN dependencies
  - Email is optional


FILE SIZES
==========

Total Project Size: ~188 KB

Large Files:
  - lib/modules.js        ~29 KB (12 modules with content)
  - lib/examContent.js    ~18 KB (19 sections with questions)
  - views/ (all)          ~48 KB (12 EJS templates)
  - public/css/style.css  ~37 KB (complete stylesheet)

Small Files:
  - lib/db.js             ~5.2 KB
  - lib/certificate.js    ~2.8 KB
  - routes/               ~12 KB (3 files)

Documentation:
  - README.md             ~3 KB
  - SETUP.md              ~7.4 KB
  - PROJECT_SUMMARY.md    ~8 KB


NEXT STEPS
==========

1. Verify all files exist (check this list)
2. Copy .env.example → .env
3. Edit .env with your configuration
4. Run: npm install
5. Run: npm start
6. Test with DEMO123 or TEST456
7. Access admin at http://localhost:3000/admin/login
8. Deploy to your server/hosting

For details, see SETUP.md

================================================================================
END OF FILE INDEX
================================================================================
