Vibe Coding: Instructions
MongoDB Airbnb AI Arena (Vibe Coding Edition)
Welcome to the MongoDB Airbnb AI Arena! π
Your mission is to create the best backend possible for this Airbnb application. The frontend is already built and waiting for you, and all API endpoints are clearly defined below. Now itβs time to vibe code your backend and bring this application to life!
Your Challenge:
- β¨ Implement robust API endpoints that power the frontend
- ποΈ Build efficient MongoDB queries and data operations
- π Create powerful search and filtering capabilities
- π‘ Add creative features that make your backend stand out
- π― Focus on performance, scalability, and clean code
Whatβs Provided:
- π¨ Frontend: Fully functional React application
- π API Spec: Complete endpoint definitions and schemas
- ποΈ Database: MongoDB Atlas with sample Airbnb data
- π οΈ Tools: All the development tools you need
Your Goal: Make the frontend work flawlessly by implementing these API endpoints. Show off your skills, get creative, and build something amazing! πͺ
π Requirements
Technical Specifications:
- π Server Port: Must run on
http://localhost:5000
- π Public Link: Run on
https://<username>.<customer>.mongogameday.com/backend
- π Documentation Format: OpenAPI 3.0
- π οΈ Language: Build in any programming language you prefer
- π― Framework: Use any web framework (Express.js, FastAPI, Spring Boot, etc.)
- ποΈ Database: MongoDB Atlas (connection details provided)
Implementation Freedom:
- β¨ Your Choice: Node.js, Python, Java
- ποΈ Your Framework: Express, SpringBoot, FastAPI, Flask
- π‘ Your Style: RESTful APIs following the provided OpenAPI specification
- π Your Creativity: Add bonus features and optimizations
π API Documentation Preview
π Interactive Documentation
- π Open in Swagger Editor
- Go to Swagger Editor.
- Click on File > Import URL.
- Paste this URL:
https://raw.githubusercontent.com/simonegaiera/mongodb-airbnb-workshop/main/docs/assets/files/swagger.json
- The API documentation will load automatically.
- πΎ Download swagger.json β Local file
π― API Endpoints Overview
π Listings & Analytics (Comprehensive Listing Operations)
π Comprehensive Listing Operations: This unified section includes CRUD operations for listings, reviews management, advanced filtering using MongoDB aggregation pipelines, and statistical analysis with aggregated data operations. All core listing functionality is consolidated here for better organization.
π Atlas Search (Advanced Lexical Search Features)
π‘ Atlas Search Integration: These endpoints are designed to leverage MongoDB Atlas Search capabilities for advanced lexical search functionality including full-text search, autocomplete, and faceted search. Youβre expected to implement these features using Atlas Search indexes and operators for lexical search operations.
π§ AI & Vector Search (Advanced AI-Powered Functionality)
π§ Advanced AI-Powered Features: This unified section combines semantic search operations using MongoDB Atlas Vector Search with automated embeddings and knnBeta operator, plus AI chatbot capabilities with RAG (Retrieval-Augmented Generation), AWS Bedrock LLM integration via LangChain, and MongoDB-based conversation memory storage. All AI and vector search functionality is consolidated here for better organization.
π Results
ποΈ MongoDB Collection Schema & Performance
Understanding the listingsAndReviews
Collection
Database Usage:
- π Primary Collection: All listing-related endpoints (
/api/listingsAndReviews/*
) use thelistingsAndReviews
collection - π Atlas Search: Search endpoints (
/autocomplete
,/facet
,/search
) operate on thelistingsAndReviews
collection - π§ Vector Search: The
/vectorsearch
endpoint uses thelistingsAndReviews
collection with automated embeddings - π¬ Chat System: Chat endpoints (
/api/chat/*
) use thelistingsAndReviews
collection for RAG operations - π Results Data: Only the Results endpoints (
/api/results/*
) use data from theairbnb_arena
database
MCP Integration Available: There is a Model Context Protocol (MCP) available that can help you understand the structure and schema of the two collections. This MCP provides insights into:
- Field types and structures
- Data patterns and relationships
- Sample document formats
- Nested object schemas
Recommendation: Leverage the MCP to properly understand the MongoDB collection schema before implementing your API endpoints. This will ensure accurate field mappings, proper data validation, and efficient query construction.
Key Collection Features:
- π Rich Listing Data: Property details, amenities, location information
- β Embedded Reviews: Review arrays with dates, comments, and reviewer info
- π Geospatial Data: Location coordinates for mapping and proximity searches
- π·οΈ Categorical Fields: Property types, room types, amenities for filtering
- π° Pricing Information: Nightly rates and pricing structures
π Data Schemas
{
"_id": "string",
"listing_url": "string",
"name": "string",
"summary": "string",
"space": "string",
"description": "string",
"neighborhood_overview": "string",
"notes": "string",
"transit": "string",
"access": "string",
"interaction": "string",
"house_rules": "string",
"property_type": "string",
"room_type": "string",
"bed_type": "string",
"minimum_nights": "string",
"maximum_nights": "string",
"cancellation_policy": "string",
"last_scraped": "Date",
"calendar_last_scraped": "Date",
"accommodates": "Number",
"bedrooms": "Number",
"beds": "Number",
"number_of_reviews": "Number",
"bathrooms": "Decimal128",
"amenities": ["string"],
"price": "Decimal128",
"weekly_price": "Decimal128",
"monthly_price": "Decimal128",
"cleaning_fee": "Decimal128",
"extra_people": "Decimal128",
"guests_included": "Decimal128",
"security_deposit": "Decimal128",
"images": {
"thumbnail_url": "string",
"medium_url": "string",
"picture_url": "string",
"xl_picture_url": "string"
},
"host": {
"host_id": "string",
"host_url": "string",
"host_name": "string",
"host_location": "string",
"host_about": "string",
"host_thumbnail_url": "string",
"host_picture_url": "string",
"host_neighbourhood": "string",
"host_is_superhost": "Boolean",
"host_has_profile_pic": "Boolean",
"host_identity_verified": "Boolean",
"host_listings_count": "Number",
"host_total_listings_count": "Number",
"host_verifications": ["string"],
"host_response_time": "string",
"host_response_rate": "Number"
},
"address": {
"street": "string",
"suburb": "string",
"government_area": "string",
"market": "string",
"country": "string",
"country_code": "string",
"location": {
"type": "string",
"coordinates": ["Number"],
"is_location_exact": "Boolean"
}
},
"availability": {
"availability_30": "Number",
"availability_60": "Number",
"availability_90": "Number",
"availability_365": "Number"
},
"review_scores": {
"review_scores_accuracy": "Number",
"review_scores_cleanliness": "Number",
"review_scores_checkin": "Number",
"review_scores_communication": "Number",
"review_scores_location": "Number",
"review_scores_value": "Number",
"review_scores_rating": "Number"
},
"reviews": [
{
"_id": "string",
"date": "Date",
"listing_id": "string",
"reviewer_id": "string",
"reviewer_name": "string",
"comments": "string"
}
],
"first_review": "Date",
"last_review": "Date",
"updated_at": "Date"
}
Important Data Types:
- Decimal128: Used for precise monetary values (
price
,weekly_price
,monthly_price
,cleaning_fee
,extra_people
,guests_included
,security_deposit
,bathrooms
) - Number: Used for integers (
accommodates
,bedrooms
,beds
,number_of_reviews
, host counts, availability counts, review scores) - Date: Used for timestamps (
last_scraped
,calendar_last_scraped
,first_review
,last_review
,updated_at
, review dates) - Boolean: Used for true/false values (host verification flags, location exactness)
- Array: Used for lists (
amenities
,host_verifications
,reviews
,coordinates
) - Document: Used for nested objects (
images
,host
,address
,availability
,review_scores
)
β‘ Performance Requirements & Index Creation
Performance is Key: Your application must be fast and responsive. Slow queries will hurt user experience and your ranking in the competition!
Index Strategy: Ask your LLM to create comprehensive index definitions that cover:
- π Query Performance: Indexes for all filtering and sorting operations
- π Aggregation Support: Indexes optimized for statistics and analytics
- π Atlas Search: Full-text search indexes for autocomplete, facet, and text search
- π§ Vector Search: Vector indexes with automated embeddings for semantic search
- π Geospatial: 2dsphere indexes for location-based queries
Index Creation Options:
- Via MCP (Preferred if available):
Use the MCP to create indexes directly in your MongoDB cluster. This is the fastest way to get your indexes deployed automatically.
- Manual Creation (Fallback):
Request your LLM to generate a comprehensive mongodb_indexes.json file containing all required index definitions. You'll need to create these indexes manually in MongoDB Atlas or via your application startup code.
Required Index Types:
- β Standard Database Indexes: For basic CRUD operations and filtering
- β Atlas Search Indexes: For text search, autocomplete, and faceted search
- β Vector Search Indexes: For semantic search with automated embeddings
- β Compound Indexes: For complex queries with multiple filter criteria
- β Geospatial Indexes: For location-based searches and proximity queries
Performance Tips:
- π― Index Coverage: Ensure all your queries are covered by appropriate indexes
- π Monitor Performance: Use MongoDB Atlas Performance Advisor
- π Query Optimization: Design queries that leverage your indexes efficiently
- π Aggregation Pipelines: Optimize pipelines with proper index support
π‘ Pro Tip: Ask your LLM to analyze your API endpoints and automatically generate the optimal index strategy. A well-indexed application can be 100x faster than one without proper indexes!
π Enhanced Implementation Guide
MongoDB Collection Understanding
- Use the MCP: Leverage the available Model Context Protocol to understand the
listingsAndReviews
collection structure - Schema Exploration: Use the MCP insights to implement proper field mappings and data validation
- Query Optimization: Build efficient MongoDB queries based on the actual collection schema
Atlas Search Implementation
For the Atlas Search endpoints (/autocomplete
, /facet
, /search
):
- Search Indexes: Create appropriate Atlas Search indexes for lexical search
- Search Operators: Use Atlas Search operators like
text
,autocomplete
, andfacet
- Performance: Optimize search queries for fast response times
- Relevance: Implement proper scoring and ranking for search results
Field Mappings:
- name (for autocomplete): Enable autocomplete search on listing names
- amenities (for facet): Support faceted filtering by available amenities
- property_type (for facet): Allow filtering by property type categories
- beds (for numeric facet): Enable range filtering on number of beds
π Index Requirements:
- Lexical Search Index: Create a single Atlas Search index that supports all lexical search operations (
/search
,/facet
,/autocomplete
) using appropriate operators and analyzers
Atlas Vector Search Implementation
For the Vector Search endpoint (/vectorsearch
):
- Vector Index: Create Atlas Vector Search index with automated embeddings
- Auto Embedding: Leverage MongoDBβs automated embedding feature for seamless vector operations
- Embedding Field: Configure automated embeddings on the
description
field for semantic search capabilities
π Index Requirements:
- Vector Search Index: Create a separate vector search index specifically for the
/vectorsearch
endpoint with automated embeddings on thedescription
field- Automated Embeddings: Reference documentation at http://mongodb.com/docs/atlas/atlas-vector-search/automated-embedding/
π― Vector Search Parameters:
- numCandidates: Set to 100 for optimal performance and accuracy
- limit: Return top 10 most relevant results
π‘ Important: Ensure your MongoDB Atlas cluster is properly configured for Vector Search, including the creation of a dedicated vector search index with automated embeddings on the
description
field. Reference the latest documentation for detailed setup instructions.
Chat System Implementation
For the Chat endpoints (/chat
, /chat/clear
):
- Vector Search: Use Atlas Vector Search with automated embeddings to find relevant listings based on user queries
- LLM Integration: Connect to AWS Bedrock using LangChain for natural language processing
- Memory Management: Use LangChain to store the chat history in MongoDB collections
- RAG Architecture: Implement Retrieval-Augmented Generation for accurate, context-aware responses
- Session Handling: Maintain conversation continuity across multiple interactions
- Embedding Strategy: Use automated embeddings for both document indexing and query processing in vector operations
Development Workflow
- Explore: Use the MCP to understand the collection schema
- Index Planning: Ask LLM to create comprehensive index definitions for performance
- Index Creation: Deploy indexes via MCP or manually from generated JSON file
- Plan: Design your API endpoints based on the schema insights
- Implement: Build the REST API following the OpenAPI specification
- Test: Use the provided test cases in the
rest-lab/
folder - Optimize: Fine-tune queries and add performance improvements
- Monitor: Check query performance and adjust indexes if needed
Bonus Features (Get Creative!)
- π Caching: Implement Redis or in-memory caching for frequently accessed data
- π Analytics: Add advanced analytics and reporting endpoints
- π Rate Limiting: Implement API rate limiting for production readiness
- π Logging: Add comprehensive logging and monitoring
- π― Validation: Implement robust input validation and error handling
- π Advanced Search: Create innovative lexical search features using Atlas Search capabilities
- π§ Smart Memory: Store chat conversation history in MongoDB for personalized experiences
- π€ Intelligent Responses: Use automated vector embeddings for contextually relevant listing recommendations
- β‘ Auto Embedding: Leverage MongoDBβs automated embedding capabilities for vector search operations
π οΈ Testing
Postman Collection
Import the OpenAPI specification directly into Postman:
- Open Postman
- Click βImportβ and provide the collection file
- All endpoints will be automatically imported
VS Code Extensions
- REST Client: Create
.http
files for testing
Testing with curl
All endpoints can be tested using curl commands. See examples above or use the βTry it outβ feature in Swagger UI to generate curl commands automatically.
π Authentication
Currently, the API does not require authentication.