-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
623 lines (557 loc) · 23.1 KB
/
Copy pathserver.js
File metadata and controls
623 lines (557 loc) · 23.1 KB
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
const express = require('express');
const cors = require('cors');
const path = require('path');
const fs = require('fs').promises;
const app = express();
const PORT = process.env.PORT || 3000;
// Middleware
app.use(cors());
app.use(express.json());
app.use(express.static('.'));
// In-memory database (in production, use MongoDB/PostgreSQL)
let database = {
users: [],
courses: [],
pathways: [],
assessments: [],
opportunities: [],
certifications: [],
microCredentials: []
};
// AI-Powered Pathway Generation Engine
class PathwayAI {
constructor() {
this.skillWeights = {
programming: { demand: 0.9, growth: 0.85, salary: 0.9 },
design: { demand: 0.75, growth: 0.8, salary: 0.7 },
data: { demand: 0.95, growth: 0.9, salary: 0.95 },
business: { demand: 0.8, growth: 0.7, salary: 0.75 },
marketing: { demand: 0.7, growth: 0.75, salary: 0.65 }
};
this.learningStyles = {
visual: ['videos', 'infographics', 'diagrams', 'presentations'],
auditory: ['podcasts', 'lectures', 'discussions', 'interviews'],
kinesthetic: ['labs', 'projects', 'workshops', 'simulations'],
reading: ['articles', 'books', 'documentation', 'case-studies']
};
}
generatePersonalizedPathway(userProfile, assessmentResults, preferences) {
const pathway = {
id: `pathway_${Date.now()}`,
userId: userProfile.id,
title: this.generatePathwayTitle(userProfile, assessmentResults),
description: this.generatePathwayDescription(userProfile, assessmentResults),
duration: this.calculateOptimalDuration(userProfile, assessmentResults),
difficulty: this.determineDifficulty(assessmentResults),
personalizedScore: this.calculatePersonalizationScore(userProfile, assessmentResults),
phases: this.createLearningPhases(userProfile, assessmentResults, preferences),
recommendations: this.generateRecommendations(userProfile, assessmentResults),
opportunities: this.findRelevantOpportunities(userProfile, assessmentResults),
certifications: this.suggestCertifications(userProfile, assessmentResults),
microCredentials: this.suggestMicroCredentials(userProfile, assessmentResults),
adaptiveElements: this.createAdaptiveElements(userProfile, preferences),
successMetrics: this.defineSuccessMetrics(userProfile, assessmentResults),
created: new Date(),
lastUpdated: new Date()
};
return pathway;
}
generatePathwayTitle(userProfile, assessmentResults) {
const dominantSkill = this.findDominantSkill(assessmentResults);
const experience = this.determineExperienceLevel(assessmentResults);
const goal = userProfile.careerGoals || 'Professional Development';
const titles = {
programming: {
beginner: `Complete ${goal} Bootcamp: From Zero to Hero`,
intermediate: `Advanced ${goal} Mastery Program`,
expert: `${goal} Leadership & Architecture Track`
},
design: {
beginner: `Creative ${goal} Foundation Program`,
intermediate: `Professional ${goal} Specialization`,
expert: `${goal} Innovation & Strategy Track`
},
data: {
beginner: `Data Science Fundamentals for ${goal}`,
intermediate: `Advanced Analytics & ${goal} Program`,
expert: `AI/ML Leadership in ${goal}`
},
business: {
beginner: `Business Essentials for ${goal}`,
intermediate: `Strategic ${goal} Development`,
expert: `Executive ${goal} Leadership Program`
}
};
return titles[dominantSkill]?.[experience] || `Personalized ${goal} Learning Journey`;
}
generatePathwayDescription(userProfile, assessmentResults) {
const dominantSkill = this.findDominantSkill(assessmentResults);
const weakAreas = this.identifyWeakAreas(assessmentResults);
const strengths = this.identifyStrengths(assessmentResults);
return `A meticulously crafted learning journey designed specifically for your unique profile.
This pathway leverages your strengths in ${strengths.join(', ')} while strategically
addressing growth opportunities in ${weakAreas.join(', ')}. Built around ${dominantSkill}
excellence, this program adapts to your learning style and career aspirations, ensuring
maximum engagement and practical skill development.`;
}
createLearningPhases(userProfile, assessmentResults, preferences) {
const phases = [];
const dominantSkill = this.findDominantSkill(assessmentResults);
const experience = this.determineExperienceLevel(assessmentResults);
// Phase 1: Foundation Building
phases.push({
id: 1,
title: "Foundation Mastery",
duration: this.calculatePhaseDuration(experience, 'foundation'),
description: "Build rock-solid fundamentals tailored to your current skill level",
modules: this.generateFoundationModules(dominantSkill, experience, preferences),
assessments: this.generatePhaseAssessments('foundation', dominantSkill),
projects: this.generatePhaseProjects('foundation', dominantSkill, preferences),
resources: this.selectOptimalResources(dominantSkill, 'foundation', preferences.learningStyle)
});
// Phase 2: Skill Development
phases.push({
id: 2,
title: "Advanced Skill Development",
duration: this.calculatePhaseDuration(experience, 'development'),
description: "Deep-dive into specialized skills with hands-on practice",
modules: this.generateDevelopmentModules(dominantSkill, assessmentResults, preferences),
assessments: this.generatePhaseAssessments('development', dominantSkill),
projects: this.generatePhaseProjects('development', dominantSkill, preferences),
resources: this.selectOptimalResources(dominantSkill, 'development', preferences.learningStyle)
});
// Phase 3: Specialization & Mastery
phases.push({
id: 3,
title: "Specialization & Mastery",
duration: this.calculatePhaseDuration(experience, 'mastery'),
description: "Achieve expertise in your chosen specialization",
modules: this.generateMasteryModules(dominantSkill, userProfile.careerGoals, preferences),
assessments: this.generatePhaseAssessments('mastery', dominantSkill),
projects: this.generatePhaseProjects('mastery', dominantSkill, preferences),
resources: this.selectOptimalResources(dominantSkill, 'mastery', preferences.learningStyle)
});
// Phase 4: Real-World Application
phases.push({
id: 4,
title: "Professional Application",
duration: this.calculatePhaseDuration(experience, 'application'),
description: "Apply skills in real-world scenarios and build portfolio",
modules: this.generateApplicationModules(dominantSkill, userProfile, preferences),
assessments: this.generatePhaseAssessments('application', dominantSkill),
projects: this.generateCapstoneProjects(dominantSkill, userProfile, preferences),
resources: this.selectOptimalResources(dominantSkill, 'application', preferences.learningStyle)
});
return phases;
}
generateFoundationModules(skill, experience, preferences) {
const modules = {
programming: [
{
title: "Programming Fundamentals",
duration: "2 weeks",
type: "interactive",
difficulty: experience === 'beginner' ? 'easy' : 'medium',
content: ["Variables & Data Types", "Control Structures", "Functions", "Basic Algorithms"],
practiceHours: 20
},
{
title: "Development Environment Setup",
duration: "1 week",
type: "hands-on",
difficulty: 'easy',
content: ["IDE Configuration", "Version Control", "Debugging Tools", "Best Practices"],
practiceHours: 10
}
],
design: [
{
title: "Design Principles & Theory",
duration: "2 weeks",
type: "visual",
difficulty: experience === 'beginner' ? 'easy' : 'medium',
content: ["Color Theory", "Typography", "Layout Principles", "Visual Hierarchy"],
practiceHours: 15
},
{
title: "Design Tools Mastery",
duration: "2 weeks",
type: "hands-on",
difficulty: 'medium',
content: ["Figma/Adobe Suite", "Prototyping", "Asset Management", "Collaboration"],
practiceHours: 25
}
],
data: [
{
title: "Data Analysis Fundamentals",
duration: "3 weeks",
type: "analytical",
difficulty: experience === 'beginner' ? 'easy' : 'medium',
content: ["Statistics Basics", "Data Cleaning", "Visualization", "Interpretation"],
practiceHours: 30
},
{
title: "Tools & Technologies",
duration: "2 weeks",
type: "hands-on",
difficulty: 'medium',
content: ["Python/R Basics", "SQL", "Excel Advanced", "BI Tools"],
practiceHours: 20
}
]
};
return modules[skill] || [];
}
generateRecommendations(userProfile, assessmentResults) {
const recommendations = {
courses: this.recommendCourses(userProfile, assessmentResults),
books: this.recommendBooks(userProfile, assessmentResults),
communities: this.recommendCommunities(userProfile, assessmentResults),
mentors: this.recommendMentors(userProfile, assessmentResults),
tools: this.recommendTools(userProfile, assessmentResults),
events: this.recommendEvents(userProfile, assessmentResults)
};
return recommendations;
}
recommendCourses(userProfile, assessmentResults) {
const skill = this.findDominantSkill(assessmentResults);
const courses = {
programming: [
{
title: "Complete JavaScript Mastery 2024",
provider: "TechAcademy Pro",
rating: 4.9,
duration: "40 hours",
price: "$89",
level: "Intermediate",
matchScore: 98,
reasons: ["Matches your JavaScript interest", "Perfect for your experience level", "Highly rated by similar learners"]
},
{
title: "React Advanced Patterns",
provider: "Frontend Masters",
rating: 4.8,
duration: "25 hours",
price: "$39/month",
level: "Advanced",
matchScore: 95,
reasons: ["Builds on your React knowledge", "Industry-relevant patterns", "Practical projects included"]
}
],
design: [
{
title: "UX Design Comprehensive Course",
provider: "Design Institute",
rating: 4.9,
duration: "60 hours",
price: "$149",
level: "All Levels",
matchScore: 97,
reasons: ["Perfect for career transition", "Portfolio-focused", "Industry mentorship included"]
}
],
data: [
{
title: "Data Science with Python Specialization",
provider: "DataCamp Pro",
rating: 4.8,
duration: "80 hours",
price: "$29/month",
level: "Intermediate",
matchScore: 96,
reasons: ["Matches your Python skills", "Real-world datasets", "Industry-recognized certificate"]
}
]
};
return courses[skill] || [];
}
findDominantSkill(assessmentResults) {
let maxScore = 0;
let dominantSkill = 'programming';
Object.keys(assessmentResults).forEach(skill => {
const avgScore = Object.values(assessmentResults[skill]).reduce((a, b) => a + b, 0) / Object.values(assessmentResults[skill]).length;
if (avgScore > maxScore) {
maxScore = avgScore;
dominantSkill = skill;
}
});
return dominantSkill;
}
determineExperienceLevel(assessmentResults) {
const avgScore = Object.values(assessmentResults).flat().reduce((a, b) => a + b, 0) / Object.values(assessmentResults).flat().length;
if (avgScore < 2.5) return 'beginner';
if (avgScore < 3.5) return 'intermediate';
return 'expert';
}
calculatePersonalizationScore(userProfile, assessmentResults) {
// Complex algorithm to calculate how well-matched the pathway is
let score = 85; // Base score
// Boost for complete profile
if (userProfile.careerGoals) score += 5;
if (userProfile.timeCommitment) score += 3;
if (userProfile.learningStyle) score += 4;
if (userProfile.budget) score += 3;
return Math.min(score, 100);
}
identifyWeakAreas(assessmentResults) {
const weakAreas = [];
Object.keys(assessmentResults).forEach(skill => {
const avgScore = Object.values(assessmentResults[skill]).reduce((a, b) => a + b, 0) / Object.values(assessmentResults[skill]).length;
if (avgScore < 2.5) {
weakAreas.push(skill);
}
});
return weakAreas.length > 0 ? weakAreas : ['foundational concepts'];
}
identifyStrengths(assessmentResults) {
const strengths = [];
Object.keys(assessmentResults).forEach(skill => {
const avgScore = Object.values(assessmentResults[skill]).reduce((a, b) => a + b, 0) / Object.values(assessmentResults[skill]).length;
if (avgScore >= 4) {
strengths.push(skill);
}
});
return strengths.length > 0 ? strengths : ['analytical thinking'];
}
calculateOptimalDuration(userProfile, assessmentResults) {
const baseHours = 120; // Base learning hours
const experience = this.determineExperienceLevel(assessmentResults);
const timeCommitment = userProfile.timeCommitment || 10; // hours per week
let totalHours = baseHours;
if (experience === 'beginner') totalHours *= 1.5;
if (experience === 'expert') totalHours *= 0.8;
const weeks = Math.ceil(totalHours / timeCommitment);
return `${weeks} weeks (${totalHours} hours)`;
}
// Additional helper methods...
calculatePhaseDuration(experience, phase) {
const baseDurations = {
foundation: { beginner: 4, intermediate: 3, expert: 2 },
development: { beginner: 6, intermediate: 5, expert: 4 },
mastery: { beginner: 8, intermediate: 6, expert: 5 },
application: { beginner: 4, intermediate: 3, expert: 2 }
};
return `${baseDurations[phase][experience]} weeks`;
}
generatePhaseAssessments(phase, skill) {
return [
{
type: 'practical',
title: `${phase} Skills Assessment`,
duration: '2 hours',
weight: 0.4
},
{
type: 'project',
title: `${phase} Project Evaluation`,
duration: '1 week',
weight: 0.6
}
];
}
generatePhaseProjects(phase, skill, preferences) {
const projects = {
programming: {
foundation: ["Personal Portfolio Website", "Simple Calculator App"],
development: ["Full-Stack Web Application", "API Development Project"],
mastery: ["Advanced Framework Implementation", "Performance Optimization Project"],
application: ["Industry-Grade Application", "Open Source Contribution"]
}
};
return projects[skill]?.[phase] || [`${phase} Capstone Project`];
}
selectOptimalResources(skill, phase, learningStyle) {
// Return resources optimized for the user's learning style
return {
videos: 15,
articles: 8,
interactive: 12,
books: 3,
podcasts: 5
};
}
}
// Initialize AI Engine
const pathwayAI = new PathwayAI();
// API Routes
// Generate personalized learning pathway
app.post('/api/generate-pathway', async (req, res) => {
try {
const { userProfile, assessmentResults, preferences } = req.body;
// Validate input
if (!userProfile || !assessmentResults) {
return res.status(400).json({
error: 'Missing required data: userProfile and assessmentResults'
});
}
// Generate pathway using AI
const pathway = pathwayAI.generatePersonalizedPathway(
userProfile,
assessmentResults,
preferences || {}
);
// Save to database
database.pathways.push(pathway);
// Return the generated pathway
res.json({
success: true,
pathway: pathway,
message: "Your personalized learning pathway has been generated!"
});
} catch (error) {
console.error('Error generating pathway:', error);
res.status(500).json({
error: 'Failed to generate pathway',
details: error.message
});
}
});
// Get user's pathways
app.get('/api/pathways/:userId', (req, res) => {
const { userId } = req.params;
const userPathways = database.pathways.filter(p => p.userId === userId);
res.json({
success: true,
pathways: userPathways
});
});
// Save assessment results
app.post('/api/assessment/save', (req, res) => {
try {
const assessmentData = {
id: `assessment_${Date.now()}`,
...req.body,
timestamp: new Date()
};
database.assessments.push(assessmentData);
res.json({
success: true,
assessmentId: assessmentData.id,
message: "Assessment results saved successfully"
});
} catch (error) {
res.status(500).json({
error: 'Failed to save assessment',
details: error.message
});
}
});
// Get course recommendations
app.post('/api/recommendations/courses', (req, res) => {
try {
const { userProfile, assessmentResults } = req.body;
const recommendations = pathwayAI.recommendCourses(userProfile, assessmentResults);
res.json({
success: true,
recommendations
});
} catch (error) {
res.status(500).json({
error: 'Failed to get recommendations',
details: error.message
});
}
});
// Get learning opportunities
app.get('/api/opportunities', (req, res) => {
const opportunities = [
{
id: 1,
title: "Google Developer Student Club - Web Development Workshop",
type: "Workshop",
date: "2024-11-15",
location: "Online",
description: "Hands-on workshop covering modern web development practices",
skills: ["JavaScript", "React", "Node.js"],
level: "Intermediate",
duration: "4 hours",
price: "Free",
provider: "Google",
rating: 4.8,
spots: 50,
spotsLeft: 12
},
{
id: 2,
title: "AWS Cloud Practitioner Certification Bootcamp",
type: "Certification",
date: "2024-11-20",
location: "Hybrid",
description: "Intensive bootcamp to prepare for AWS Cloud Practitioner certification",
skills: ["Cloud Computing", "AWS", "Infrastructure"],
level: "Beginner",
duration: "2 days",
price: "$299",
provider: "AWS Training",
rating: 4.9,
certification: "AWS Certified Cloud Practitioner",
examIncluded: true
}
];
res.json({
success: true,
opportunities
});
});
// Get micro-credentials
app.get('/api/micro-credentials', (req, res) => {
const microCredentials = [
{
id: 1,
title: "JavaScript ES6+ Mastery Badge",
provider: "Mozilla Developer Network",
duration: "2 weeks",
effort: "3-5 hours/week",
skills: ["JavaScript", "ES6+", "Modern Syntax"],
level: "Intermediate",
price: "$49",
credentialType: "Digital Badge",
verification: "Blockchain verified",
acceptedBy: ["Google", "Microsoft", "Meta", "Netflix"],
completionRate: 89,
rating: 4.7
},
{
id: 2,
title: "UX Research Specialist Micro-Credential",
provider: "Nielsen Norman Group",
duration: "4 weeks",
effort: "4-6 hours/week",
skills: ["User Research", "Usability Testing", "Data Analysis"],
level: "Advanced",
price: "$199",
credentialType: "Professional Certificate",
verification: "Industry verified",
acceptedBy: ["Apple", "Airbnb", "Spotify", "Adobe"],
completionRate: 92,
rating: 4.9
}
];
res.json({
success: true,
microCredentials
});
});
// Health check
app.get('/api/health', (req, res) => {
res.json({
status: 'healthy',
timestamp: new Date(),
pathways: database.pathways.length,
assessments: database.assessments.length
});
});
// Serve the main application
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
// Start server
app.listen(PORT, () => {
console.log(`🚀 Wayforge Backend Server running on port ${PORT}`);
console.log(`🤖 AI-Powered Pathway Generation: ACTIVE`);
console.log(`📊 Real-time Analytics: ENABLED`);
console.log(`🎯 Personalization Engine: OPTIMIZED`);
console.log(`\n🌟 Ready to create mind-blowing learning experiences!`);
});
module.exports = app;