Skip to content

splimon/Nintendo-DS

Β 
Β 

Repository files navigation

UH Pathways - University of Hawaii Career Pathways System

An intelligent educational pathway advisor system that helps students explore career paths through Hawaii's college programs. The system uses AI agents to provide personalized recommendations, market intelligence, and career guidance based on student profiles and conversational context.


πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone <repository-url>
    cd ai-pathways-poc
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env file in the root directory based on .env.example:

    cp .env.example .env

    Fill in your environment variables:

    # Required: Groq API for LLM processing
    GROQ_API_KEY="your_groq_api_key_here"
    
    # Required: Upstash Redis for caching and rate limiting
    UPSTASH_REDIS_REST_URL="your_upstash_redis_url"
    UPSTASH_REDIS_REST_TOKEN="your_upstash_redis_token"
    
    # Optional: Use LangGraph-Style Orchestrator (default: false)
    USE_LANGGRAPH_STYLE=true
  4. Run the development server

    npm run dev
  5. Open your browser

    Navigate to http://localhost:3000


πŸ“š Architecture Overview

System Design Philosophy

The AI Pathways system is built on a multi-agent orchestration architecture that combines:

  • LLM-powered intelligence for understanding student needs
  • Data-driven recommendations from Hawaii's educational databases
  • Iterative quality improvement through reflection and verification
  • Context-aware personalization using conversation history and user profiles

System Flow Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                            USER INTERACTION                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         1. LLM CLASSIFIER NODE                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  β€’ Analyze user intent                                              β”‚    β”‚
β”‚  β”‚  β€’ Classify query type: search | conversational | update_profile   β”‚    β”‚
β”‚  β”‚  β€’ Determine if tools needed                                        β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                 β”‚                 β”‚
                    β–Ό                 β–Ό                 β–Ό
            CONVERSATIONAL        SEARCH        UPDATE_PROFILE
                    β”‚                 β”‚                 β”‚
                    β–Ό                 β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Conversational Agent β”‚  β”‚    2. PROFILE EXTRACTOR NODE                 β”‚
β”‚                      β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚ β€’ Answer questions   β”‚  β”‚  β”‚ Extract Keywords:                      β”‚  β”‚
β”‚ β€’ Provide guidance   β”‚  β”‚  β”‚                                        β”‚  β”‚
β”‚ β€’ Chat naturally     β”‚  β”‚  β”‚ Topic Pivot Mode:                      β”‚  β”‚
β”‚                      β”‚  β”‚  β”‚ └─> Fresh keywords only                β”‚  β”‚
β”‚ └─> Return response  β”‚  β”‚  β”‚                                        β”‚  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚ Affirmative Mode ("yes"):              β”‚  β”‚
                          β”‚  β”‚ └─> Use conversation context           β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Normal Mode:                           β”‚  β”‚
                          β”‚  β”‚ └─> Query keywords only                β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    3. TOOL PLANNER NODE                      β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ Select Tools:                          β”‚  β”‚
                          │  │ ‒ trace_pathway (HS→College→Career)    │  │
                          β”‚  β”‚ β€’ search_hs_programs                   β”‚  β”‚
                          β”‚  β”‚ β€’ search_college_programs              β”‚  β”‚
                          β”‚  β”‚ β€’ get_careers (from CIP codes)         β”‚  β”‚
                          β”‚  β”‚ β€’ expand_cip (2-digit β†’ full codes)    β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    4. TOOL EXECUTOR NODE                     β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ Search JSONL Databases:                β”‚  β”‚
                          β”‚  β”‚ β€’ Program name matching                β”‚  β”‚
                          β”‚  β”‚ β€’ CIP code lookups                     β”‚  β”‚
                          β”‚  β”‚ β€’ Campus mappings                      β”‚  β”‚
                          β”‚  β”‚ β€’ Career path connections              β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Returns:                               β”‚  β”‚
                          β”‚  β”‚ β€’ High school programs                 β”‚  β”‚
                          β”‚  β”‚ β€’ College programs                     β”‚  β”‚
                          │  │ ‒ Career mappings (CIP→SOC)            │  │
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    5. VERIFIER NODE                          β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ LLM Validation (0-10 scoring):         β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Normal Query:                          β”‚  β”‚
                          β”‚  β”‚ └─> Use profile for scoring            β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Affirmative Response:                  β”‚  β”‚
                          β”‚  β”‚ └─> Skip profile, use context only     β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Smart Thresholds:                      β”‚  β”‚
                          β”‚  β”‚ β€’ Strong matches exist β†’ threshold 7+  β”‚  β”‚
                          β”‚  β”‚ β€’ Weak matches β†’ threshold 5+          β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    6. REFLECTOR NODE (Quality Check)         β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ Evaluate Results (0-10 score):         β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Score 9-10: βœ“ Excellent β†’ Continue    β”‚  β”‚
                          β”‚  β”‚ Score 7-8:  βœ“ Good β†’ Continue          β”‚  β”‚
                          β”‚  β”‚ Score 4-6:  ⚠ Retry with adjustments   β”‚  β”‚
                          β”‚  β”‚ Score 0-3:  βœ— Retry with new strategy  β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                            β”‚                 β”‚                 β”‚
                      Quality < 7        Quality β‰₯ 7       Attempt 3
                            β”‚                 β”‚                 β”‚
                            β–Ό                 β”‚                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚                 β”‚
                    β”‚ RETRY LOGIC   β”‚         β”‚                 β”‚
                    β”‚               β”‚         β”‚                 β”‚
                    β”‚ Attempt 2:    β”‚         β”‚                 β”‚
                    β”‚ β€’ Broaden     β”‚         β”‚                 β”‚
                    β”‚ β€’ New tools   β”‚         β”‚                 β”‚
                    β”‚               β”‚         β”‚                 β”‚
                    β”‚ Attempt 3:    β”‚         β”‚                 β”‚
                    β”‚ β€’ CIP expand  β”‚         β”‚                 β”‚
                    β”‚ β€’ Accept best β”‚         β”‚                 β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚                 β”‚
                            β”‚                 β”‚                 β”‚
                            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    7. AGGREGATOR NODE                        β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ Process & Organize:                    β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ β€’ Group by CIP code                    β”‚  β”‚
                          β”‚  β”‚ β€’ Find best program name               β”‚  β”‚
                          β”‚  β”‚ β€’ Extract all specializations          β”‚  β”‚
                          β”‚  β”‚ β€’ List all campuses                    β”‚  β”‚
                          β”‚  β”‚ β€’ Map CIP β†’ SOC codes                  β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Output:                                β”‚  β”‚
                          β”‚  β”‚ β€’ Program families with variants       β”‚  β”‚
                          β”‚  β”‚ β€’ SOC codes for market intelligence    β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                                              β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚    8. FORMATTER NODE                         β”‚
                          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
                          β”‚  β”‚ Generate Markdown Response:            β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ β€’ High School Programs section         β”‚  β”‚
                          β”‚  β”‚ β€’ College Programs with specs          β”‚  β”‚
                          β”‚  β”‚ β€’ Career Pathways                      β”‚  β”‚
                          β”‚  β”‚ β€’ Next Steps & Recommendations         β”‚  β”‚
                          β”‚  β”‚                                        β”‚  β”‚
                          β”‚  β”‚ Include:                               β”‚  β”‚
                          β”‚  β”‚ β€’ SOC codes for market intelligence    β”‚  β”‚
                          β”‚  β”‚ β€’ Pathway metadata                     β”‚  β”‚
                          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                              β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                             β”‚                             β”‚
                β–Ό                             β–Ό                             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  RETURN TO USER          β”‚   β”‚  MARKET INTELLIGENCE     β”‚   β”‚  CACHE RESULT       β”‚
β”‚                          β”‚   β”‚                          β”‚   β”‚                     β”‚
β”‚  β€’ Formatted response    β”‚   β”‚  Generate AI Report:     β”‚   β”‚  β€’ Store in Redis   β”‚
β”‚  β€’ Pathway data          β”‚   β”‚  β€’ Fetch SOC data        β”‚   β”‚  β€’ TTL: 1 hour      β”‚
β”‚  β€’ SOC codes             β”‚   β”‚  β€’ Top 5 skills          β”‚   β”‚  β€’ Key: hash of     β”‚
β”‚  β€’ Metadata              β”‚   β”‚  β€’ Top 5 companies       β”‚   β”‚    query+profile    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β€’ 4 action insights     β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚  β€’ UHCC-specific         β”‚
                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Detailed Execution Flow

  1. User sends message β†’ API receives request with conversation history and profile
  2. Cache check β†’ If query cached, return immediately (1 hour TTL)
  3. Classifier β†’ Determines intent and routing
  4. ProfileExtractor β†’ Extracts keywords with smart filtering
  5. ToolPlanner β†’ Selects appropriate search tools
  6. ToolExecutor β†’ Searches JSONL databases for programs and careers
  7. Verifier β†’ LLM validates and scores results (0-10 scale)
  8. Reflector β†’ Evaluates quality, triggers retry if needed
  9. Aggregator β†’ Groups and organizes results, extracts SOC codes
  10. Formatter β†’ Generates markdown response
  11. Response β†’ Returns to user with pathway data and SOC codes
  12. Market Intelligence (async) β†’ Fetches labor market data, generates AI report
  13. Cache β†’ Stores result for future identical queries

Parallel Processing

The system uses parallel execution where possible:

  • Tool execution: All selected tools run simultaneously
  • Verification: Programs verified in batches of 5
  • Market intelligence: All 4 SOC APIs called in parallel
  • Data fetching: Multiple JSONL files read concurrently

πŸ—οΈ Core Architecture

1. LangGraph-Style Orchestrator

File: src/app/lib/agents/langgraph-style-orchestrator.ts

The main orchestration engine that coordinates all agents in a graph-based workflow.

Key Features:

  • State Management: Maintains conversation context, user profile, and intermediate results
  • Node-based Processing: Each agent is a node in the execution graph
  • Quality Assurance: Built-in reflection and retry mechanisms
  • Smart Routing: Determines next steps based on classification and quality scores

Execution Nodes:

  1. Classifier Node (llm-classifier.ts)

    • Analyzes user intent
    • Determines query type: search, conversational, update_profile
    • Decides if tools are needed
  2. ProfileExtractor Node

    • Extracts keywords from user query
    • Three modes:
      • Topic Pivot: Fresh start with new keywords
      • Affirmative: Uses conversation context (when user says "yes")
      • Normal: Query keywords only
    • Smart filtering to prevent profile contamination
  3. ToolPlanner Node

    • Selects appropriate tools based on query type
    • Available tools:
      • trace_pathway: Comprehensive search (HS β†’ College β†’ Career)
      • search_hs_programs: High school programs only
      • search_college_programs: College programs only
      • get_careers: Career paths from CIP codes
      • expand_cip: Expand 2-digit CIP codes to full programs
  4. ToolExecutor Node (direct-search-tracer.ts)

    • Executes selected tools
    • Searches JSONL databases
    • Collects high school programs, college programs, and career mappings
  5. Verifier Node (result-verifier.ts)

    • Validates results against user query
    • Scores programs on 0-10 relevance scale
    • Smart threshold filtering:
      • High threshold (7+) when strong matches exist
      • Lower threshold (5+) when matches are weak
    • Profile Usage:
      • Normal queries: Uses profile for scoring
      • Affirmative responses: Skips profile to focus on conversation
  6. Reflector Node (reflection-agent.ts)

    • Evaluates result quality (0-10 score)
    • Provides improvement suggestions
    • Triggers retries if quality < 7 (up to 3 attempts)
  7. Aggregator Node (pathway-aggregator.ts)

    • Groups programs by CIP code
    • Finds best representative name for each program family
    • Extracts specializations and variants
    • Maps CIP codes to SOC codes for market intelligence
  8. Formatter Node (response-formatter.ts)

    • Generates markdown responses
    • Creates structured output with:
      • High school programs
      • College programs (with specializations)
      • Career pathways
      • Next steps

2. Conversational Agent

File: src/app/lib/agents/conversational-agent.ts

Handles natural language interactions that don't require pathway searches.

Capabilities:

  • Answers general questions about UHCC, Hawaii careers, programs
  • Maintains conversation context
  • Provides encouragement and guidance
  • Redirects to pathway search when appropriate

3. Profile Management

Profile Generation Agent

File: src/app/lib/agents/profile-generation-agent.ts

  • Analyzes conversation history
  • Extracts student information:
    • Education level, grade, current status
    • Interests, career goals, motivations
    • Work preferences, learning style
    • Challenges, strengths, support needs
    • Cultural background, confidence level

Profile Update Agent

File: src/app/lib/agents/profile-update-agent.ts

  • Incrementally updates profile as conversation progresses
  • Identifies new information in user messages
  • Merges updates intelligently (doesn't overwrite unless contradictory)

4. Market Intelligence System

File: src/app/lib/agents/market-intelligence-agent.ts

Generates AI-powered market analysis reports for career pathways.

Data Sources:

Integrates with Hawaii Career Explorer API:

  • Job titles and required skills
  • Companies hiring for specific roles
  • Skill demand across companies
  • Active job postings

Report Components:

  1. Key Skills Required

    • Top 5 in-demand skills
    • AI infers relevant skills from SOC codes
    • Visual ranking bars (no percentages shown)
  2. Hiring Companies

    • Top 5 companies in Hawaii
    • Filters out invalid/test data
    • Prioritizes Hawaii-based employers
  3. Recommended Actions

    • Personalized to student's profile and conversation
    • UHCC-specific program recommendations
    • Portfolio development suggestions
    • Networking opportunities in Hawaii
    • Certification pathways

Creative AI Approach:

  • Temperature: 0.7 for balanced creativity
  • LLM uses domain knowledge to infer skills
  • Doesn't rely solely on potentially inaccurate API data
  • Example: For electrical engineering, suggests "Circuit Design, AutoCAD, MATLAB" instead of generic skills

πŸ—„οΈ Data Architecture

JSONL Databases

Location: src/app/lib/data/jsonl/

The system uses JSON Lines files for fast, efficient searches:

  • campus_to_cip_mapping.jsonl: Campus β†’ CIP code mappings
  • cip_to_campus_mapping.jsonl: CIP β†’ Campus mappings
  • cip_to_program_mapping.jsonl: CIP β†’ Program details
  • cip_to_soc_mapping.jsonl: CIP β†’ SOC (career) mappings
  • cip2digit_to_cip_mapping.jsonl: 2-digit CIP β†’ Full CIP codes
  • program_to_cip_mapping.jsonl: Program name β†’ CIP codes
  • soc_to_cip_mapping.jsonl: SOC β†’ CIP mappings

Search Tools

File: src/app/lib/tools/jsonl-reader.ts & jsonl-tools.ts

Features:

  • Phrase matching: Detects exact phrases in program names
  • Keyword scoring: Ranks programs by keyword relevance
  • Fuzzy matching: Handles typos and variations
  • CIP code expansion: Maps broad categories to specific programs

🎯 Smart Features

1. Context-Aware Keyword Extraction

Problem Solved: Prevent profile interests from contaminating specific queries

Implementation:

// When user says "yes" after seeing nursing programs
// DON'T: Add profile interests (art, music, engineering)
// DO: Use conversation context (nursing)

if (isAffirmative) {
  keywords = extractFromLastAssistantMessage();
  // Only add relevant profile interests if context is thin
}

2. Profile Filtering in Verification

Problem Solved: Wrong programs shown when user confirms interest

Implementation:

// When user says "yes", don't boost profile interests
const profileForVerification = isAffirmative ? undefined : state.userProfile;

// Profile only used for scoring in normal searches, not affirmative responses

3. Component Caching (UI)

Problem Solved: Re-fetching data when toggling between views

Implementation:

// Keep components mounted, hide with CSS
<div style={{ display: showDetails ? 'block' : 'none' }}>
  <MarketIntelligenceReport /> {/* Always mounted */}
</div>

4. Data Validation

Problem Solved: API returns junk data (numbers, "null", test values)

Implementation:

isValidSkill(skill: string): boolean {
  // Filter: pure numbers, no letters, "na", 1-2 chars, "test"
  return !junkPatterns.some(pattern => pattern.test(skill));
}

πŸ”Œ API Routes

Pathway Search

Endpoint: POST /api/pathway

Searches for educational pathways based on user query.

Request:

{
  "message": "show me nursing programs",
  "conversationHistory": [...],
  "profile": {...}
}

Response:

{
  "response": "markdown formatted pathway results",
  "pathwayData": {
    "highSchoolPrograms": [...],
    "collegePrograms": [...],
    "careers": [...]
  },
  "socCodes": ["29-1141", "29-1151"],
  "metadata": {...}
}

Market Intelligence

Endpoint: POST /api/market-intelligence

Generates AI-powered market analysis for career paths.

Request:

{
  "socCodes": ["15-1252", "15-1256"],
  "conversationContext": [...],
  "userProfile": {...}
}

Response:

{
  "success": true,
  "markdown": "AI-generated report with interactive components",
  "summary": {
    "totalCompanies": 125,
    "totalSkills": 450,
    "topCompanies": ["Company A", "Company B", ...],
    "topSkills": ["Python", "SQL", ...],
    "activePosts": 234
  }
}

Profile Management

  • POST /api/generate-profile: Generate initial profile from conversation
  • POST /api/update-profile: Update existing profile with new information

SOC Data Proxies (Server-side only)

  • GET /api/soc/jobtitles-skills?soc5=11-1011,13-1071
  • GET /api/soc/jobtitles-companies?soc5=...
  • GET /api/soc/companies-skills?soc5=...
  • GET /api/soc/active-posts?soc5=...

🎨 UI Components

Interactive Chat Interface

File: src/app/components/AIPathwaysChat/UnifiedSleekChat.tsx

Features:

  • Real-time streaming responses
  • Message history
  • Profile generation and display
  • Language selection (English/Hawaiian Pidgin)

Data Visualization Panel

File: src/app/components/AIPathwaysChat/DataPanel.tsx

Two views:

  1. Summary View: Market Intelligence Report
  2. Detailed Data View:
    • Companies & Skills
    • Job Titles & Companies
    • Job Titles & Skills

Visualizer Components:

  • CompaniesSkillsVisualizer.tsx: Skills required by company
  • JobTitlesCompaniesVisualizer.tsx: Companies hiring by job title
  • JobTitlesSkillsVisualizer.tsx: Skills required by job title

Market Intelligence Report

File: src/app/components/AIPathwaysChat/MarketIntelligenceReport.tsx

Custom MDX components:

  • Skill Bar: Visual ranking of skills (no percentages)
  • Company Card: Minimal company information
  • Insight Box: Color-coded actionable recommendations
    • Success (green): Getting started
    • Info (blue): Portfolio, networking
    • Warning (amber): Competitive edge

🧠 AI Models & Configuration

Primary LLM: Groq (Llama 3.3 70B)

Model: llama-3.3-70b-versatile

Usage by Agent:

Agent Temperature Max Tokens Purpose
Classifier 0.1 150 Precise intent detection
Conversational 0.7 800 Natural, friendly responses
Profile Generation 0.3 2000 Structured data extraction
Profile Update 0.3 1500 Incremental updates
Verifier 0.2 1000 Accurate relevance scoring
Reflector 0.3 500 Quality assessment
Market Intelligence 0.7 2000 Creative skill inference
Response Formatter 0.5 3000 Well-structured output

🚦 Rate Limiting & Caching

Rate Limiting

Implementation: Upstash Rate Limit

  • Limit: 10 requests per 10 seconds per IP
  • Endpoint: All API routes
  • Response: 429 Too Many Requests with retry info

Caching

Implementation: Upstash Redis

  • TTL: 1 hour for pathway searches
  • Cache Key: Hash of (query + profile + history)
  • Invalidation: Manual via /api/cache-invalidate

Cache Management Endpoints:

  • GET /api/cache-stats: View cache statistics
  • POST /api/cache-invalidate: Clear specific or all cache
  • POST /api/cache-warmup: Pre-populate cache with common queries

πŸ“Š Quality Assurance

Reflection System

Score Thresholds:

  • 9-10: Excellent - Single attempt accepted
  • 7-8: Good - Single attempt accepted
  • 4-6: Needs improvement - Retry with adjustments
  • 0-3: Poor - Retry with different strategy

Retry Strategy:

Attempt 1:

  • Use initial keywords and tools
  • Standard verification

Attempt 2:

  • Broaden search if too few results
  • Try different tool combinations

Attempt 3:

  • Use CIP code expansion
  • Broader keyword matching
  • Accept best available results

🎯 Best Practices

For Developers

  1. Always validate data from external APIs

    if (!isValidSkill(skill)) return;
  2. Use conversation context for affirmative responses

    if (isAffirmative) keywords = extractFromConversation();
  3. Keep components mounted for performance

    <div style={{ display: visible ? 'block' : 'none' }}>
  4. Call external APIs server-side directly

    // In agents (server-side): Direct API call
    // In components (client-side): Next.js proxy

For Content

  1. UHCC-Specific Recommendations Only

    • Reference specific UHCC campuses
    • Mention UHCC programs and certifications
    • Suggest Hawaii-based companies
    • No generic online platforms
  2. Actionable Insights

    • Specific courses to take
    • Certifications to earn
    • Projects to build
    • People to connect with

πŸ”§ Development Commands

# Development
npm run dev              # Start dev server with Turbopack

# Build
npm run build           # Build for production

# Production
npm start               # Start production server

# Code Quality
npm run lint            # Run ESLint
npm run format:fix      # Format code with Prettier

πŸ› Debugging

Enable Verbose Logging

The system uses console logging extensively. Look for:

  • [LangGraph-Style]: Orchestrator flow
  • [ProfileExtractor]: Keyword extraction
  • [Verifier]: Program validation
  • [Aggregator]: CIP code mapping
  • [MarketIntelligence]: Report generation

Common Issues

Issue: Wrong programs shown after saying "yes"

  • Cause: Profile contamination
  • Check: [ProfileExtractor] logs for keyword extraction
  • Fix: Ensure affirmative detection working

Issue: Market intelligence report fails

  • Cause: External API timeout or invalid data
  • Check: Network tab for API calls
  • Fix: Verify SOC codes and external API status

Issue: No cache hits

  • Cause: Cache keys not matching
  • Check: Redis connection and key format
  • Fix: Verify UPSTASH environment variables

πŸ“ˆ Performance Optimization

Current Optimizations

  1. Component Caching: UI components stay mounted
  2. Redis Caching: Pathway results cached for 1 hour
  3. Parallel API Calls: Market intelligence fetches all data simultaneously
  4. JSONL Databases: Fast file-based searches
  5. Smart Verification: Early termination when quality is high

Metrics

  • Average Response Time: 2-4 seconds for pathway search
  • Cache Hit Rate: ~60% for repeated queries
  • Quality Score: Average 8/10 on first attempt

πŸš€ Deployment

Environment Variables (Production)

Ensure all required variables are set:

GROQ_API_KEY=<your_production_key>
UPSTASH_REDIS_REST_URL=<your_redis_url>
UPSTASH_REDIS_REST_TOKEN=<your_redis_token>
USE_LANGGRAPH_STYLE=true

Build & Deploy

# Build production bundle
npm run build

# Start production server
npm start

Vercel Deployment

The project is optimized for Vercel deployment:

  • API routes use nodejs runtime
  • All routes are dynamic (force-dynamic)
  • Environment variables via Vercel dashboard

πŸ“ Contributing

Code Style

  • Use TypeScript strict mode
  • Follow ESLint and Prettier rules
  • Add JSDoc comments for functions
  • Include console logs for debugging

Testing New Features

  1. Test with profile contamination scenarios
  2. Verify affirmative response handling
  3. Check data validation for external APIs
  4. Test cache invalidation
  5. Verify market intelligence generation

πŸ™ Acknowledgments

  • University of Hawaii Community Colleges for educational data
  • Hawaii Career Explorer for labor market data
  • Groq for fast LLM inference
  • Upstash for Redis caching and rate limiting

πŸ“ž Support

For questions or issues:


Built with ❀️ for Hawaii's Students

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.6%
  • Other 0.4%