-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
642 lines (576 loc) · 32.9 KB
/
Copy pathapp.py
File metadata and controls
642 lines (576 loc) · 32.9 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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
import os
from flask import Flask, jsonify, render_template_string, request
from routine_engine import match_routine, NEIGHBORHOOD_DATABASE
app = Flask(__name__)
HTML_TEMPLATE = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RoutineMatch - Find Your Equivalent Neighborhood & Routine</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');
body { font-family: 'Plus Jakarta Sans', sans-serif; }
.glass-card { background: rgba(30, 41, 59, 0.85); backdrop-filter: blur(16px); border: 1px solid rgba(255, 255, 255, 0.1); }
.gradient-hero { background: radial-gradient(circle at 50% 0%, #1e40af 0%, #0f172a 75%); }
.gradient-brand { background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%); }
.card-radio:checked + div { border-color: #3b82f6; background-color: rgba(59, 130, 246, 0.15); }
.card-checkbox:checked + div { border-color: #8b5cf6; background-color: rgba(139, 92, 246, 0.18); }
</style>
</head>
<body class="bg-slate-950 text-slate-100 min-h-screen flex flex-col antialiased selection:bg-blue-500 selection:text-white">
<!-- Navigation Header -->
<header class="border-b border-slate-800/80 bg-slate-900/80 backdrop-blur-md sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-6 py-4 flex justify-between items-center">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-xl gradient-brand flex items-center justify-center text-white shadow-lg shadow-blue-500/20">
<i class="fa-solid fa-route text-lg"></i>
</div>
<div>
<h1 class="text-xl font-extrabold tracking-tight text-white flex items-center gap-2">
RoutineMatch <span class="text-[10px] uppercase tracking-wider bg-blue-500/20 text-blue-400 border border-blue-500/30 px-2 py-0.5 rounded-full font-bold">DevFest MVP</span>
</h1>
<p class="text-xs text-slate-400 font-medium">Relocation & Lifestyle Routine Matching Engine</p>
</div>
</div>
<div class="flex items-center gap-3 text-xs">
<button onclick="resetWizard()" class="px-3.5 py-2 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 transition flex items-center gap-2 border border-slate-700 font-semibold">
<i class="fa-solid fa-arrow-rotate-left"></i> New Match
</button>
<span class="hidden md:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-purple-500/10 text-purple-300 border border-purple-500/20 font-semibold">
<i class="fa-solid fa-code"></i> Code With Me
</span>
</div>
</div>
</header>
<!-- Hero Section -->
<div class="gradient-hero py-12 px-6 border-b border-slate-800/60 text-center">
<div class="max-w-3xl mx-auto space-y-3">
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-blue-500/10 border border-blue-400/20 text-blue-400 text-xs font-semibold">
<i class="fa-solid fa-sparkles"></i> Quantitative Geospatial Routine Matching
</div>
<h2 class="text-3xl md:text-4xl font-extrabold text-white tracking-tight">
Move to a new city without changing your <span class="text-transparent bg-clip-text gradient-brand">daily routine</span>.
</h2>
<p class="text-sm md:text-base text-slate-400 max-w-2xl mx-auto">
Answer 5 quick lifestyle questions. Our 8D vector cosine engine pairs you with equivalent target neighborhoods and the exact local coffee shops, gyms, markets, and social spots to fit your lifestyle.
</p>
<!-- Team Attribution Badge -->
<div class="pt-2">
<span class="inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full bg-slate-900/80 border border-slate-700/80 text-xs text-slate-300 shadow-sm">
<i class="fa-solid fa-users-gear text-pink-400"></i> Built by <strong class="text-white">Team People (w)Ho Devfest</strong>: Shijit, Erik, Azmain, Bilgehan • Associated with <strong class="text-blue-400">Code With Me Meetup</strong>
</span>
</div>
</div>
</div>
<!-- Main Container -->
<main class="max-w-7xl mx-auto p-6 md:p-8 flex-1 w-full space-y-12">
<!-- QUESTIONNAIRE WIZARD -->
<section id="wizard-container" class="max-w-3xl mx-auto glass-card rounded-3xl p-6 md:p-10 shadow-2xl border border-slate-800">
<!-- Progress Bar -->
<div class="mb-8">
<div class="flex justify-between items-center text-xs font-bold text-slate-400 mb-2">
<span id="stepIndicator">STEP 1 OF 5: RELOCATION ROUTE</span>
<span id="progressPercent">20% COMPLETED</span>
</div>
<div class="w-full h-2 bg-slate-800 rounded-full overflow-hidden">
<div id="progressBar" class="h-full gradient-brand w-1/5 transition-all duration-300"></div>
</div>
</div>
<!-- FORM WIZARD -->
<form id="routineForm" onsubmit="submitSurvey(event)">
<!-- STEP 1: CITIES (Where you live & where you're moving) -->
<div id="step-1" class="wizard-step space-y-6">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fa-solid fa-location-dot text-blue-400"></i> Where are you relocating from and to?
</h3>
<p class="text-xs text-slate-400 mt-1">Select your current city and your target destination city.</p>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
<div>
<label class="block text-xs font-bold uppercase tracking-wider text-slate-400 mb-2">Current City (Where you live)</label>
<select id="sourceCity" class="w-full bg-slate-900 border border-slate-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500">
<option value="NYC">New York City (NYC)</option>
<option value="DC" selected>Washington, DC</option>
<option value="Baltimore">Baltimore, MD</option>
<option value="Philadelphia">Philadelphia, PA</option>
<option value="Boston">Boston, MA</option>
<option value="Atlanta">Atlanta, GA</option>
<option value="Arlington">Arlington, VA</option>
<option value="Bethesda">Bethesda, MD</option>
</select>
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-wider text-slate-400 mb-2">Target City (Moving To)</label>
<select id="targetCity" class="w-full bg-slate-900 border border-slate-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500">
<option value="NYC" selected>New York City (NYC)</option>
<option value="DC">Washington, DC</option>
<option value="Baltimore">Baltimore, MD</option>
<option value="Philadelphia">Philadelphia, PA</option>
<option value="Boston">Boston, MA</option>
<option value="Atlanta">Atlanta, GA</option>
<option value="Arlington">Arlington, VA</option>
<option value="Bethesda">Bethesda, MD</option>
</select>
</div>
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-wider text-slate-400 mb-2">Favorite Current Neighborhood / Anchor (Optional)</label>
<input type="text" id="anchorNeighborhood" placeholder="e.g. Dupont Circle, Williamsburg, Fells Point, Rittenhouse" class="w-full bg-slate-900 border border-slate-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500 placeholder-slate-600">
</div>
</div>
<!-- STEP 2: COMMUTE & TRANSIT -->
<div id="step-2" class="wizard-step hidden space-y-6">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fa-solid fa-train-subway text-cyan-400"></i> Commute & Daily Transit Mode
</h3>
<p class="text-xs text-slate-400 mt-1">How do you prefer to get around, and what is your work cadence?</p>
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-wider text-slate-400 mb-3">Primary Transit Mode</label>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-3">
<label class="cursor-pointer relative">
<input type="radio" name="transit_mode" value="walk_bike" checked class="sr-only card-radio">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition text-center space-y-2">
<i class="fa-solid fa-person-walking text-2xl text-emerald-400"></i>
<p class="text-xs font-bold text-white">Walk & Bike</p>
<p class="text-[10px] text-slate-400">High walkability & bike paths</p>
</div>
</label>
<label class="cursor-pointer relative">
<input type="radio" name="transit_mode" value="transit" class="sr-only card-radio">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition text-center space-y-2">
<i class="fa-solid fa-subway text-2xl text-blue-400"></i>
<p class="text-xs font-bold text-white">Public Transit</p>
<p class="text-[10px] text-slate-400">Subway, Metro & Express bus</p>
</div>
</label>
<label class="cursor-pointer relative">
<input type="radio" name="transit_mode" value="car" class="sr-only card-radio">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition text-center space-y-2">
<i class="fa-solid fa-car text-2xl text-amber-400"></i>
<p class="text-xs font-bold text-white">Car / Driving</p>
<p class="text-[10px] text-slate-400">Easy parking & highway access</p>
</div>
</label>
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5 pt-2">
<div>
<label class="block text-xs font-bold uppercase tracking-wider text-slate-400 mb-2">Work Setup</label>
<select id="workRoutine" class="w-full bg-slate-900 border border-slate-700 rounded-xl px-4 py-3 text-sm text-white focus:outline-none focus:border-blue-500">
<option value="wfh" selected>Remote / Work From Home (WFH)</option>
<option value="hybrid">Hybrid (2-3 days in office)</option>
<option value="office">Daily Office Commuter</option>
</select>
</div>
<div>
<div class="flex justify-between items-center mb-2">
<label class="text-xs font-bold uppercase tracking-wider text-slate-400">Max Commute Tolerance</label>
<span id="commuteVal" class="text-xs font-extrabold text-blue-400 font-mono">25 mins</span>
</div>
<input type="range" id="maxCommute" min="10" max="60" value="25" step="5" oninput="document.getElementById('commuteVal').innerText = this.value + ' mins'" class="w-full accent-blue-500 bg-slate-800">
</div>
</div>
</div>
<!-- STEP 3: EXERCISE & OUTDOORS -->
<div id="step-3" class="wizard-step hidden space-y-6">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fa-solid fa-dumbbell text-emerald-400"></i> Exercise & Outdoors Routine
</h3>
<p class="text-xs text-slate-400 mt-1">Select all activities that are part of your fitness routine.</p>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<label class="cursor-pointer relative">
<input type="checkbox" name="exercise" value="gym" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-emerald-500/20 text-emerald-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-dumbbell"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Gym & Fitness Studios</p>
<p class="text-xs text-slate-400">Equinox, Barry's, CrossFit, Pilates</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="exercise" value="trails" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-teal-500/20 text-teal-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-person-biking"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Running & Bike Trails</p>
<p class="text-xs text-slate-400">Paved trails, riverways, BeltLine</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="exercise" value="dog_park" class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-green-500/20 text-green-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-dog"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Dog Parks & Green Squares</p>
<p class="text-xs text-slate-400">Off-leash parks & shaded plazas</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="exercise" value="strolls" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-blue-500/20 text-blue-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-shoe-prints"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Casual Strolls & Waterfronts</p>
<p class="text-xs text-slate-400">Pedestrian boardwalks & tree-lined streets</p>
</div>
</div>
</label>
</div>
</div>
<!-- STEP 4: ENTERTAINMENT & SOCIAL -->
<div id="step-4" class="wizard-step hidden space-y-6">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fa-solid fa-martini-glass text-violet-400"></i> Entertainment & Social Habits
</h3>
<p class="text-xs text-slate-400 mt-1">What places make up your regular weekly third-places and social outings?</p>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3.5">
<label class="cursor-pointer relative">
<input type="checkbox" name="social" value="coffee" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-amber-500/20 text-amber-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-mug-hot"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Third-Wave Coffee & Cafes</p>
<p class="text-xs text-slate-400">Artisan roasters & work-friendly cafes</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="social" value="pubs" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-purple-500/20 text-purple-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-beer-mug-empty"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Breweries & Cocktail Lounges</p>
<p class="text-xs text-slate-400">Craft taprooms, speakeasies & patios</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="social" value="dining" checked class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-rose-500/20 text-rose-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-utensils"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Foodie Dining & Markets</p>
<p class="text-xs text-slate-400">Food halls, international cuisine, organic grocers</p>
</div>
</div>
</label>
<label class="cursor-pointer relative">
<input type="checkbox" name="social" value="arts" class="sr-only card-checkbox">
<div class="p-4 rounded-xl border border-slate-700 bg-slate-900/60 hover:bg-slate-800 transition flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-indigo-500/20 text-indigo-400 flex items-center justify-center shrink-0">
<i class="fa-solid fa-masks-theater"></i>
</div>
<div>
<p class="text-sm font-bold text-white">Live Music, Arts & Indie Cinema</p>
<p class="text-xs text-slate-400">Venues, indie bookstores & galleries</p>
</div>
</div>
</label>
</div>
</div>
<!-- STEP 5: NOISE & ENERGY LEVEL -->
<div id="step-5" class="wizard-step hidden space-y-6">
<div>
<h3 class="text-xl font-bold text-white flex items-center gap-2">
<i class="fa-solid fa-bolt text-amber-400"></i> Lifestyle Energy & Noise Preference
</h3>
<p class="text-xs text-slate-400 mt-1">What neighborhood vibe feels most like home to you?</p>
</div>
<div class="space-y-4">
<div class="flex justify-between items-center">
<span class="text-xs font-bold uppercase tracking-wider text-slate-400">Target Vibe</span>
<span id="energyLabel" class="text-xs font-extrabold text-amber-400 bg-amber-500/20 px-2.5 py-1 rounded-full border border-amber-500/30">Active & Lively (4/5)</span>
</div>
<input type="range" id="energyLevel" min="1" max="5" value="4" step="1" oninput="updateEnergyLabel(this.value)" class="w-full accent-amber-500 bg-slate-800">
<div class="flex justify-between text-[11px] text-slate-400 font-semibold px-1">
<span>1: Quiet & Village-like</span>
<span>3: Balanced Neighborhood</span>
<span>5: High Energy Epicenter</span>
</div>
</div>
<div class="p-4 bg-slate-900/80 rounded-2xl border border-slate-800 text-xs text-slate-300 space-y-1">
<p class="font-bold text-white flex items-center gap-1.5"><i class="fa-solid fa-circle-check text-emerald-400"></i> Ready to Calculate Vector Match</p>
<p class="text-slate-400">Our engine will execute cosine similarity against target city centroids weighted by commute penalty & noise tolerance.</p>
</div>
</div>
<!-- Navigation Buttons -->
<div class="flex justify-between items-center pt-8 border-t border-slate-800">
<button type="button" id="prevBtn" onclick="prevStep()" class="hidden px-5 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300 text-sm font-semibold transition">
<i class="fa-solid fa-arrow-left mr-1.5"></i> Back
</button>
<div class="ml-auto flex gap-3">
<button type="button" id="nextBtn" onclick="nextStep()" class="px-6 py-2.5 rounded-xl bg-blue-600 hover:bg-blue-500 text-white text-sm font-bold transition shadow-lg shadow-blue-600/30 flex items-center gap-2">
Next <i class="fa-solid fa-arrow-right"></i>
</button>
<button type="submit" id="submitBtn" class="hidden px-8 py-2.5 rounded-xl gradient-brand text-white text-sm font-extrabold transition shadow-lg shadow-purple-500/30 flex items-center gap-2">
<i class="fa-solid fa-wand-magic-sparkles"></i> Find My Routine Match
</button>
</div>
</div>
</form>
</section>
<!-- RESULTS SECTION -->
<section id="results-section" class="hidden space-y-8">
<!-- Results Banner -->
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4 bg-slate-900 border border-slate-800 p-6 rounded-3xl">
<div>
<span class="text-xs uppercase tracking-wider font-extrabold text-blue-400 bg-blue-500/10 px-3 py-1 rounded-full border border-blue-500/20">Vector Match Results</span>
<h2 class="text-2xl font-extrabold text-white mt-2">
Top Neighborhood Matches in <span id="resTargetCity" class="text-blue-400">NYC</span>
</h2>
<p class="text-xs text-slate-400">Ranked by 8D cosine similarity to your routine in <span id="resSourceCity" class="text-slate-300 font-semibold">DC</span>.</p>
</div>
<button onclick="document.getElementById('wizard-container').scrollIntoView({behavior: 'smooth'})" class="px-4 py-2 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl text-xs font-semibold border border-slate-700 transition flex items-center gap-2">
<i class="fa-solid fa-sliders"></i> Modify Routine
</button>
</div>
<!-- Neighborhood Cards Grid -->
<div id="resultsGrid" class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Rendered dynamically -->
</div>
</section>
</main>
<!-- Footer with Team Attribution -->
<footer class="bg-slate-950 border-t border-slate-800 py-8 px-6 text-center space-y-3">
<div class="max-w-4xl mx-auto space-y-2">
<p class="text-sm font-bold text-slate-200 flex items-center justify-center gap-2">
<i class="fa-solid fa-code text-blue-400"></i> Built by <span class="text-transparent bg-clip-text gradient-brand font-extrabold">Team People (w)Ho Devfest</span>: Shijit, Erik, Azmain, Bilgehan
</p>
<p class="text-xs text-slate-400">
Associated with <strong class="text-blue-300">Code With Me Meetup</strong> • RoutineMatch MVP
</p>
<p class="text-[11px] text-slate-600">
Geospatial Vector Matching Engine • Powered by Google Cloud Platform
</p>
</div>
</footer>
<script>
let currentStep = 1;
const totalSteps = 5;
function updateStepUI() {
// Hide all steps
for (let i = 1; i <= totalSteps; i++) {
const el = document.getElementById(`step-${i}`);
if (el) el.classList.add('hidden');
}
// Show current step
document.getElementById(`step-${currentStep}`).classList.remove('hidden');
// Update progress bar
const pct = (currentStep / totalSteps) * 100;
document.getElementById('progressBar').style.width = `${pct}%`;
document.getElementById('progressPercent').innerText = `${Math.round(pct)}% COMPLETED`;
const titles = [
"STEP 1 OF 5: RELOCATION ROUTE",
"STEP 2 OF 5: COMMUTE & TRANSIT",
"STEP 3 OF 5: EXERCISE & OUTDOORS",
"STEP 4 OF 5: ENTERTAINMENT & SOCIAL",
"STEP 5 OF 5: LIFESTYLE & ENERGY LEVEL"
];
document.getElementById('stepIndicator').innerText = titles[currentStep - 1];
// Buttons
document.getElementById('prevBtn').classList.toggle('hidden', currentStep === 1);
document.getElementById('nextBtn').classList.toggle('hidden', currentStep === totalSteps);
document.getElementById('submitBtn').classList.toggle('hidden', currentStep !== totalSteps);
}
function nextStep() {
if (currentStep < totalSteps) {
currentStep++;
updateStepUI();
}
}
function prevStep() {
if (currentStep > 1) {
currentStep--;
updateStepUI();
}
}
function resetWizard() {
currentStep = 1;
updateStepUI();
document.getElementById('results-section').classList.add('hidden');
document.getElementById('wizard-container').classList.remove('hidden');
document.getElementById('wizard-container').scrollIntoView({behavior: 'smooth'});
}
function updateEnergyLabel(val) {
const labels = {
"1": "Very Quiet & Village-like (1/5)",
"2": "Calm & Residential (2/5)",
"3": "Balanced Neighborhood (3/5)",
"4": "Active & Lively (4/5)",
"5": "High Energy Epicenter (5/5)"
};
document.getElementById('energyLabel').innerText = labels[val] || `${val}/5`;
}
async function submitSurvey(e) {
e.preventDefault();
const submitBtn = document.getElementById('submitBtn');
submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Calculating Match...';
// Gather answers
const sourceCity = document.getElementById('sourceCity').value;
const targetCity = document.getElementById('targetCity').value;
const anchor = document.getElementById('anchorNeighborhood').value;
const transitMode = document.querySelector('input[name="transit_mode"]:checked')?.value || 'transit';
const workRoutine = document.getElementById('workRoutine').value;
const maxCommute = document.getElementById('maxCommute').value;
const exerciseHabits = Array.from(document.querySelectorAll('input[name="exercise"]:checked')).map(el => el.value);
const socialHabits = Array.from(document.querySelectorAll('input[name="social"]:checked')).map(el => el.value);
const energyLevel = document.getElementById('energyLevel').value;
const payload = {
source_city: sourceCity,
target_city: targetCity,
anchor_neighborhood: anchor,
transit_mode: transitMode,
work_routine: workRoutine,
max_commute: maxCommute,
exercise_habits: exerciseHabits,
social_habits: socialHabits,
energy_level: energyLevel
};
try {
const res = await fetch('/api/v1/match', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const matches = await res.json();
renderMatches(matches, sourceCity, targetCity);
} catch (err) {
alert("Error running matching engine: " + err.message);
} finally {
submitBtn.disabled = false;
submitBtn.innerHTML = '<i class="fa-solid fa-wand-magic-sparkles"></i> Find My Routine Match';
}
}
function renderMatches(matches, sourceCity, targetCity) {
document.getElementById('resTargetCity').innerText = targetCity;
document.getElementById('resSourceCity').innerText = sourceCity;
const grid = document.getElementById('resultsGrid');
grid.innerHTML = '';
matches.forEach((item, idx) => {
const card = document.createElement('div');
card.className = "glass-card rounded-3xl p-6 md:p-7 shadow-xl border border-slate-800 space-y-5 hover:border-slate-700 transition flex flex-col justify-between";
// Match score color
let scoreBg = "bg-emerald-500/20 text-emerald-300 border-emerald-500/40";
if (item.match_score < 80) scoreBg = "bg-blue-500/20 text-blue-300 border-blue-500/40";
if (item.match_score < 65) scoreBg = "bg-amber-500/20 text-amber-300 border-amber-500/40";
// Store HTML
let storesHtml = '';
if (item.matched_stores && item.matched_stores.length > 0) {
storesHtml = `
<div class="mt-4 pt-4 border-t border-slate-800">
<p class="text-xs font-bold text-slate-300 uppercase tracking-wider mb-3 flex items-center gap-1.5">
<i class="fa-solid fa-store text-blue-400"></i> Routine-Matched Stores & Venues
</p>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
${item.matched_stores.map(s => `
<div class="p-2.5 bg-slate-900/90 rounded-xl border border-slate-800 flex items-start gap-2.5">
<span class="p-2 bg-blue-500/10 text-blue-400 rounded-lg text-xs shrink-0 mt-0.5"><i class="fa-solid ${s.icon}"></i></span>
<div class="overflow-hidden">
<p class="text-[10px] font-semibold text-slate-400 uppercase truncate">${s.category}</p>
<p class="text-xs font-bold text-white truncate" title="${s.name}">${s.name}</p>
</div>
</div>
`).join('')}
</div>
</div>
`;
}
card.innerHTML = `
<div>
<div class="flex justify-between items-start gap-3 mb-2">
<div>
<span class="text-[10px] font-bold text-slate-400 uppercase tracking-wider">${item.borough_district} • ${item.city}</span>
<h3 class="text-2xl font-extrabold text-white mt-0.5">${item.name}</h3>
<span class="inline-block text-xs text-blue-400 bg-blue-500/10 px-2.5 py-0.5 rounded-full mt-1 border border-blue-500/20 font-semibold">${item.vibe}</span>
</div>
<div class="text-right shrink-0">
<div class="px-3.5 py-1.5 rounded-2xl border text-center ${scoreBg}">
<span class="text-xl font-black">${item.match_score}%</span>
<span class="block text-[9px] uppercase tracking-wider font-extrabold">Routine Match</span>
</div>
</div>
</div>
<p class="text-xs text-slate-300 mt-3 leading-relaxed">${item.description}</p>
<!-- Key metrics pills -->
<div class="grid grid-cols-3 gap-2 mt-4 text-center">
<div class="p-2 bg-slate-900/60 rounded-xl border border-slate-800/80">
<span class="block text-[10px] text-slate-400 uppercase font-semibold">Commute</span>
<span class="text-xs font-extrabold text-white">~${item.commute_mins} mins</span>
</div>
<div class="p-2 bg-slate-900/60 rounded-xl border border-slate-800/80">
<span class="block text-[10px] text-slate-400 uppercase font-semibold">Walkability</span>
<span class="text-xs font-extrabold text-emerald-400">${item.dimension_breakdown.Walkability}/100</span>
</div>
<div class="p-2 bg-slate-900/60 rounded-xl border border-slate-800/80">
<span class="block text-[10px] text-slate-400 uppercase font-semibold">Activity Vibe</span>
<span class="text-xs font-extrabold text-amber-400">${item.activity_level}/5 Level</span>
</div>
</div>
${storesHtml}
</div>
`;
grid.appendChild(card);
});
document.getElementById('results-section').classList.remove('hidden');
document.getElementById('results-section').scrollIntoView({behavior: 'smooth'});
}
// Init
updateStepUI();
</script>
</body>
</html>
"""
@app.route("/")
def home():
return render_template_string(HTML_TEMPLATE)
@app.route("/api/v1/match", methods=["POST"])
def api_match():
try:
data = request.get_json() or {}
matches = match_routine(data)
return jsonify(matches)
except Exception as e:
return jsonify({"error": str(e)}), 500
@app.route("/api/v1/neighborhoods", methods=["GET"])
def api_neighborhoods():
city = request.args.get("city")
if city:
filtered = [n for n in NEIGHBORHOOD_DATABASE if n["city"].lower() == city.lower()]
return jsonify(filtered)
return jsonify(NEIGHBORHOOD_DATABASE)
@app.route("/api/v1/cities", methods=["GET"])
def api_cities():
cities = list(set(n["city"] for n in NEIGHBORHOOD_DATABASE))
return jsonify(sorted(cities))
if __name__ == "__main__":
port = int(os.getenv("PORT", 8080))
app.run(host="0.0.0.0", port=port, debug=False)