Skip to content

responsivedev/hotel-mcp-demo

Repository files navigation

Mock Hotel Booking Platform

A modern hotel booking platform built with Next.js, featuring real-time hotel view tracking using Apache Kafka and an AI-powered travel assistant. This demo application showcases a full-stack system with event streaming, real-time analytics, and AI integration.

Features

  • 🏨 Browse and search hotels with modern UI
  • 🌟 Filter by location, star rating, and amenities
  • 📊 Real-time hotel view tracking and analytics
  • 🚀 Kafka integration for event streaming
  • 💬 AI-powered travel assistant using LangChain
  • 📈 Real-time analytics dashboard
  • 🔄 Kafka Streams for data processing

Architecture Overview

The application consists of several key components:

  1. Frontend (Next.js)

    • Modern UI built with Next.js 13+ and Tailwind CSS
    • Real-time hotel view tracking
    • Interactive hotel search and filtering
    • AI chat interface for travel assistance
  2. Kafka Topics

    • hotels topic: Stores hotel data
    • hotel-views topic: Tracks user view events
    • user-views-aggregate topic: Aggregates the views after joining hotel-views with hotels
  3. Kafka Streams Application

    • Each pageview to a specific hotel emits an event to hotel-views (users are identified by IP for now)
    • Hotel views are deduplicated to reduce number of tokens sent to LLM
    • These views are then joined with hotels for a full enrichment
    • They are finally aggregated by using a 15 minute context window per user
  4. AI Chat Bot

    • Powered by LangChain and OpenAI
    • Provides hotel recommendations based on past history

Prerequisites

Before you begin, ensure you have the following installed:

Getting Started

  1. Clone the repository

    git clone <repository-url>
    cd session-mcp-demo
  2. Install dependencies

    npm install
  3. Start Kafka and Zookeeper

    docker-compose up -d

    This will start Kafka and Zookeeper in detached mode. Verify they're running with:

    docker-compose ps
  4. Initialize Kafka and load hotel data

    npm run init-kafka

    This will:

    • Create the necessary Kafka topics (hotels, hotel-views, hotel-analytics)
    • Load all hotels from the JSON file into the hotels topic
  5. Start the Kafka Streams application

    npm run kafka-streams

    This will build and run the Java application that processes hotel view events.

  6. Start the development server

    npm run dev
  7. Open your browser Visit http://localhost:3000 to see the application in action.

  8. Seed the AI Chatbot Context To get the most out of the AI travel assistant:

    1. Use the search filters to select a location (e.g., "New York")
    2. Browse through several hotels in that location
    3. The chatbot will use your browsing history to provide more relevant recommendations
    4. Try asking questions like "What are the best hotels in this area?" or "Which hotel would you recommend for a family?"

Project Structure

session-mcp-demo/
├── app/                    # Next.js application code
│   ├── api/               # API routes
│   │   ├── chat/         # AI chat endpoints
│   │   └── track-view/   # Hotel view tracking endpoint
│   └── hotels/           # Hotel pages
├── components/            # React components
├── data/                  # Hotel data
├── kafka-streams/         # Java Kafka Streams application
│   ├── src/              # Source code
│   └── build.gradle      # Build configuration
├── lib/                   # Utility functions and services
├── scripts/               # Utility scripts
│   ├── init-kafka.js     # Kafka initialization
│   └── load-hotels-to-kafka.js  # Hotel data loader
└── docker-compose.yml    # Kafka and Zookeeper configuration

Environment Variables

Create a .env file in the root directory with:

NEXT_PUBLIC_BASE_URL=http://localhost:3000
OPENAI_API_KEY=your_openai_api_key  # Required for the AI chat feature

Development

Available Scripts

  • npm run dev - Start Next.js development server
  • npm run build - Build the application
  • npm run start - Start the production server
  • npm run lint - Run ESLint
  • npm run generate-hotels - Generate new hotel data
  • npm run init-kafka - Initialize Kafka topics and load data
  • npm run load-hotels - Reload hotel data into Kafka
  • npm run kafka-streams - Build and run the Kafka Streams application

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published