How shohan-nub/nubhome works
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: schemas/index.ts Rental data schemas · db/index.ts Drizzle database runtime · house.repository.ts Domain repositories · page.tsx Root page
Components 20
Next.js UI
- App layout
src/app/layout.tsx - Root page · Minimal browser entry point.
src/app/page.tsx
HTTP API
- Houses API · Collection and item HTTP endpoints.
src/app/api/houses/route.ts - Booking API · Booking endpoints include ID-scoped operations.
src/app/api/booking/[id]/route.ts - Favorites API
src/app/api/favorites/route.ts - Payment API
src/app/api/payment/route.ts - Users, categories and images API
Domain layer
- House service
src/services/house.service.ts - Booking service · Orchestrates reservation workflows.
src/services/booking.service.ts - Payment service · Orchestrates payment workflows.
src/services/payment.service.ts
Data and infrastructure
- Domain repositories · Entity-specific repositories isolate database access.
src/repositories/house.repository.ts - Favorite repository
src/repositories/favorite.repository.ts - User repository
src/repositories/user.repository.ts - Drizzle database runtime · Centralized database connectivity.
src/db/index.ts - Rental data schemas · Defines houses, bookings, payments, users, categories, images, and favorites.
src/db/schemas/index.ts - House schema
src/db/schemas/house.ts - Booking schema
src/db/schemas/booking.ts - Payment schema
src/db/schemas/payment.ts - SQL migrations · Versioned SQL evolves the persistent schema.
src/db/migrations/0000_cool_the_fallen.sql - Local infrastructure · Provides containerized local dependencies, including the database.
docker-compose.yml
Connections 19
- 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