Interactive Next.js resort map where guests can book poolside cabanas by clicking map tiles.
./run.sh --map ./map.ascii --bookings ./bookings.jsonNotes:
--mapand--bookingsare optional. Defaults are./map.asciiand./bookings.json.- Backward-compatible positional args also work:
./run.sh ./map.ascii ./bookings.json.
Returns the render-ready map and availability data.
Response includes:
width,heighttiles: Cell[][]where each cell has:type(W,p,#,c,.)asset(tile image path in/public/assets)rotation(0 | 90 | 180 | 270when needed)- optional
cabanaId - optional
isBooked
legendavailability(total,booked,available)
Books one cabana for a validated guest.
Request body:
{
"cabanaId": "r12c4",
"room": "204",
"guestName": "Rita Cook"
}Success response (201):
{
"message": "Cabana booked successfully.",
"booking": {
"cabanaId": "r12c4",
"room": "204",
"guestName": "Rita Cook",
"bookedAt": "2026-03-24T12:34:56.000Z"
}
}Error response (4xx):
{
"message": "Human-readable error message."
}Run all tests:
npm run testCoverage focus:
- Map parsing and path auto-shaping logic
- Booking validation rules and one-cabana-per-guest behavior
- API route behavior (
/api/map,/api/book) - Frontend interaction (map rendering, booking form, success refresh, unavailable/error feedback)
- Kept backend state in memory to match the requirement and keep complexity low.
- Split business logic into
lib/*so API routes remain thin and testable. - Used a REST-only frontend data flow (
/api/map,/api/book) instead of server actions to keep API behavior explicit. - Implemented path tile auto-shaping using local neighbor topology (N/E/S/W) and rotation metadata for clear visual paths.
- Chose unit/integration-style automated tests (Vitest + RTL) to cover core behavior quickly without adding heavy E2E setup.
- AI workflow notes:
AI.md - App screenshot:
screenshot.png