# yashurade27/globetrotter architecture

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

- Interactive diagram: https://gitdiagram.com/yashurade27/globetrotter
- Repository: https://github.com/yashurade27/globetrotter

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js 13 using the App Router. It provides both client-side UX (React pages and UI components) and server-side logic (server actions, API routes) for user signup, data persistence, caching, and email notifications.

##### File structure
- Top-level config files: next.config.ts, tsconfig.json, eslint.config.mjs, postcss.config.mjs.
- Prisma folder: defines your relational database schema and migration scripts (`prisma/schema.prisma` + migration SQL).
- Public folder: static assets.
- src/app: the App Router entrypoints – layout.tsx, page.tsx, plus a signup subpage and server action (`src/app/actions/signup.ts`).
- src/components: reusable UI primitives (button.tsx, card.tsx, input.tsx, label.tsx).
- src/lib: server-side helper modules (Prisma client, Redis client, mail sender, general utils).

##### Key insights from the README
- Project bootstrapped with create-next-app.
- Uses next/font for font optimization.
- Standard Next.js dev and deploy workflow (Vercel).

##### Main components
a. Client-side / Browser (React pages in `src/app`, UI components in `src/components/ui`)
b. Next.js Server (App Router + Server Actions in `src/app/actions`)
c. Database (relational DB managed via Prisma; represented by prisma/schema.prisma)
d. Cache / Session Store (Redis via `src/lib/redis.ts`)
e. Email Service (external SMTP or transactional email API invoked by `src/lib/mail.ts`)

##### Relationships and data flows
- Browser → Next.js Server: HTTP(S) requests for pages and form submissions
- Next.js Server → Prisma Client: SQL queries and mutations
- Next.js Server → Redis Client: get/set cache or session data
- Next.js Server → External Email API: send confirmation or notification emails
- Next.js Server → Browser: rendered HTML or JSON responses

##### Architectural patterns and design principles
- Layered architecture:
- Presentation layer (React + UI components)
- Application layer (Next.js App Router, server actions for business logic)
- Persistence layer (Prisma + Redis)
- Serverless / function-as-a-service style: each server action is an isolated function.
- Convention-over-configuration from Next.js App Router.

##### Detail and clarity
- Server dependencies: next/font, PostCSS, ESLint config, TypeScript settings can be footnoted.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "Frontend (Client-Side)" 
        direction TB
        LP["Landing Page"]:::frontend
        SP["Signup Page"]:::frontend
        RL["Root Layout"]:::frontend
        GS["Global Styles"]:::frontend

        subgraph "UI Components" 
            direction TB
            BTN["Button"]:::frontend
            CARD["Card"]:::frontend
            INPUT["Input"]:::frontend
            LABEL["Label"]:::frontend
        end
    end

    subgraph "Backend (Next.js Server)" 
        direction TB
        subgraph "App Router & Server Actions"
            direction TB
            SA["Signup Action"]:::backend
        end

        subgraph "Lib Modules"
            direction TB
            PC["Prisma Client"]:::backend
            RC["Redis Client"]:::backend
            MS["Mail Sender"]:::backend
            UT["Utils"]:::backend
        end
    end

    %% External Data Stores
    DB[(Database)]:::datastore
    REDIS[(Redis Cache)]:::datastore
    EM{{"Email Service"}}:::external

    %% Flows
    %% Frontend flows
    Browser["Browser"]:::external
    Browser -->|"GET /"| LP
    Browser -->|"GET /signup"| SP
    LP -->|uses| RL
    RL -->|loads| GS
    SP -->|renders| BTN
    SP -->|renders| INPUT
    SP -->|renders| LABEL
    SP -->|renders| CARD
    SP -->|"POST /signup"| SA

    %% Backend flows
    SA -->|"calls"| PC
    SA -->|"calls"| RC
    SA -->|"calls"| MS
    PC -->|"SQL queries"| DB
    RC -->|"cache ops"| REDIS
    MS -->|"SMTP send"| EM
    SA -->|"response JSON/HTML"| Browser

    %% Click events
    click LP "https://github.com/yashurade27/globetrotter/blob/auth/src/app/page.tsx"
    click SP "https://github.com/yashurade27/globetrotter/blob/auth/src/app/signup/page.tsx"
    click RL "https://github.com/yashurade27/globetrotter/blob/auth/src/app/layout.tsx"
    click GS "https://github.com/yashurade27/globetrotter/blob/auth/src/app/globals.css"
    click BTN "https://github.com/yashurade27/globetrotter/blob/auth/src/components/ui/button.tsx"
    click CARD "https://github.com/yashurade27/globetrotter/blob/auth/src/components/ui/card.tsx"
    click INPUT "https://github.com/yashurade27/globetrotter/blob/auth/src/components/ui/input.tsx"
    click LABEL "https://github.com/yashurade27/globetrotter/blob/auth/src/components/ui/label.tsx"
    click SA "https://github.com/yashurade27/globetrotter/blob/auth/src/app/actions/signup.ts"
    click PC "https://github.com/yashurade27/globetrotter/blob/auth/src/lib/prisma.ts"
    click RC "https://github.com/yashurade27/globetrotter/blob/auth/src/lib/redis.ts"
    click MS "https://github.com/yashurade27/globetrotter/blob/auth/src/lib/mail.ts"
    click UT "https://github.com/yashurade27/globetrotter/blob/auth/src/lib/utils.ts"
    click DB "https://github.com/yashurade27/globetrotter/blob/auth/prisma/schema.prisma"
    click DB "https://github.com/yashurade27/globetrotter/blob/auth/prisma/migrations/20250824043001_init/migration.sql"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef backend fill:#E6F4EA,stroke:#28A745,color:#1B6A34
    classDef datastore fill:#FFF4E5,stroke:#DB8C00,color:#DB8C00
    classDef external fill:#F0F0F0,stroke:#6A737D,color:#6A737D
```
