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
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
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
const logger = require('../utils/logger');
const { redisUtils } = require('../utils/redis');

class KnowledgeBaseService {
  constructor() {
    this.ugaKnowledgeBase = this.initializeUGAKnowledge();
    this.athensKnowledgeBase = this.initializeAthensKnowledge();
    this.studentLifeKnowledge = this.initializeStudentLifeKnowledge();
  }

  initializeUGAKnowledge() {
    return {
      // University Overview
      overview: {
        founded: 1785,
        type: 'Public Research University',
        motto: 'To teach, to serve, and to inquire into the nature of things',
        mascot: 'Hairy Dawg (English Bulldog)',
        colors: ['Red', 'Black'],
        nickname: 'Bulldogs',
        enrollment: '39,000+ students',
        campusSize: '762 acres',
        ranking: 'Top 20 public university',
        president: 'Jere Morehead',
        established: 'First state-chartered university in the United States'
      },

      // Academic Structure
      academics: {
        colleges: [
          {
            name: 'Franklin College of Arts and Sciences',
            dean: 'Departmental structure varies',
            programs: ['Liberal Arts', 'Sciences', 'Mathematics', 'English', 'History', 'Psychology'],
            notable: 'Largest college at UGA'
          },
          {
            name: 'Terry College of Business',
            programs: ['Accounting', 'Finance', 'Management', 'Marketing', 'Real Estate'],
            ranking: 'Top-ranked business school',
            facilities: ['Correll Hall', 'Brooks Hall']
          },
          {
            name: 'College of Engineering',
            programs: ['Aerospace', 'Agricultural', 'Biological', 'Chemical', 'Civil', 'Computer Science', 'Electrical', 'Environmental'],
            facilities: ['Driftmier Engineering Center', 'Boyd Graduate Studies Research Center']
          },
          {
            name: 'College of Education',
            programs: ['Elementary Education', 'Secondary Education', 'Special Education', 'Educational Psychology'],
            facilities: ['Aderhold Hall', 'River\'s Crossing']
          },
          {
            name: 'College of Journalism and Mass Communication',
            programs: ['Journalism', 'Advertising', 'Public Relations', 'Digital Media'],
            ranking: 'Top journalism school nationally',
            facilities: ['Grady College Building']
          },
          {
            name: 'College of Agricultural and Environmental Sciences',
            programs: ['Agriculture', 'Environmental Science', 'Food Science', 'Landscape Architecture'],
            facilities: ['Conner Hall', 'Food Science Building']
          },
          {
            name: 'College of Veterinary Medicine',
            programs: ['Doctor of Veterinary Medicine', 'Veterinary Technology'],
            ranking: 'Top veterinary school',
            facilities: ['Veterinary Medicine Complex']
          },
          {
            name: 'College of Pharmacy',
            programs: ['Doctor of Pharmacy', 'Pharmaceutical Sciences'],
            facilities: ['Pharmacy South Building']
          },
          {
            name: 'School of Law',
            programs: ['Juris Doctor', 'Master of Laws'],
            ranking: 'Highly ranked law school',
            facilities: ['Hirsch Hall', 'Rusk Hall']
          },
          {
            name: 'College of Public Health',
            programs: ['Public Health', 'Epidemiology', 'Health Policy'],
            facilities: ['Health Sciences Campus']
          },
          {
            name: 'School of Social Work',
            programs: ['Bachelor of Social Work', 'Master of Social Work'],
            facilities: ['Tucker Hall']
          },
          {
            name: 'College of Family and Consumer Sciences',
            programs: ['Human Development', 'Nutrition', 'Fashion Merchandising'],
            facilities: ['Dawson Hall']
          }
        ],

        semesterSystem: {
          fall: 'August - December',
          spring: 'January - May', 
          summer: 'May - August',
          maymester: 'May intensive session',
          winterSession: 'December/January short courses'
        },

        graduationRequirements: {
          undergraduate: {
            totalHours: 120,
            coreRequirements: 'Areas A-F (42 hours)',
            majorRequirements: 'Varies by program (30-60 hours)',
            electiveHours: 'Remaining hours',
            residencyRequirement: '30 hours at UGA',
            gpaRequirement: '2.0 minimum'
          }
        },

        honors: {
          honorsProgram: 'Honors Program for high-achieving students',
          foundationFellows: 'Premier scholarship program',
            ramseyScholars: 'Leadership and service scholarship',
          bernardRamseyHonorsScholarship: 'Full-ride academic scholarship'
        }
      },

      // Campus Facilities
      facilities: {
        libraries: [
          {
            name: 'University of Georgia Libraries',
            mainLibrary: 'Main Library',
            specialLibraries: [
              'Miller Learning Center (MLC)',
              'Science Library', 
              'Law Library',
              'Veterinary Medicine Library',
              'Map and Government Information Library'
            ],
            services: ['Research assistance', 'Interlibrary loans', 'Study spaces', 'Computer labs', 'Printing services'],
            hours: 'Varies by location, some 24/7 during semester'
          }
        ],

        recreation: {
          ramseyCenter: {
            name: 'Ramsey Student Center',
            facilities: [
              'Fitness equipment and weights',
              '25-yard swimming pool',
              'Basketball courts',
              'Racquetball courts', 
              'Rock climbing wall',
              'Group fitness studios',
              'Outdoor recreation equipment rental'
            ],
            hours: 'M-F: 5:30 AM - 12:00 AM, weekends vary',
            programs: ['Group fitness classes', 'Intramural sports', 'Personal training']
          },
          outdoorRecreation: {
            programs: ['Hiking trips', 'Camping', 'Kayaking', 'Rock climbing'],
            equipment: 'Rental equipment available'
          }
        },

        studentCenters: {
          tasteCenter: {
            name: 'Tate Student Center',
            services: ['Dining', 'Bookstore', 'Student organizations', 'Event spaces'],
            dining: ['Food court', 'Restaurants', 'Starbucks']
          }
        },

        technology: {
          wifi: 'UGA-WiFi available campus-wide',
          computerLabs: 'Available in MLC, libraries, and academic buildings',
          printing: 'PawPrints system for printing',
          software: 'Free software available to students'
        }
      },

      // Athletics
      athletics: {
        conference: 'Southeastern Conference (SEC)',
        colors: 'Red and Black',
        mascot: 'Uga (English Bulldog lineage)',
        fightSong: 'Hail to Georgia',
        venues: {
          football: 'Sanford Stadium (capacity: 92,746)',
          basketball: 'Stegeman Coliseum',
          baseball: 'Foley Field',
          soccer: 'Turner Soccer Complex',
          tennis: 'Dan Magill Tennis Complex',
          golf: 'University of Georgia Golf Course'
        },
        traditions: [
          'The Dawg Walk',
          'Calling the Dawgs',
          'Between the Hedges (Sanford Stadium)',
          'The Georgia-Florida game (World\'s Largest Outdoor Cocktail Party)',
          'Clean, Old-Fashioned Hate (Georgia vs. Georgia Tech)'
        ],
        championships: {
          football: ['1942', '1980', '2021 National Champions'],
          baseball: 'Multiple College World Series appearances',
          gymnastics: 'Multiple national championships',
          tennis: 'Multiple national championships'
        }
      },

      // Student Organizations
      studentLife: {
        greekLife: {
          ifcChapters: 30,
          panhellenicChapters: 25,
          nphcChapters: 9,
          multiculturalChapters: 15,
          participation: 'About 25% of students'
        },
        studentOrganizations: {
          total: '600+ organizations',
          categories: [
            'Academic and Professional',
            'Cultural and Ethnic',
            'Religious and Spiritual', 
            'Service and Philanthropy',
            'Sports and Recreation',
            'Arts and Performance',
            'Special Interest',
            'Student Government'
          ]
        },
        traditions: [
          'Ring Ceremony',
          'Homecoming',
          'SpringFest',
          'Dawg Days (orientation)',
          'Arch ceremonies'
        ]
      },

      // Notable Programs
      notablePrograms: {
        studyAbroad: {
          programs: '100+ programs in 50+ countries',
          notable: ['Costa Rica', 'Oxford', 'Cortona Italy', 'Ramallah']
        },
        research: {
          status: 'R1: Doctoral Universities – Very High Research Activity',
          opportunities: 'Undergraduate research opportunities available',
          centers: ['Center for Undergraduate Research Opportunities (CURO)']
        },
        sustainability: {
          initiatives: ['Campus sustainability', 'LEED certified buildings', 'Recycling programs'],
          rating: 'Green campus designation'
        }
      },

      // Campus Landmarks
      landmarks: [
        {
          name: 'The Arch',
          significance: 'Iconic entrance to North Campus',
          tradition: 'Students traditionally don\'t walk under it until graduation'
        },
        {
          name: 'Chapel Bell',
          significance: 'Historic bell tower',
          tradition: 'Rings after football victories'
        },
        {
          name: 'Sanford Stadium',
          significance: '92,746 capacity football stadium',
          nickname: 'Between the Hedges'
        },
        {
          name: 'North Campus',
          significance: 'Historic heart of campus',
          features: ['The Arch', 'Old College', 'Chapel']
        },
        {
          name: 'State Botanical Garden',
          significance: '313-acre botanical garden',
          features: ['Visitor Center', 'Conservatory', 'Nature trails']
        }
      ],

      // Academic Calendar Key Dates
      importantDates: {
        fall2024: {
          orientation: 'August 12-16',
          classesBegin: 'August 19',
          laborDay: 'September 2 (no classes)',
          fallBreak: 'October 10-11',
          thanksgiving: 'November 25-29',
          classesEnd: 'December 6',
          finalsWeek: 'December 9-16',
          commencement: 'December 20'
        },
        spring2025: {
          classesBegin: 'January 13',
          mlkDay: 'January 20 (no classes)',
          springBreak: 'March 10-14',
          classesEnd: 'April 25',
          finalsWeek: 'April 28 - May 5',
          commencement: 'May 9-10'
        }
      }
    };
  }

  initializeAthensKnowledge() {
    return {
      // City Overview
      overview: {
        location: 'Northeast Georgia, 70 miles northeast of Atlanta',
        population: '127,000 (city), 215,000 (metro area)',
        established: 1806,
        nickname: 'Classic City',
        climate: 'Humid subtropical',
        geography: 'Rolling hills, part of Piedmont region'
      },

      // Neighborhoods and Areas
      neighborhoods: {
        downtown: {
          description: 'Historic downtown area with shops, restaurants, and entertainment',
          landmarks: ['Georgia Theatre', 'Classic Center', 'City Hall'],
          nightlife: ['Bars', 'Live music venues', 'Restaurants'],
          events: ['AthFest', 'Twilight Criterium', 'First Friday']
        },
        northside: {
          description: 'Upscale residential area',
          features: ['Historic homes', 'Tree-lined streets', 'Close to campus']
        },
        eastside: {
          description: 'Diverse area with mix of students and locals',
          features: ['Affordable housing', 'Local businesses', 'Easy campus access']
        },
        westside: {
          description: 'Growing area with new developments',
          features: ['Shopping centers', 'Chain restaurants', 'Apartments']
        },
        southside: {
          description: 'Mix of residential and commercial',
          features: ['Shopping', 'Restaurants', 'Business district']
        },
        fivePoints: {
          description: 'Popular student area',
          features: ['Bars', 'Restaurants', 'Student housing', 'Late-night food']
        },
        normaltown: {
          description: 'Hip neighborhood east of downtown',
          features: ['Local shops', 'Restaurants', 'Music venues', 'Art galleries']
        }
      },

      // Transportation
      transportation: {
        publicTransit: {
          athensTransit: {
            routes: '25 bus routes',
            campusTransit: 'Free campus bus system',
            hours: 'Varies by route',
            fare: 'Free for UGA students with ID'
          }
        },
        parking: {
          downtown: 'Limited street parking, paid parking decks',
          campus: 'Permit required, various zones',
          tips: 'Use transit when possible, carpool'
        },
        biking: {
          infrastructure: 'Growing bike lane network',
          campusPolicy: 'Bikes allowed on campus with registration',
          rentalOptions: 'Bike rental programs available'
        },
        walkability: 'Very walkable downtown and campus areas'
      },

      // Dining and Food
      dining: {
        categories: {
          southern: ['The National', 'Mama\'s Boy', 'Weaver D\'s'],
          pizza: ['Mellow Mushroom', 'Your Pie', 'Little Italy'],
          mexican: ['Tlaloc', 'Cali N Tito\'s', 'Taco Stand'],
          asian: ['Tsing Tao', 'Golden Dragon', 'Sushi Huku'],
          coffee: ['Jittery Joe\'s', 'Walker\'s Coffee', 'Starbucks locations'],
          barbecue: ['Fresh Air BBQ', 'Smokin\' Pig'],
          breakfast: ['Mama\'s Boy', 'The Grit', 'Flying Biscuit'],
          lateNight: ['Gumby\'s Pizza', 'Cookout', 'Taco Bell']
        },
        studentFavorites: [
          'Mama\'s Boy (brunch)',
          'The Grit (vegetarian)', 
          'Mellow Mushroom (pizza)',
          'Jittery Joe\'s (coffee)',
          'Cookout (late night)'
        ],
        campusEating: 'Multiple dining halls and food courts on campus'
      },

      // Entertainment and Nightlife
      entertainment: {
        venues: {
          music: [
            'Georgia Theatre (historic venue)',
            'The Foundry (live music)',
            '40 Watt Club (indie music)',
            'Normaltown Hall',
            'Flicker Theatre & Bar'
          ],
          bars: [
            'Creature Comforts Brewing',
            'The World Famous',
            'Copper Creek',
            'Allgood Lounge',
            'Cloud Bar'
          ],
          activities: [
            'State Botanical Garden',
            'Sandy Creek Park',
            'Bear Hollow Zoo',
            'North Oconee River Greenway'
          ]
        },
        events: {
          athFest: 'Annual music and arts festival',
          twilightCriterium: 'Annual bike race downtown',
          wildRumpus: 'Halloween parade',
          firstFriday: 'Monthly downtown event'
        }
      },

      // Shopping
      shopping: {
        malls: ['Beechwood Promenade', 'The Georgia Square Mall'],
        downtown: ['Local boutiques', 'Record stores', 'Gift shops'],
        studentNecessities: ['Walmart', 'Target', 'Publix', 'Kroger'],
        bookstores: ['UGA Bookstore', 'Jackson Street Books', 'Avid Bookshop']
      },

      // Weather and Climate
      weather: {
        spring: 'Mild, 60-75°F, occasional rain',
        summer: 'Hot and humid, 75-85°F, thunderstorms',
        fall: 'Pleasant, 50-70°F, perfect for football',
        winter: 'Mild, 35-55°F, occasional snow',
        tips: [
          'Bring umbrella for sudden showers',
          'Layer clothing for temperature changes',
          'Summer can be very humid'
        ]
      },

      // Healthcare
      healthcare: {
        hospitals: ['Athens Regional Medical Center', 'St. Mary\'s Sacred Heart Hospital'],
        campusHealth: ['University Health Center', 'Counseling services'],
        urgentCare: 'Multiple urgent care facilities',
        pharmacies: ['CVS', 'Walgreens', 'Campus pharmacy']
      },

      // Local Culture
      culture: {
        music: {
          heritage: 'Birthplace of R.E.M. and B-52s',
          scene: 'Vibrant indie and alternative music scene',
          venues: 'Multiple live music venues'
        },
        arts: {
          galleries: ['Lyndon House Arts Center', 'Various downtown galleries'],
          theater: ['Theatre UGA', 'Town & Gown Theatre'],
          festivals: ['AthFest', 'Human Rights Festival']
        },
        sports: {
          professional: 'No major pro teams (Atlanta teams popular)',
          college: 'UGA Bulldogs dominate local sports culture',
          recreation: 'Intramural and club sports popular'
        }
      }
    };
  }

  initializeStudentLifeKnowledge() {
    return {
      // Housing Options
      housing: {
        onCampus: {
          traditional: [
            'Brumby Hall', 'Creswell Hall', 'Russell Hall', 
            'Church Hall', 'Oglethorpe House', 'Lipscomb Hall'
          ],
          suiteStyle: [
            'East Campus Village', 'Reed Hall', 'Boggs Hall'
          ],
          apartmentStyle: [
            'University Village', 'Village Summit'
          ],
          special: [
            'Language immersion floors',
            'Honors housing',
            'Living-learning communities'
          ]
        },
        offCampus: {
          popular: [
            'The Standard', 'The Connection', 'University Courtyard',
            'Campus Lodge', 'Athens Green', 'Reserve at Athens'
          ],
          neighborhoods: [
            'Five Points area (party scene)',
            'Boulevard area (close to campus)',
            'Baxter area (quieter)'
          ],
          tips: [
            'Start looking early for good options',
            'Consider distance to campus',
            'Budget for utilities and parking'
          ]
        }
      },

      // Academic Life
      academicLife: {
        studySpots: {
          libraries: [
            'Miller Learning Center (24/7 during semester)',
            'Main Library (quiet study)',
            'Science Library (group study)'
          ],
          campus: [
            'Tate Student Center',
            'Memorial Hall',
            'Various academic buildings'
          ],
          offCampus: [
            'Jittery Joe\'s',
            'Walker\'s Coffee',
            'Various cafes downtown'
          ]
        },
        academicSupport: {
          tutoring: 'Free tutoring in DAWGhaus',
          writingCenter: 'Free writing assistance',
          advisors: 'Academic advisors in each college',
          disabilities: 'Disability Resource Center',
          mentalHealth: 'Counseling and Psychological Services'
        }
      },

      // Social Life
      socialLife: {
        greekLife: {
          participation: 'About 25% of students',
          rush: 'Fall and spring rush periods',
          benefits: 'Social connections, leadership, philanthropy',
          costs: 'Dues vary by chapter ($1000-3000+ per semester)'
        },
        clubs: {
          academic: 'Professional organizations for each major',
          special: 'Chess club, outdoor club, gaming groups',
          cultural: 'International student organizations',
          service: 'Habitat for Humanity, various volunteer groups',
          sports: 'Intramural sports, club teams'
        },
        dating: {
          apps: ['Popular dating apps used'],
          events: 'Mixers, formals, campus events',
          culture: 'Generally friendly dating scene'
        }
      },

      // Campus Traditions
      traditions: {
        academic: {
          orientation: 'Dawg Days for new students',
          ringCeremony: 'Junior year tradition',
          graduation: 'Walking under the Arch'
        },
        athletic: {
          gamedays: 'Tailgating culture, red and black everywhere',
          chants: 'Calling the Dawgs, Go Dawgs Sic \'Em',
          rivals: 'Georgia Tech (Clean Old-Fashioned Hate), Auburn, Florida'
        },
        social: {
          springfest: 'Annual spring concert and festival',
          homecoming: 'Week of events and football game',
          halloween: 'Wild Rumpus parade downtown'
        }
      },

      // Practical Information
      practicalInfo: {
        banking: {
          campus: 'BB&T branch on campus',
          local: 'Various banks downtown and around town',
          atms: 'Available throughout campus and town'
        },
        employment: {
          onCampus: 'Work-study jobs, student assistant positions',
          offCampus: 'Restaurants, retail, tutoring opportunities',
          internships: 'Career Center helps with placement'
        },
        safety: {
          campus: 'UGA Police patrol 24/7',
          escort: 'Campus escort service available',
          emergency: 'Blue light emergency phones throughout campus',
          downtown: 'Generally safe but use common sense'
        },
        technology: {
          internet: 'High-speed WiFi throughout campus',
          computers: 'Computer labs and printing available',
          software: 'Free software for students',
          support: 'EITS provides tech support'
        }
      },

      // Seasonal Activities
      seasonalActivities: {
        fall: {
          activities: [
            'Football games and tailgating',
            'Homecoming events',
            'Fall festivals',
            'Perfect weather for outdoor activities'
          ]
        },
        winter: {
          activities: [
            'Basketball games',
            'Indoor activities',
            'Holiday events',
            'Study abroad fair'
          ]
        },
        spring: {
          activities: [
            'SpringFest',
            'Baseball games', 
            'Outdoor recreation',
            'Graduation events'
          ]
        },
        summer: {
          activities: [
            'Summer classes',
            'Internships',
            'Research opportunities',
            'Fewer crowds on campus'
          ]
        }
      },

      // Health and Wellness
      healthWellness: {
        physicalHealth: {
          campusHealth: 'University Health Center',
          fitness: 'Ramsey Student Center',
          nutrition: 'Healthy dining options available',
          recreation: 'Intramural sports, outdoor programs'
        },
        mentalHealth: {
          counseling: 'Free counseling services',
          support: 'Support groups available',
          crisis: '24/7 crisis support available',
          stress: 'Stress management programs'
        }
      }
    };
  }

  // Query methods
  async queryKnowledgeBase(query, category = 'all') {
    try {
      const cacheKey = `kb:${category}:${query.toLowerCase().replace(/\s+/g, '_')}`;
      
      // Check cache first
      const cached = await redisUtils.get(cacheKey);
      if (cached) {
        return cached;
      }

      const results = [];
      const queryLower = query.toLowerCase();

      // Search UGA knowledge
      if (category === 'all' || category === 'uga') {
        const ugaResults = this.searchUGAKnowledge(queryLower);
        results.push(...ugaResults);
      }

      // Search Athens knowledge
      if (category === 'all' || category === 'athens') {
        const athensResults = this.searchAthensKnowledge(queryLower);
        results.push(...athensResults);
      }

      // Search student life knowledge
      if (category === 'all' || category === 'studentlife') {
        const studentResults = this.searchStudentLifeKnowledge(queryLower);
        results.push(...studentResults);
      }

      // Score and rank results
      const scoredResults = this.scoreResults(results, queryLower);
      const topResults = scoredResults.slice(0, 5);

      // Cache results for 30 minutes
      await redisUtils.setex(cacheKey, 1800, topResults);

      return topResults;

    } catch (error) {
      logger.error('Knowledge base query error:', error);
      return [];
    }
  }

  searchUGAKnowledge(query) {
    const results = [];
    
    // Search through different sections
    this.searchSection(this.ugaKnowledgeBase.overview, query, 'UGA Overview', results);
    this.searchSection(this.ugaKnowledgeBase.academics, query, 'Academics', results);
    this.searchSection(this.ugaKnowledgeBase.facilities, query, 'Campus Facilities', results);
    this.searchSection(this.ugaKnowledgeBase.athletics, query, 'Athletics', results);
    this.searchSection(this.ugaKnowledgeBase.studentLife, query, 'Student Life', results);

    return results;
  }

  searchAthensKnowledge(query) {
    const results = [];
    
    this.searchSection(this.athensKnowledgeBase.neighborhoods, query, 'Athens Neighborhoods', results);
    this.searchSection(this.athensKnowledgeBase.dining, query, 'Athens Dining', results);
    this.searchSection(this.athensKnowledgeBase.entertainment, query, 'Athens Entertainment', results);
    this.searchSection(this.athensKnowledgeBase.transportation, query, 'Athens Transportation', results);

    return results;
  }

  searchStudentLifeKnowledge(query) {
    const results = [];
    
    this.searchSection(this.studentLifeKnowledge.housing, query, 'Student Housing', results);
    this.searchSection(this.studentLifeKnowledge.academicLife, query, 'Academic Life', results);
    this.searchSection(this.studentLifeKnowledge.socialLife, query, 'Social Life', results);
    this.searchSection(this.studentLifeKnowledge.practicalInfo, query, 'Practical Information', results);

    return results;
  }

  searchSection(section, query, sectionName, results) {
    const searchInObject = (obj, path = '') => {
      for (const [key, value] of Object.entries(obj)) {
        const currentPath = path ? `${path}.${key}` : key;
        
        if (typeof value === 'string') {
          if (value.toLowerCase().includes(query) || key.toLowerCase().includes(query)) {
            results.push({
              section: sectionName,
              path: currentPath,
              content: value,
              type: 'text',
              relevance: this.calculateRelevance(query, value + ' ' + key)
            });
          }
        } else if (Array.isArray(value)) {
          value.forEach((item, index) => {
            if (typeof item === 'string') {
              if (item.toLowerCase().includes(query) || key.toLowerCase().includes(query)) {
                results.push({
                  section: sectionName,
                  path: `${currentPath}[${index}]`,
                  content: item,
                  type: 'list_item',
                  relevance: this.calculateRelevance(query, item + ' ' + key)
                });
              }
            } else if (typeof item === 'object') {
              searchInObject(item, `${currentPath}[${index}]`);
            }
          });
        } else if (typeof value === 'object' && value !== null) {
          searchInObject(value, currentPath);
        }
      }
    };

    searchInObject(section);
  }

  calculateRelevance(query, text) {
    const queryWords = query.toLowerCase().split(' ');
    const textLower = text.toLowerCase();
    let score = 0;

    queryWords.forEach(word => {
      if (textLower.includes(word)) {
        // Exact word match gets higher score
        const regex = new RegExp(`\\b${word}\\b`, 'gi');
        const exactMatches = (textLower.match(regex) || []).length;
        score += exactMatches * 2;

        // Partial matches get lower score
        const partialMatches = textLower.split(word).length - 1;
        score += (partialMatches - exactMatches) * 0.5;
      }
    });

    // Boost score for shorter text (more relevant)
    score = score * (1 + (100 / Math.max(text.length, 100)));

    return score;
  }

  scoreResults(results, query) {
    return results
      .sort((a, b) => b.relevance - a.relevance)
      .map(result => ({
        ...result,
        snippet: this.createSnippet(result.content, query)
      }));
  }

  createSnippet(text, query, maxLength = 150) {
    const queryIndex = text.toLowerCase().indexOf(query.toLowerCase());
    if (queryIndex === -1) {
      return text.length > maxLength ? text.substring(0, maxLength) + '...' : text;
    }

    const start = Math.max(0, queryIndex - 50);
    const end = Math.min(text.length, queryIndex + query.length + 50);
    
    let snippet = text.substring(start, end);
    if (start > 0) snippet = '...' + snippet;
    if (end < text.length) snippet = snippet + '...';

    return snippet;
  }

  // Get contextual information based on user profile
  getContextualInfo(user, topic) {
    const context = {
      userRole: user.role,
      userCollege: user.college,
      userMajor: user.major,
      userClassification: user.classification
    };

    // Provide personalized information based on user context
    switch (topic) {
      case 'housing':
        return this.getHousingContext(context);
      case 'dining':
        return this.getDiningContext(context);
      case 'academics':
        return this.getAcademicContext(context);
      default:
        return this.getGeneralContext(context);
    }
  }

  getHousingContext(context) {
    if (context.userClassification === 'freshman') {
      return {
        recommendation: 'Traditional residence halls recommended for first-year students',
        options: ['Brumby Hall', 'Creswell Hall', 'Russell Hall'],
        tips: ['Apply early', 'Consider living-learning communities', 'Traditional halls help with socialization']
      };
    }
    return {
      recommendation: 'Various options available based on preference and budget',
      options: ['On-campus apartments', 'Off-campus housing', 'Greek housing']
    };
  }

  getDiningContext(context) {
    return {
      campusOptions: 'Multiple dining halls and food courts',
      localFavorites: ['Mama\'s Boy', 'The Grit', 'Mellow Mushroom'],
      budgetTips: ['Use meal plan efficiently', 'Cook in apartment kitchens', 'Look for student discounts']
    };
  }

  getAcademicContext(context) {
    const academicInfo = {
      general: 'UGA offers comprehensive academic support services'
    };

    if (context.userCollege) {
      academicInfo.collegeSpecific = `Information specific to ${context.userCollege}`;
    }

    if (context.userMajor) {
      academicInfo.majorSpecific = `Resources for ${context.userMajor} students`;
    }

    return academicInfo;
  }

  getGeneralContext(context) {
    return {
      campusLife: 'Rich campus life with 600+ student organizations',
      location: 'Athens, Georgia - vibrant college town',
      athletics: 'SEC athletics, strong Bulldog pride'
    };
  }
}

module.exports = new KnowledgeBaseService();