A **Next.js ** AI + Booking System app using Google Gemini, RabbitMQ, MongoDB, and Redis.
Live: next15-ai.vercel.app
- React 19, Turbopack, caching,
<Form>
, and new async APIs - Styled with optimized
next/font
(Geist) - TypeScript-first
- Gemini API via REST POST endpoint (
/api/gemini
) - Accepts prompt input and returns model-generated responses
- Uses
gemini-1.5-flash
model
- Seats booking with unique
bookingId
+messageId
for idempotency - MongoDB used for persistent bookings
- Redis for temporary seat lock logic
- Handles booking conflicts and concurrency
- Bookings pushed to RabbitMQ queue
worker.ts
processes each message (deduplicates, validates, stores)- Implements retry logic with headers
- Failed bookings go to dead-letter queue (
booking_deadlockqueue
) - MongoDB/Redis connected in worker
- Upstash Redis, Cloudamqp
/
├── app/ # Next.js
│ └── api/ # API endpoints (e.g., gemini route)
├── lib/ # Shared modules (RabbitMQ, Redis, DB)
├── api-models/ # Mongoose schema (Booking)
├── worker/ # RabbitMQ booking worker (worker.ts)
├── public/
├── types/ # Type definitions
├── utils/ # Constants (e.g., queue name, delay)
├── .env.local # Your secrets (not committed)
└── README.md
git clone https://github.com/htoann/Next15AI.git
cd Next15AI
pnpm install
RABBIT_URL=amqp://localhost
MONGODB_URI=mongodb://localhost:27017/next15ai
REDIS_URL=redis://localhost:6379
GEMINI_API_KEY=your_google_gemini_key
pnpm dev
pnpm start:worker
Queue a booking to RabbitMQ
Processes messages from queue with retry and DLQ fallback
Handles AI prompts, calls Gemini API
- Seat IDs locked via Redis to prevent race conditions
- Retry count tracked in message headers
bookingId
andmessageId
used for idempotency- Errors routed to
booking_deadlockqueue
afterMAX_RETRIES
MIT