# tanjim-islam/homiestay architecture

> Architecture diagram of the GitHub repository tanjim-islam/homiestay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tanjim-islam/homiestay
- Repository: https://github.com/tanjim-islam/homiestay

## Overview

1. This repository is an Airbnb-style marketplace built on Next.js App Router. The core domain is centered on users, listings, favorites, reservations, and user-owned properties/trips.

2. The app is split into three main layers: route-level pages under `app/`, reusable UI components under `app/components/`, and data-access/server logic under `app/actions/`, `app/api/`, and `app/libs/`.

3. The primary UI shell is `app/layout.tsx`, which wires global styling, providers, and site-wide chrome like the navbar. Most pages are composed from small, reusable components rather than page-specific markup.

4. Client-side interaction is concentrated in modal and hook systems. Hooks such as `useLoginModal`, `useRegisterModal`, `useRentModal`, `useSearchModal`, and `useFavorite` manage shared UI state, while modal components trigger auth, search, and listing-creation flows.

5. Data access is split between server actions and API routes. The `app/actions/*` files fetch current user, listings, reservations, and favorites for server-rendered pages, while `app/api/*` exposes CRUD endpoints for listings, reservations, favorites, and registration.

6. The persistent data boundary is Prisma. `app/libs/prismadb.ts` is the database client, backed by the Prisma schema in `prisma/schema.prisma`, and all listing/reservation/favorite persistence flows ultimately go through this layer.

7. Authentication is handled separately through NextAuth in `pages/api/auth/[...nextauth].ts`. Session-aware UI and protected operations rely on this auth layer, and `middleware.ts` likely enforces access control or redirects for authenticated routes.

8. The main user journeys map cleanly to route groups:
   - `/` for browsing listings
   - `/listings/[listingId]` for a listing detail and reservation view
   - `/favorites` for saved listings
   - `/trips` for guest reservations
   - `/properties` for host-owned listings
   - `/reservations` for host reservation management

9. Listing creation and management are host-centric. The `RentModal` plus inputs like `CategoryInput`, `CountrySelect`, `ImageUpload`, `Counter`, and `Calendar` feed listing metadata into the listings API and Prisma-backed store.

10. Reservation and favorites flows are user-centric. `HeartButton` and `useFavorite` toggle saved listings through the favorites endpoints, while `ListingReservation` and the reservations routes manage date-based booking records.

11. Several browser-only integrations are isolated behind `ClientOnly` and provider wrappers. `Map` handles geospatial display, `crisp-chat.tsx` and `crisp-provider.tsx` integrate live chat, and `ToasterProvider` handles user feedback notifications.

12. The component structure is intentionally domain-oriented: navbar, listing, inputs, and modal folders each represent a boundary in the architecture. That makes the diagram easy to draw as a UI shell feeding into feature components, which then call shared hooks and server-backed APIs.

13. Overall data flow: user interaction in client components → shared modal/hook state → server actions or API routes → Prisma/database → updated server-rendered pages or client refreshes. The app is therefore a hybrid server/client Next.js application with a clearly defined auth, persistence, and feature-routing layer.

Main entry points: [`app/hooks/useSearchModal.ts`](https://github.com/tanjim-islam/homiestay/blob/master/app/hooks/useSearchModal.ts) (Hooks), [`app/layout.tsx`](https://github.com/tanjim-islam/homiestay/blob/master/app/layout.tsx) (Layout), [`app/components/modals/Modal.tsx`](https://github.com/tanjim-islam/homiestay/blob/master/app/components/modals/Modal.tsx) (Modals), [`app/api/listings/route.ts`](https://github.com/tanjim-islam/homiestay/blob/master/app/api/listings/route.ts) (Listings API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app_shell["App shell"]
  node_app_layout["Layout<br/>Next.js shell<br/>[layout.tsx]"]
  node_navbar["Navbar<br/>site chrome<br/>[Navbar.tsx]"]
  node_modals["Modals<br/>ui flows<br/>[Modal.tsx]"]
  node_hooks(("Hooks<br/>client state<br/>[useSearchModal.ts]"))
  node_clients["Client helpers<br/>browser-only<br/>[ClientOnly.tsx]"]
end

subgraph group_group_journeys["User journeys"]
  node_home_page["Browse<br/>listing feed<br/>[page.tsx]"]
  node_listing_page["Listing detail<br/>reservation view<br/>[page.tsx]"]
  node_favorites_page["Favorites<br/>saved listings<br/>[page.tsx]"]
  node_trips_page["Trips<br/>guest reservations<br/>[page.tsx]"]
  node_properties_page["Properties<br/>host listings<br/>[page.tsx]"]
  node_reservations_page["Reservations<br/>host bookings<br/>[page.tsx]"]
end

subgraph group_group_data["Data layer"]
  node_listing_actions["Listing actions<br/>server actions<br/>[getListings.ts]"]
  node_reservation_actions["Reservation actions<br/>server actions<br/>[getReservations.ts]"]
  node_favorite_actions["Favorite actions<br/>server actions"]
  node_listing_api["Listings API<br/>CRUD endpoints<br/>[route.ts]"]
  node_reservation_api["Reservations API<br/>CRUD endpoints<br/>[route.ts]"]
  node_favorite_api["Favorites API<br/>toggle endpoint<br/>[route.ts]"]
  node_register_api["Register API<br/>auth endpoint<br/>[route.ts]"]
  node_prisma[("Prisma DB<br/>database client<br/>[prismadb.ts]")]
end

subgraph group_group_auth["Auth & state"]
  node_nextauth{{"NextAuth<br/>session auth<br/>[[...nextauth].ts]"}}
  node_middleware{{"Middleware<br/>route guard<br/>[middleware.ts]"}}
end

node_app_layout -->|"renders"| node_navbar
node_app_layout -->|"mounts"| node_modals
node_app_layout -->|"wraps"| node_clients
node_modals -->|"uses"| node_hooks
node_navbar -->|"opens"| node_hooks
node_home_page -->|"loads"| node_listing_actions
node_listing_page -->|"loads"| node_listing_actions
node_listing_page -->|"checks"| node_reservation_actions
node_favorites_page -->|"loads"| node_favorite_actions
node_trips_page -->|"loads"| node_reservation_actions
node_properties_page -->|"loads"| node_listing_actions
node_reservations_page -->|"loads"| node_reservation_actions
node_hooks -->|"creates"| node_listing_api
node_hooks -->|"registers"| node_register_api
node_hooks -->|"toggles"| node_favorite_api
node_modals -->|"submits"| node_listing_api
node_listing_api -->|"persists"| node_prisma
node_reservation_api -->|"persists"| node_prisma
node_favorite_api -->|"persists"| node_prisma
node_register_api -->|"authenticates"| node_nextauth
node_middleware -->|"protects"| node_nextauth
node_clients -->|"reads session"| node_nextauth

click node_app_layout "https://github.com/tanjim-islam/homiestay/blob/master/app/layout.tsx"
click node_navbar "https://github.com/tanjim-islam/homiestay/blob/master/app/components/navbar/Navbar.tsx"
click node_modals "https://github.com/tanjim-islam/homiestay/blob/master/app/components/modals/Modal.tsx"
click node_hooks "https://github.com/tanjim-islam/homiestay/blob/master/app/hooks/useSearchModal.ts"
click node_clients "https://github.com/tanjim-islam/homiestay/blob/master/app/components/ClientOnly.tsx"
click node_home_page "https://github.com/tanjim-islam/homiestay/blob/master/app/page.tsx"
click node_listing_page "https://github.com/tanjim-islam/homiestay/blob/master/app/listings/[listingId]/page.tsx"
click node_favorites_page "https://github.com/tanjim-islam/homiestay/blob/master/app/favorites/page.tsx"
click node_trips_page "https://github.com/tanjim-islam/homiestay/blob/master/app/trips/page.tsx"
click node_properties_page "https://github.com/tanjim-islam/homiestay/blob/master/app/properties/page.tsx"
click node_reservations_page "https://github.com/tanjim-islam/homiestay/blob/master/app/reservations/page.tsx"
click node_listing_actions "https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getListings.ts"
click node_reservation_actions "https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getReservations.ts"
click node_favorite_actions "https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getFavoriteListings.ts"
click node_listing_api "https://github.com/tanjim-islam/homiestay/blob/master/app/api/listings/route.ts"
click node_reservation_api "https://github.com/tanjim-islam/homiestay/blob/master/app/api/reservations/route.ts"
click node_favorite_api "https://github.com/tanjim-islam/homiestay/blob/master/app/api/favorites/[listingId]/route.ts"
click node_register_api "https://github.com/tanjim-islam/homiestay/blob/master/app/api/register/route.ts"
click node_prisma "https://github.com/tanjim-islam/homiestay/blob/master/app/libs/prismadb.ts"
click node_nextauth "https://github.com/tanjim-islam/homiestay/blob/master/pages/api/auth/[...nextauth].ts"
click node_middleware "https://github.com/tanjim-islam/homiestay/blob/master/middleware.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_layout,node_navbar,node_modals,node_hooks,node_clients toneBlue
class node_home_page,node_listing_page,node_favorites_page,node_trips_page,node_properties_page,node_reservations_page toneAmber
class node_listing_actions,node_reservation_actions,node_favorite_actions,node_listing_api,node_reservation_api,node_favorite_api,node_register_api,node_prisma toneMint
class node_nextauth,node_middleware toneRose
```

## Components

### App shell

Global layout, shared UI, modals, hooks, and client-only integrations.

- [Layout](https://github.com/tanjim-islam/homiestay/blob/master/app/layout.tsx): Next.js shell · Global app layout that wires providers, chrome, and shared page structure. · `app/layout.tsx`
- [Navbar](https://github.com/tanjim-islam/homiestay/blob/master/app/components/navbar/Navbar.tsx): site chrome · Top-level navigation and search entry point. · `app/components/navbar/Navbar.tsx`
- [Modals](https://github.com/tanjim-islam/homiestay/blob/master/app/components/modals/Modal.tsx): ui flows · Shared modal system for login, register, search, and rent flows. · `app/components/modals/Modal.tsx`
- [Hooks](https://github.com/tanjim-islam/homiestay/blob/master/app/hooks/useSearchModal.ts): client state · Shared UI state for auth, search, rent, favorites, and country selection. · `app/hooks/useSearchModal.ts`
- [Client helpers](https://github.com/tanjim-islam/homiestay/blob/master/app/components/ClientOnly.tsx): browser-only · Client-only wrappers and integrations such as maps, chat, and toasts. · `app/components/ClientOnly.tsx`

### User journeys

Main route-level experiences for browsing, hosting, and reservations.

- [Browse](https://github.com/tanjim-islam/homiestay/blob/master/app/page.tsx): listing feed · Home route for browsing available listings. · `app/page.tsx`
- [Listing detail](https://github.com/tanjim-islam/homiestay/blob/master/app/listings/[listingId]/page.tsx): reservation view · Single-listing page with details, map, and booking flow. · `app/listings/[listingId]/page.tsx`
- [Favorites](https://github.com/tanjim-islam/homiestay/blob/master/app/favorites/page.tsx): saved listings · Saved listings experience for the current user. · `app/favorites/page.tsx`
- [Trips](https://github.com/tanjim-islam/homiestay/blob/master/app/trips/page.tsx): guest reservations · Guest-facing reservation history and upcoming stays. · `app/trips/page.tsx`
- [Properties](https://github.com/tanjim-islam/homiestay/blob/master/app/properties/page.tsx): host listings · Host-owned listings management view. · `app/properties/page.tsx`
- [Reservations](https://github.com/tanjim-islam/homiestay/blob/master/app/reservations/page.tsx): host bookings · Host reservation management view. · `app/reservations/page.tsx`

### Data layer

Server actions, API routes, and database access.

- [Listing actions](https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getListings.ts): server actions · Server-side listing fetchers used by rendered pages. · `app/actions/getListings.ts`
- [Reservation actions](https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getReservations.ts): server actions · Server-side reservation fetchers for trips and host reservations. · `app/actions/getReservations.ts`
- [Favorite actions](https://github.com/tanjim-islam/homiestay/blob/master/app/actions/getFavoriteListings.ts): server actions · Server-side favorite fetchers used by saved-listing views. · `app/actions/getFavoriteListings.ts`
- [Listings API](https://github.com/tanjim-islam/homiestay/blob/master/app/api/listings/route.ts): CRUD endpoints · Create, update, and fetch listing records through route handlers. · `app/api/listings/route.ts`
- [Reservations API](https://github.com/tanjim-islam/homiestay/blob/master/app/api/reservations/route.ts): CRUD endpoints · Create, update, and delete reservation records through route handlers. · `app/api/reservations/route.ts`
- [Favorites API](https://github.com/tanjim-islam/homiestay/blob/master/app/api/favorites/[listingId]/route.ts): toggle endpoint · Favorite add/remove endpoints for a specific listing. · `app/api/favorites/[listingId]/route.ts`
- [Register API](https://github.com/tanjim-islam/homiestay/blob/master/app/api/register/route.ts): auth endpoint · User registration endpoint used by the auth modal flow. · `app/api/register/route.ts`
- [Prisma DB](https://github.com/tanjim-islam/homiestay/blob/master/app/libs/prismadb.ts): database client · Database client boundary for persistence. · `app/libs/prismadb.ts`

### Auth & state

Session handling and access control boundaries.

- [NextAuth](https://github.com/tanjim-islam/homiestay/blob/master/pages/api/auth/[...nextauth].ts): session auth · Authentication and session handling for protected routes and user-aware UI. · `pages/api/auth/[...nextauth].ts`
- [Middleware](https://github.com/tanjim-islam/homiestay/blob/master/middleware.ts): route guard · Access-control and redirect layer around authenticated routes. · `middleware.ts`

## Connections

- Layout → Navbar: renders · The global layout includes the top navigation shell.
- Layout → Modals: mounts · Shared modal overlays are available across the app.
- Layout → Client helpers: wraps · Client-only providers and integrations are initialized here.
- Modals → Hooks: uses · Modal visibility and interaction state are managed by hooks.
- Navbar → Hooks: opens · Navbar actions trigger search and auth modals.
- Browse → Listing actions: loads · Browse page uses server data for listings.
- Listing detail → Listing actions: loads · Listing detail page fetches the selected listing.
- Listing detail → Reservation actions: checks · Reservation info is used to compute booking state.
- Favorites → Favorite actions: loads · Saved listings page fetches favorite items.
- Trips → Reservation actions: loads · Trips page fetches user reservation history.
- Properties → Listing actions: loads · Host properties page is driven by listing data.
- Reservations → Reservation actions: loads · Host reservations page is driven by reservation data.
- Hooks → Listings API: creates · Rent flow submits new listings through the API.
- Hooks → Register API: registers · Auth modal can register new users through the API.
- Hooks → Favorites API: toggles · Favorite hook drives listing favorite state changes.
- Modals → Listings API: submits · Rent modal sends listing metadata to persistence.
- Listings API → Prisma DB: persists · Listings are stored through Prisma.
- Reservations API → Prisma DB: persists · Reservations are stored through Prisma.
- Favorites API → Prisma DB: persists · Favorite relationships are stored through Prisma.
- Register API → NextAuth: authenticates · Registration works alongside the session auth layer.
- Middleware → NextAuth: protects · Route protection is based on authentication state.
- Client helpers → NextAuth: reads session · Client-only UI adapts to authenticated state.
