# sahil-tandon/date-dash architecture

> Architecture diagram of the GitHub repository sahil-tandon/date-dash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sahil-tandon/date-dash
- Repository: https://github.com/sahil-tandon/date-dash

## Overview

##### Project type and purpose
- This is a full-stack, React-based web application built with Next.js (App Router).
- It provides a user interface for selecting a city (via a combobox) and generating “date ideas” (via an API route).
- Core use cases: city search/autocomplete, idea generation, and UI rendering of cards/modals.

##### File structure
Top-level directories and key files:
- src/app: Next.js App Router directory; defines pages, layouts, global styles, and serverless API routes under api/.
– api/cities/search/route.ts – a serverless function for searching/filtering cities (autocomplete).
– api/generate/route.ts – a serverless function that generates date ideas (likely via an external AI service).
– layout.tsx, page.tsx – root layout and home page.
– shared/ – shared page layouts or metadata.
– ui/ – design system primitives (button, card, dialog, input, popover, skeleton, carousel, command).
- src/data/cities.ts: static list of cities used by the search API.
- src/lib/utils.ts: helper functions (e.g., formatting, request wrappers).
- src/types/index.ts: shared TypeScript types.
- Configuration: next.config.ts, tsconfig.json, tailwind.config.ts, eslint.config.mjs, postcss.config.mjs.

##### README for additional insights
- Standard Next.js boilerplate README; confirms use of create-next-app, next/font for font optimization, and Vercel for deployment.

a. Main components
1. Client (Browser) – React/Next.js pages rendered on the client (hydration) and server.
2. Next.js Server (Serverless Runtime) – hosts SSR/SSG and API route handlers.
3. API Routes
- CitySearch Function – reads src/data/cities.ts, filters by query, returns JSON.
- IdeaGenerate Function – orchestrates idea creation (invokes lib/utils, external AI API).
4. Static Data Store – cities.ts (in-repo JSON/TS).
5. External Service – e.g., OpenAI (or other AI endpoint) used by generate route.
6. CDN/Static Assets – public/ folder served by Next.js.
7. Design System Library – src/components/ui primitives imported by UI components.

b. Relationships and interactions
- User loads URL → Next.js routes request to either a server-rendered page or static page.
- On the home page:
- CityCombobox → sends HTTP GET to “/api/cities/search?query=…” → CitySearch Function → static data → JSON.
- User selects city and clicks generate → front end sends HTTP POST to “/api/generate” with payload → IdeaGenerate Function → calls external AI API → returns generated ideas → UI renders DateIdeaCard components.
- All page navigations and API calls occur over HTTPS to Next.js serverless endpoints.
- Shared layout (layout.tsx) and CSS (globals.css, tailwind) wrap pages.
- Static assets (images etc.) are served from public/.

c. Architectural patterns & design principles
- Component-Based UI (React) with a shared design-system subfolder.
- App Router for file-based routing.
- Serverless Functions / API Routes for backend logic (CRO).
- Static data embedding (no external DB).
- Separation of concerns: UI, data (cities.ts), business logic (utils), API layer.
- Typed codebase: TypeScript for all layers.

d. Relevant technologies
- Next.js (App Router, serverless API routes)
- React (functional components, hooks)
- Tailwind CSS (utility-first styling)
- TypeScript (static types)
- Vercel / Serverless runtime (deployment target)
- External AI API (presumed OpenAI)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Frontend Zone
  subgraph "Frontend (Browser)"
    Browser["User's Browser"]:::external
    Page["Home Page<br/>(page.tsx)"]:::frontend
    Layout["Root Layout<br/>(layout.tsx)"]:::frontend
    Meta["Metadata<br/>(metadata.ts)"]:::frontend
    SharedPage["Shared Page Layout<br/>(page.tsx)"]:::frontend
    Styles["Global Styles<br/>(globals.css)"]:::frontend
    CityCB["CityCombobox"]:::frontend
    DateCard["DateIdeaCard"]:::frontend
    ShareModal["ShareModal"]:::frontend
    Heart["Heart Icon"]:::frontend
    CloudBG["Cloud Background"]:::frontend
    subgraph "Design System Primitives"
      Button["Button"]:::frontend
      Card["Card"]:::frontend
      Carousel["Carousel"]:::frontend
      Command["Command"]:::frontend
      Dialog["Dialog"]:::frontend
      Input["Input"]:::frontend
      Popover["Popover"]:::frontend
      Skeleton["Skeleton"]:::frontend
    end
  end

  %% Backend Zone
  subgraph "Backend (Serverless/API)"
    NextServer["Next.js Serverless Runtime"]:::api
    CityAPI["CitySearch API Route"]:::api
    GenAPI["IdeaGenerate API Route"]:::api
    Utils["Utility Functions<br/>(utils.ts)"]:::utils
    Types["TypeScript Types<br/>(types/index.ts)"]:::utils
    CitiesData["Static Cities Data<br/>(cities.ts)"]:::datastore
  end

  %% External & Deployment
  subgraph "External & Deployment"
    AI["External AI Service"]:::external
    Assets["Static Assets<br/>(public/)"]:::external
    Vercel["Vercel / Serverless Host"]:::external
  end

  %% Configurations
  subgraph "Configurations"
    NextConfig["next.config.ts"]:::config
    TailwindConfig["tailwind.config.ts"]:::config
    TSConfig["tsconfig.json"]:::config
    ESLint["eslint.config.mjs"]:::config
    PostCSS["postcss.config.mjs"]:::config
  end

  %% Connections - Frontend Flow
  Browser --> Page
  Page --> Layout
  Page --> Meta
  Page --> SharedPage
  Layout --> Styles
  Page --> CityCB
  CityCB -->|GET /api/cities/search| CityAPI
  CityAPI --> CitiesData
  CityAPI -->|returns JSON| CityCB
  Page -->|POST /api/generate| GenAPI
  GenAPI --> Utils
  GenAPI --> AI
  GenAPI -->|returns JSON| Page
  Page --> DateCard
  Page --> ShareModal
  Page --> Heart
  Page --> CloudBG

  %% UI Composition
  DateCard --> Card
  ShareModal --> Dialog
  ShareModal --> Button
  CityCB --> Input
  Command --> CityCB
  Carousel --> DateCard
  Popover --> CityCB
  Skeleton --> CityCB

  %% Deployment & Assets
  Vercel --> NextServer
  Assets --> Browser
  Assets --> NextServer

  %% Backend Config Connections
  NextServer --> NextConfig
  NextServer --> TSConfig
  NextServer --> ESLint
  Styles --> TailwindConfig
  Styles --> PostCSS

  %% Click Events
  click Page "https://github.com/sahil-tandon/date-dash/blob/main/src/app/page.tsx"
  click Layout "https://github.com/sahil-tandon/date-dash/blob/main/src/app/layout.tsx"
  click Meta "https://github.com/sahil-tandon/date-dash/blob/main/src/app/shared/metadata.ts"
  click SharedPage "https://github.com/sahil-tandon/date-dash/blob/main/src/app/shared/page.tsx"
  click Styles "https://github.com/sahil-tandon/date-dash/blob/main/src/app/globals.css"
  click CityAPI "https://github.com/sahil-tandon/date-dash/blob/main/src/app/api/cities/search/route.ts"
  click GenAPI "https://github.com/sahil-tandon/date-dash/blob/main/src/app/api/generate/route.ts"
  click CitiesData "https://github.com/sahil-tandon/date-dash/blob/main/src/data/cities.ts"
  click Utils "https://github.com/sahil-tandon/date-dash/blob/main/src/lib/utils.ts"
  click Types "https://github.com/sahil-tandon/date-dash/blob/main/src/types/index.ts"
  click CityCB "https://github.com/sahil-tandon/date-dash/blob/main/src/components/CityCombobox.tsx"
  click DateCard "https://github.com/sahil-tandon/date-dash/blob/main/src/components/DateIdeaCard.tsx"
  click ShareModal "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ShareModal.tsx"
  click Heart "https://github.com/sahil-tandon/date-dash/blob/main/src/components/Heart.tsx"
  click CloudBG "https://github.com/sahil-tandon/date-dash/blob/main/src/components/CloudBackground.tsx"
  click Button "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/button.tsx"
  click Card "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/card.tsx"
  click Carousel "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/carousel.tsx"
  click Command "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/command.tsx"
  click Dialog "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/dialog.tsx"
  click Input "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/input.tsx"
  click Popover "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/popover.tsx"
  click Skeleton "https://github.com/sahil-tandon/date-dash/blob/main/src/components/ui/skeleton.tsx"
  click Assets "https://github.com/sahil-tandon/date-dash/tree/main/public/"
  click NextConfig "https://github.com/sahil-tandon/date-dash/blob/main/next.config.ts"
  click TailwindConfig "https://github.com/sahil-tandon/date-dash/blob/main/tailwind.config.ts"
  click TSConfig "https://github.com/sahil-tandon/date-dash/blob/main/tsconfig.json"
  click ESLint "https://github.com/sahil-tandon/date-dash/blob/main/eslint.config.mjs"
  click PostCSS "https://github.com/sahil-tandon/date-dash/blob/main/postcss.config.mjs"

  %% Styles
  classDef frontend fill:#E0F7FA,stroke:#006064
  classDef api fill:#E8F5E9,stroke:#2E7D32
  classDef datastore fill:#FFF9C4,stroke:#F9A825
  classDef external fill:#EDE7F6,stroke:#5E35B1
  classDef utils fill:#ECEFF1,stroke:#607D8B
  classDef config fill:#FFF3E0,stroke:#EF6C00
```
