# sudeepjoshi456/imageholidays architecture

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

- Interactive diagram: https://gitdiagram.com/sudeepjoshi456/imageholidays
- Repository: https://github.com/sudeepjoshi456/imageholidays

## Overview

#### Purpose and entry points
Image Holidays is a full-stack Next.js car-rental catalog for a Nepal travel agency. It supports public vehicle discovery and agency contact, plus a single-admin fleet-management workflow; bookings, payments, and customer accounts are intentionally absent. The App Router root is `src/app/layout.tsx`; public routes are grouped under `src/app/(public)/`, while administration begins at `src/app/admin/page.tsx`.

#### Public catalog experience
Public pages render the home/search, vehicle catalog, vehicle details, agency information, and contact surfaces. Catalog and detail routes use slugs as the public vehicle identity:
- `src/app/(public)/page.tsx`
- `src/app/(public)/cars/page.tsx`
- `src/app/(public)/cars/[slug]/page.tsx`

Shared catalog presentation is split into cards, filters, galleries, and hero search components under `src/components/CarCard.tsx`, `src/components/CatalogFilters.tsx`, and `src/components/CarGallery.tsx`.

#### Domain and persistence boundary
PostgreSQL is the system of record, accessed through Prisma. The schema and initial migration define the data model, while seeding provisions the sole admin and sample fleet. Server-side data access and derived car presentation logic are centralized in library modules:
- `prisma/schema.prisma`
- `src/lib/prisma.ts`
- `src/lib/cars.ts`

Deployment requires a hosted PostgreSQL provider and Prisma migrations; Prisma 7 uses the PostgreSQL driver adapter at runtime.

#### Admin fleet lifecycle
The protected admin area provides fleet overview, create/edit forms, deletion, and photo management. Admin mutations are implemented as server-side actions/validation rather than a separate CRUD API layer:
- `src/app/admin/cars/new/page.tsx`
- `src/app/admin/cars/[id]/edit/page.tsx`
- `src/components/admin/CarForm.tsx`
- `src/lib/actions.ts`
- `src/lib/validations.ts`

The control flow is: authenticate admin → access fleet/dashboard → submit validated create/update/delete action → persist through Prisma → refresh rendered catalog/admin state.

#### Authentication and authorization
NextAuth credentials authentication gates the single-admin workflow. The catch-all auth route exposes NextAuth handlers, auth configuration lives in the library layer, and middleware protects admin routes:
- `src/app/api/auth/[...nextauth]/route.ts`
- `src/lib/auth.ts`
- `src/lib/login-action.ts`
- `src/middleware.ts`

Credentials are seeded/configured from `ADMIN_EMAIL` and `ADMIN_PASSWORD`; `AUTH_SECRET` and `AUTH_URL` support session security and deployment origin configuration.

#### External service boundaries
Vercel Blob is isolated behind the upload route used by admin photo management; missing credentials produce upload errors without preventing seeded remote-image demos:
- `src/app/api/upload/route.ts`
- `src/components/admin/PhotoManager.tsx`

The contact workflow is a server action that sends through Resend when configured, otherwise logs demo submissions server-side:
- `src/components/ContactForm.tsx`
- `src/lib/actions.ts`

#### Runtime and deployment
The application runs on Next.js 16, TypeScript, and Tailwind CSS, targeting Vercel (`vercel.json`). Required runtime configuration connects PostgreSQL, NextAuth, agency contact CTA values, and optionally Vercel Blob and Resend. Database evolution is represented by `prisma/migrations/`, with initial/demo state created through `prisma/seed.ts`.

Main entry points: [`src/lib/actions.ts`](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/actions.ts) (Server actions), [`src/app/admin/page.tsx`](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/admin/page.tsx) (Fleet dashboard), [`src/lib/prisma.ts`](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/prisma.ts) (Prisma client), [`src/app/(public)/cars/page.tsx`](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/(public)/cars/page.tsx) (Catalog pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public catalog"]
  node_public_pages["Catalog pages<br/>public routes<br/>[page.tsx]"]
  node_catalog_ui["Catalog UI<br/>presentation components<br/>[CarCard.tsx]"]
  node_cars_query["Car read model<br/>domain data access<br/>[cars.ts]"]
  node_contact_form["Contact form<br/>public component<br/>[ContactForm.tsx]"]
end

subgraph group_admin["Admin workflow"]
  node_admin_pages["Fleet dashboard<br/>protected admin routes<br/>[page.tsx]"]
  node_car_form["Car form<br/>admin component<br/>[CarForm.tsx]"]
  node_photo_manager["Photo manager<br/>admin component<br/>[PhotoManager.tsx]"]
  node_actions["Server actions<br/>mutation and contact actions<br/>[actions.ts]"]
  node_validation["Input validation<br/>validation layer<br/>[validations.ts]"]
  node_middleware["Admin route guard<br/>Next.js middleware<br/>[middleware.ts]"]
  node_nextauth["NextAuth handlers<br/>auth API route<br/>[route.ts]"]
  node_auth_config["Credentials auth<br/>auth configuration<br/>[auth.ts]"]
end

subgraph group_platform["Data &amp; integrations"]
  node_prisma_client["Prisma client<br/>persistence adapter<br/>[prisma.ts]"]
  node_postgres[("PostgreSQL<br/>system of record<br/>[schema.prisma]")]
  node_migrations["Migrations<br/>database evolution"]
  node_seed["Seed data<br/>database bootstrap<br/>[seed.ts]"]
  node_upload_route["Blob upload route<br/>upload API route<br/>[route.ts]"]
  node_vercel_blob[("Vercel Blob<br/>object storage")]
  node_resend["Resend<br/>email service"]
  node_vercel{{"Vercel<br/>deployment platform<br/>[vercel.json]"}}
end

node_app["Next.js App Router<br/>application runtime<br/>[layout.tsx]"]

node_app -->|"renders"| node_public_pages
node_public_pages -->|"composes"| node_catalog_ui
node_public_pages -->|"loads cars"| node_cars_query
node_catalog_ui -->|"displays"| node_cars_query
node_contact_form -->|"submits"| node_actions
node_app -->|"renders"| node_admin_pages
node_middleware -->|"protects"| node_admin_pages
node_nextauth -->|"uses"| node_auth_config
node_auth_config -->|"verifies admin"| node_prisma_client
node_admin_pages -->|"hosts"| node_car_form
node_admin_pages -->|"hosts"| node_photo_manager
node_car_form -->|"validates"| node_validation
node_car_form -->|"mutates"| node_actions
node_actions -->|"validates"| node_validation
node_actions -->|"persists fleet"| node_prisma_client
node_actions -.->|"sends contact"| node_resend
node_photo_manager -->|"uploads photos"| node_upload_route
node_upload_route -->|"stores"| node_vercel_blob
node_cars_query -->|"queries"| node_prisma_client
node_prisma_client -->|"reads and writes"| node_postgres
node_migrations -->|"evolves schema"| node_postgres
node_seed -->|"provisions"| node_postgres
node_vercel -->|"deploys"| node_app

click node_app "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/layout.tsx"
click node_public_pages "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/(public)/cars/page.tsx"
click node_catalog_ui "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/CarCard.tsx"
click node_cars_query "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/cars.ts"
click node_contact_form "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/ContactForm.tsx"
click node_admin_pages "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/admin/page.tsx"
click node_car_form "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/admin/CarForm.tsx"
click node_photo_manager "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/admin/PhotoManager.tsx"
click node_actions "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/actions.ts"
click node_validation "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/validations.ts"
click node_middleware "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/middleware.ts"
click node_nextauth "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_auth_config "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/auth.ts"
click node_prisma_client "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/prisma.ts"
click node_postgres "https://github.com/sudeepjoshi456/imageholidays/blob/main/prisma/schema.prisma"
click node_seed "https://github.com/sudeepjoshi456/imageholidays/blob/main/prisma/seed.ts"
click node_upload_route "https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/api/upload/route.ts"
click node_vercel "https://github.com/sudeepjoshi456/imageholidays/blob/main/vercel.json"

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_public_pages,node_catalog_ui,node_cars_query,node_contact_form toneBlue
class node_admin_pages,node_car_form,node_photo_manager,node_actions,node_validation,node_middleware,node_nextauth,node_auth_config toneAmber
class node_prisma_client,node_postgres,node_migrations,node_seed,node_upload_route,node_vercel_blob,node_resend,node_vercel toneMint
class node_app toneNeutral
```

## Components

### Public catalog

- [Catalog pages](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/(public)/cars/page.tsx): public routes · Home, catalog, and slug-based vehicle details. · `src/app/(public)/cars/page.tsx`
- [Catalog UI](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/CarCard.tsx): presentation components · Cards, filters, galleries, and search. · `src/components/CarCard.tsx`
- [Car read model](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/cars.ts): domain data access · Loads and derives public car presentation data. · `src/lib/cars.ts`
- [Contact form](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/ContactForm.tsx): public component · `src/components/ContactForm.tsx`

### Admin workflow

- [Fleet dashboard](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/admin/page.tsx): protected admin routes · Fleet overview and lifecycle entry points. · `src/app/admin/page.tsx`
- [Car form](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/admin/CarForm.tsx): admin component · Creates and edits fleet records. · `src/components/admin/CarForm.tsx`
- [Photo manager](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/components/admin/PhotoManager.tsx): admin component · `src/components/admin/PhotoManager.tsx`
- [Server actions](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/actions.ts): mutation and contact actions · Persists fleet changes and submits contact messages. · `src/lib/actions.ts`
- [Input validation](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/validations.ts): validation layer · `src/lib/validations.ts`
- [Admin route guard](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/middleware.ts): Next.js middleware · `src/middleware.ts`
- [NextAuth handlers](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/api/auth/%5B...nextauth%5D/route.ts): auth API route · `src/app/api/auth/[...nextauth]/route.ts`
- [Credentials auth](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/auth.ts): auth configuration · Single-admin credentials and session configuration. · `src/lib/auth.ts`

### Data & integrations

- [Prisma client](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/lib/prisma.ts): persistence adapter · Uses the PostgreSQL driver adapter at runtime. · `src/lib/prisma.ts`
- [PostgreSQL](https://github.com/sudeepjoshi456/imageholidays/blob/main/prisma/schema.prisma): system of record · `prisma/schema.prisma`
- **Migrations**: database evolution
- [Seed data](https://github.com/sudeepjoshi456/imageholidays/blob/main/prisma/seed.ts): database bootstrap · Provisions the sole admin and demo fleet. · `prisma/seed.ts`
- [Blob upload route](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/api/upload/route.ts): upload API route · Isolates Vercel Blob photo uploads. · `src/app/api/upload/route.ts`
- **Vercel Blob**: object storage · Optional vehicle photo storage.
- **Resend**: email service · Optional contact delivery; actions log demos when absent.
- [Vercel](https://github.com/sudeepjoshi456/imageholidays/blob/main/vercel.json): deployment platform · `vercel.json`

### Other components

- [Next.js App Router](https://github.com/sudeepjoshi456/imageholidays/blob/main/src/app/layout.tsx): application runtime · Renders public and admin routes. · `src/app/layout.tsx`

## Connections

- Next.js App Router → Catalog pages: renders
- Catalog pages → Catalog UI: composes
- Catalog pages → Car read model: loads cars
- Catalog UI → Car read model: displays
- Contact form → Server actions: submits
- Next.js App Router → Fleet dashboard: renders
- Admin route guard → Fleet dashboard: protects
- NextAuth handlers → Credentials auth: uses
- Credentials auth → Prisma client: verifies admin
- Fleet dashboard → Car form: hosts
- Fleet dashboard → Photo manager: hosts
- Car form → Input validation: validates
- Car form → Server actions: mutates
- Server actions → Input validation: validates
- Server actions → Prisma client: persists fleet
- Server actions → Resend: sends contact
- Photo manager → Blob upload route: uploads photos
- Blob upload route → Vercel Blob: stores
- Car read model → Prisma client: queries
- Prisma client → PostgreSQL: reads and writes
- Migrations → PostgreSQL: evolves schema
- Seed data → PostgreSQL: provisions
- Vercel → Next.js App Router: deploys
