Skip to content

kvbxss/resort-map

Repository files navigation

Resort Map Booking

Interactive Next.js resort map where guests can book poolside cabanas by clicking map tiles.

Single command to run backend + frontend

./run.sh --map ./map.ascii --bookings ./bookings.json

Notes:

  • --map and --bookings are optional. Defaults are ./map.ascii and ./bookings.json.
  • Backward-compatible positional args also work: ./run.sh ./map.ascii ./bookings.json.

API overview

GET /api/map

Returns the render-ready map and availability data.

Response includes:

  • width, height
  • tiles: Cell[][] where each cell has:
    • type (W, p, #, c, .)
    • asset (tile image path in /public/assets)
    • rotation (0 | 90 | 180 | 270 when needed)
    • optional cabanaId
    • optional isBooked
  • legend
  • availability (total, booked, available)

POST /api/book

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."
}

Automated tests

Run all tests:

npm run test

Coverage 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)

Core design decisions and trade-offs

  • 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.

Additional deliverables

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors