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.
- 🏨 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
The application consists of several key components:
-
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
-
Kafka Topics
hotelstopic: Stores hotel datahotel-viewstopic: Tracks user view eventsuser-views-aggregatetopic: Aggregates the views after joininghotel-viewswithhotels
-
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
hotelsfor a full enrichment - They are finally aggregated by using a 15 minute context window per user
- Each pageview to a specific hotel emits an event to
-
AI Chat Bot
- Powered by LangChain and OpenAI
- Provides hotel recommendations based on past history
Before you begin, ensure you have the following installed:
- Node.js (v18 or later)
- Docker and Docker Compose
- npm (comes with Node.js)
- Java JDK (v11 or later, for Kafka Streams)
-
Clone the repository
git clone <repository-url> cd session-mcp-demo
-
Install dependencies
npm install
-
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
-
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
hotelstopic
- Create the necessary Kafka topics (
-
Start the Kafka Streams application
npm run kafka-streams
This will build and run the Java application that processes hotel view events.
-
Start the development server
npm run dev
-
Open your browser Visit http://localhost:3000 to see the application in action.
-
Seed the AI Chatbot Context To get the most out of the AI travel assistant:
- Use the search filters to select a location (e.g., "New York")
- Browse through several hotels in that location
- The chatbot will use your browsing history to provide more relevant recommendations
- Try asking questions like "What are the best hotels in this area?" or "Which hotel would you recommend for a family?"
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
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 featurenpm run dev- Start Next.js development servernpm run build- Build the applicationnpm run start- Start the production servernpm run lint- Run ESLintnpm run generate-hotels- Generate new hotel datanpm run init-kafka- Initialize Kafka topics and load datanpm run load-hotels- Reload hotel data into Kafkanpm run kafka-streams- Build and run the Kafka Streams application
This project is licensed under the MIT License - see the LICENSE file for details.