# imvg93/salon-website architecture

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

- Interactive diagram: https://gitdiagram.com/imvg93/salon-website
- Repository: https://github.com/imvg93/salon-website

## Overview

##### Project Type & Purpose
- This is a full-stack Jamstack web application built with Next.js, Tailwind CSS, and Framer Motion on the frontend, with serverless API routes for backend logic. It powers the Catwalk Salon & Academy website, handling static content (services, pages, images) and dynamic features (booking form, contact form, email automation).

##### Main Components
a. Frontend Layer
- Next.js pages & components (pages/, components/)
- Styling & animations: Tailwind CSS, Framer Motion
- Static assets: public/images, CSS modules, globals.css
b. Serverless API Layer
- Next.js API routes (pages/api/*.js) and the Backend/api folder
- Endpoints for appointments.js, contact.js, hello.js
c. Database & Storage
- Supabase (PostgreSQL) for persisting booking and contact data
d. Email Service
- Resend API for sending confirmation and notification emails
e. Hosting & CDN
- Vercel for deploying Next.js, serving pages via SSR/SSG, and scaling serverless functions

##### Component Interactions & Data Flow
- User Browser → Vercel CDN Edge
- Requests static pages (SSG) or SSR pages (booking, confirmation)
- Client-side (BookingForm / ContactForm) → Next.js API Route
- Submit form → /api/appointments or /api/contact
- Serverless Function
- Validates input → writes to Supabase → calls Resend API → returns status
- External Services
- Supabase returns DB acknowledgement
- Resend returns email delivery status
- Admin/User sees confirmation page or error—viewed client-side

##### Architectural Patterns & Principles
- Jamstack: pre-rendered pages + JS API calls
- Serverless microservices: each API route as an independent function
- Separation of concerns: UI vs business logic vs data layer
- CDN caching for static content; SSR for dynamic routes

##### Technologies & Frameworks
- Next.js: routing, SSR/SSG, API routes
- Tailwind CSS & CSS Modules: styling, responsive design
- Framer Motion: UX animations
- Supabase: open-source Postgres as a service
- Resend: transactional email API
- Vercel: global hosting, serverless execution

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User and CDN
    UserBrowser["User Browser"]:::external
    VercelCDN["Vercel CDN / Edge"]:::external

    UserBrowser -->|"requests pages"| VercelCDN

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        NextPages["Next.js Frontend Pages"]:::frontend
        UIComponents["UI Components"]:::frontend
        Styling["Styling & Animations"]:::frontend
        StaticAssets["Static Assets"]:::frontend
    end

    VercelCDN -->|"serves SSG/SSR"| NextPages
    NextPages --> UIComponents
    NextPages --> Styling
    NextPages --> StaticAssets

    %% Serverless API Layer
    subgraph "Serverless API Layer"
        direction TB
        subgraph "Next.js API Routes"
            direction TB
            AppointmentsAPI["/api/appointments"]:::compute
            ContactAPI["/api/contact"]:::compute
        end
        subgraph "Backend/api Microservices"
            direction TB
            BE_Appointments["Appointments Service"]:::compute
            BE_Contact["Contact Service"]:::compute
            BE_Hello["Hello Service"]:::compute
            BE_Booked["Booked Utility"]:::compute
        end
    end

    UIComponents -->|"form submit"| AppointmentsAPI
    UIComponents -->|"form submit"| ContactAPI

    AppointmentsAPI -->|"validate & write"| BE_Appointments
    ContactAPI -->|"validate & write"| BE_Contact
    BE_Appointments --> BE_Booked
    BE_Contact --> BE_Hello

    %% Data and Email Services
    subgraph "Data & External Services"
        direction TB
        SupabaseDB[(Supabase Database)]:::database
        ResendEmail[(Resend Email Service)]:::external
    end

    BE_Appointments -->|"writes bookings"| SupabaseDB
    BE_Contact -->|"writes contacts"| SupabaseDB
    BE_Appointments -->|"calls Resend"| ResendEmail
    BE_Contact -->|"calls Resend"| ResendEmail

    %% Response back to Browser
    ResendEmail -->|"email status"| AppointmentsAPI
    ResendEmail -->|"email status"| ContactAPI
    SupabaseDB -->|"db ack"| AppointmentsAPI
    SupabaseDB -->|"db ack"| ContactAPI
    AppointmentsAPI -->|"response"| UserBrowser
    ContactAPI -->|"response"| UserBrowser

    %% Click Events
    click NextPages "https://github.com/imvg93/salon-website/tree/main/pages/"
    click UIComponents "https://github.com/imvg93/salon-website/tree/main/components/"
    click Styling "https://github.com/imvg93/salon-website/blob/main/tailwind.config.js"
    click Styling "https://github.com/imvg93/salon-website/blob/main/postcss.config.js"
    click Styling "https://github.com/imvg93/salon-website/blob/main/styles/globals.css"
    click StaticAssets "https://github.com/imvg93/salon-website/tree/main/public/images/"
    click StaticAssets "https://github.com/imvg93/salon-website/blob/main/public/site.webmanifest"
    click StaticAssets "https://github.com/imvg93/salon-website/blob/main/public/robots.txt"
    click AppointmentsAPI "https://github.com/imvg93/salon-website/blob/main/pages/api/appointments.js"
    click ContactAPI "https://github.com/imvg93/salon-website/blob/main/pages/api/contact.js"
    click BE_Appointments "https://github.com/imvg93/salon-website/blob/main/Backend/api/appointments.js"
    click BE_Contact "https://github.com/imvg93/salon-website/blob/main/Backend/api/contact.js"
    click BE_Hello "https://github.com/imvg93/salon-website/blob/main/Backend/api/hello.js"
    click BE_Booked "https://github.com/imvg93/salon-website/blob/main/Backend/api/booked.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#005cbf,stroke-width:2px
    classDef compute fill:#ffe5b4,stroke:#bf5f00,stroke-width:2px
    classDef database fill:#d4edda,stroke:#155724,stroke-width:2px
    classDef external fill:#e2d5f7,stroke:#5a259e,stroke-width:2px
```
