# shohan-nub/nubhome architecture

> Architecture diagram of the GitHub repository shohan-nub/nubhome, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shohan-nub/nubhome
- Repository: https://github.com/shohan-nub/nubhome

## Overview

#### Purpose and Entry Points
This is a Next.js App Router application exposing a property-rental domain backend alongside a minimal browser entry point. The UI begins at `src/app/page.tsx` under shared application layout `src/app/layout.tsx`. Resource APIs are implemented as Next.js route handlers beneath `src/app/api`.

#### HTTP API Boundary
The API provides collection and item endpoints for users, houses, categories, house images, favorites, bookings, and payments. Each resource has a collection handler and typically an ID-scoped handler, e.g. `src/app/api/houses/route.ts`, `src/app/api/houses/[id]/route.ts`, and `src/app/api/booking/[id]/route.ts`. Route handlers are the external control boundary: they receive HTTP requests and delegate domain work below the transport layer.

#### Layered Domain Operations
Each resource follows a route → service → repository structure. Services hold use-case orchestration and are isolated per domain: `src/services/booking.service.ts`, `src/services/house.service.ts`, and `src/services/payment.service.ts`. This makes booking/payment workflows and property-management behavior separable from HTTP and persistence concerns.

#### Persistence Access Layer
Repositories encapsulate database reads and writes for each domain entity, including `src/repositories/house.repository.ts`, `src/repositories/favorite.repository.ts`, and `src/repositories/user.repository.ts`. Services should depend on these repositories rather than directly coupling API handlers to SQL or ORM operations.

#### Relational Data Model
Drizzle schema modules define the core rental marketplace entities and their relationships: properties in `src/db/schemas/house.ts`, reservations in `src/db/schemas/booking.ts`, payment records in `src/db/schemas/payment.ts`, plus user, category, image, and favorite models. `src/db/schemas/index.ts` is the likely schema aggregation boundary.

#### Database Runtime and Evolution
Database connectivity is centralized in `src/db/index.ts`; Drizzle configuration is at `drizzle.config.ts`. Versioned SQL migrations in `src/db/migrations/0000_cool_the_fallen.sql` and `src/db/migrations/0001_pink_roughhouse.sql` evolve the persistent schema independently of application deployment. `docker-compose.yml` indicates containerized local infrastructure, likely including the database required by this layer.

#### Primary Flows and Boundaries
Property discovery and management flow from `/api/houses` through house services/repositories to house, category, and image records. User-centric flows traverse favorites, bookings, and payments: API handlers such as `src/app/api/favorites/route.ts` and `src/app/api/payment/route.ts` invoke their services, which persist through the corresponding repository and schema. The frontend is currently limited in visible structure to the root page; the API and database layers are the architecture-defining product surface.

Main entry points: [`src/db/schemas/index.ts`](https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/index.ts) (Rental data schemas), [`src/db/index.ts`](https://github.com/shohan-nub/nubhome/blob/main/src/db/index.ts) (Drizzle database runtime), [`src/repositories/house.repository.ts`](https://github.com/shohan-nub/nubhome/blob/main/src/repositories/house.repository.ts) (Domain repositories), [`src/app/page.tsx`](https://github.com/shohan-nub/nubhome/blob/main/src/app/page.tsx) (Root page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Next.js UI"]
  node_layout["App layout<br/>Next.js layout<br/>[layout.tsx]"]
  node_page["Root page<br/>Next.js page<br/>[page.tsx]"]
end

subgraph group_api["HTTP API"]
  node_house_api["Houses API<br/>route handlers<br/>[route.ts]"]
  node_booking_api["Booking API<br/>route handlers<br/>[route.ts]"]
  node_favorites_api["Favorites API<br/>route handler<br/>[route.ts]"]
  node_payment_api["Payment API<br/>route handler<br/>[route.ts]"]
  node_other_api["Users, categories and images API<br/>route handlers"]
end

subgraph group_domain["Domain layer"]
  node_house_service["House service<br/>domain service<br/>[house.service.ts]"]
  node_booking_service["Booking service<br/>domain service<br/>[booking.service.ts]"]
  node_payment_service["Payment service<br/>domain service<br/>[payment.service.ts]"]
end

subgraph group_data["Data and infrastructure"]
  node_repositories["Domain repositories<br/>persistence ports"]
  node_favorite_repository["Favorite repository"]
  node_user_repository["User repository<br/>[user.repository.ts]"]
  node_db_runtime[("Drizzle database runtime<br/>database client<br/>[index.ts]")]
  node_schemas["Rental data schemas<br/>Drizzle schemas<br/>[index.ts]"]
  node_house_schema["House schema<br/>Drizzle schema<br/>[house.ts]"]
  node_booking_schema["Booking schema<br/>Drizzle schema<br/>[booking.ts]"]
  node_payment_schema["Payment schema<br/>Drizzle schema<br/>[payment.ts]"]
  node_migrations["SQL migrations<br/>schema evolution"]
  node_local_infra{{"Local infrastructure<br/>Docker Compose<br/>[docker-compose.yml]"}}
end

node_layout -->|"renders"| node_page
node_page -->|"uses"| node_house_api
node_house_api -->|"delegates"| node_house_service
node_booking_api -->|"delegates"| node_booking_service
node_payment_api -->|"delegates"| node_payment_service
node_favorites_api -->|"persists via"| node_favorite_repository
node_other_api -->|"uses"| node_user_repository
node_house_service -->|"uses"| node_repositories
node_booking_service -->|"uses"| node_repositories
node_payment_service -->|"uses"| node_repositories
node_repositories -->|"queries through"| node_db_runtime
node_favorite_repository -->|"queries through"| node_db_runtime
node_user_repository -->|"queries through"| node_db_runtime
node_db_runtime -->|"maps data with"| node_schemas
node_schemas -->|"aggregates"| node_house_schema
node_schemas -->|"aggregates"| node_booking_schema
node_schemas -->|"aggregates"| node_payment_schema
node_migrations -.->|"evolves"| node_schemas
node_local_infra -.->|"hosts locally"| node_db_runtime

click node_layout "https://github.com/shohan-nub/nubhome/blob/main/src/app/layout.tsx"
click node_page "https://github.com/shohan-nub/nubhome/blob/main/src/app/page.tsx"
click node_house_api "https://github.com/shohan-nub/nubhome/blob/main/src/app/api/houses/route.ts"
click node_booking_api "https://github.com/shohan-nub/nubhome/blob/main/src/app/api/booking/%5Bid%5D/route.ts"
click node_favorites_api "https://github.com/shohan-nub/nubhome/blob/main/src/app/api/favorites/route.ts"
click node_payment_api "https://github.com/shohan-nub/nubhome/blob/main/src/app/api/payment/route.ts"
click node_house_service "https://github.com/shohan-nub/nubhome/blob/main/src/services/house.service.ts"
click node_booking_service "https://github.com/shohan-nub/nubhome/blob/main/src/services/booking.service.ts"
click node_payment_service "https://github.com/shohan-nub/nubhome/blob/main/src/services/payment.service.ts"
click node_repositories "https://github.com/shohan-nub/nubhome/blob/main/src/repositories/house.repository.ts"
click node_favorite_repository "https://github.com/shohan-nub/nubhome/blob/main/src/repositories/favorite.repository.ts"
click node_user_repository "https://github.com/shohan-nub/nubhome/blob/main/src/repositories/user.repository.ts"
click node_db_runtime "https://github.com/shohan-nub/nubhome/blob/main/src/db/index.ts"
click node_schemas "https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/index.ts"
click node_house_schema "https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/house.ts"
click node_booking_schema "https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/booking.ts"
click node_payment_schema "https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/payment.ts"
click node_migrations "https://github.com/shohan-nub/nubhome/blob/main/src/db/migrations/0000_cool_the_fallen.sql"
click node_local_infra "https://github.com/shohan-nub/nubhome/blob/main/docker-compose.yml"

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_layout,node_page toneBlue
class node_house_api,node_booking_api,node_favorites_api,node_payment_api,node_other_api toneAmber
class node_house_service,node_booking_service,node_payment_service toneMint
class node_repositories,node_favorite_repository,node_user_repository,node_db_runtime,node_schemas,node_house_schema,node_booking_schema,node_payment_schema,node_migrations,node_local_infra toneRose
```

## Components

### Next.js UI

- [App layout](https://github.com/shohan-nub/nubhome/blob/main/src/app/layout.tsx): Next.js layout · `src/app/layout.tsx`
- [Root page](https://github.com/shohan-nub/nubhome/blob/main/src/app/page.tsx): Next.js page · Minimal browser entry point. · `src/app/page.tsx`

### HTTP API

- [Houses API](https://github.com/shohan-nub/nubhome/blob/main/src/app/api/houses/route.ts): route handlers · Collection and item HTTP endpoints. · `src/app/api/houses/route.ts`
- [Booking API](https://github.com/shohan-nub/nubhome/blob/main/src/app/api/booking/%5Bid%5D/route.ts): route handlers · Booking endpoints include ID-scoped operations. · `src/app/api/booking/[id]/route.ts`
- [Favorites API](https://github.com/shohan-nub/nubhome/blob/main/src/app/api/favorites/route.ts): route handler · `src/app/api/favorites/route.ts`
- [Payment API](https://github.com/shohan-nub/nubhome/blob/main/src/app/api/payment/route.ts): route handler · `src/app/api/payment/route.ts`
- **Users, categories and images API**: route handlers

### Domain layer

- [House service](https://github.com/shohan-nub/nubhome/blob/main/src/services/house.service.ts): domain service · `src/services/house.service.ts`
- [Booking service](https://github.com/shohan-nub/nubhome/blob/main/src/services/booking.service.ts): domain service · Orchestrates reservation workflows. · `src/services/booking.service.ts`
- [Payment service](https://github.com/shohan-nub/nubhome/blob/main/src/services/payment.service.ts): domain service · Orchestrates payment workflows. · `src/services/payment.service.ts`

### Data and infrastructure

- [Domain repositories](https://github.com/shohan-nub/nubhome/blob/main/src/repositories/house.repository.ts): persistence ports · Entity-specific repositories isolate database access. · `src/repositories/house.repository.ts`
- [Favorite repository](https://github.com/shohan-nub/nubhome/blob/main/src/repositories/favorite.repository.ts): repository · `src/repositories/favorite.repository.ts`
- [User repository](https://github.com/shohan-nub/nubhome/blob/main/src/repositories/user.repository.ts): repository · `src/repositories/user.repository.ts`
- [Drizzle database runtime](https://github.com/shohan-nub/nubhome/blob/main/src/db/index.ts): database client · Centralized database connectivity. · `src/db/index.ts`
- [Rental data schemas](https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/index.ts): Drizzle schemas · Defines houses, bookings, payments, users, categories, images, and favorites. · `src/db/schemas/index.ts`
- [House schema](https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/house.ts): Drizzle schema · `src/db/schemas/house.ts`
- [Booking schema](https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/booking.ts): Drizzle schema · `src/db/schemas/booking.ts`
- [Payment schema](https://github.com/shohan-nub/nubhome/blob/main/src/db/schemas/payment.ts): Drizzle schema · `src/db/schemas/payment.ts`
- [SQL migrations](https://github.com/shohan-nub/nubhome/blob/main/src/db/migrations/0000_cool_the_fallen.sql): schema evolution · Versioned SQL evolves the persistent schema. · `src/db/migrations/0000_cool_the_fallen.sql`
- [Local infrastructure](https://github.com/shohan-nub/nubhome/blob/main/docker-compose.yml): Docker Compose · Provides containerized local dependencies, including the database. · `docker-compose.yml`

## Connections

- App layout → Root page: renders
- Root page → Houses API: uses
- Houses API → House service: delegates
- Booking API → Booking service: delegates
- Payment API → Payment service: delegates
- Favorites API → Favorite repository: persists via
- Users, categories and images API → User repository: uses
- House service → Domain repositories: uses
- Booking service → Domain repositories: uses
- Payment service → Domain repositories: uses
- Domain repositories → Drizzle database runtime: queries through
- Favorite repository → Drizzle database runtime: queries through
- User repository → Drizzle database runtime: queries through
- Drizzle database runtime → Rental data schemas: maps data with
- Rental data schemas → House schema: aggregates
- Rental data schemas → Booking schema: aggregates
- Rental data schemas → Payment schema: aggregates
- SQL migrations → Rental data schemas: evolves
- Local infrastructure → Drizzle database runtime: hosts locally
