# kubowania/airbnb-sanity-backend architecture

> Architecture diagram of the GitHub repository kubowania/airbnb-sanity-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubowania/airbnb-sanity-backend
- Repository: https://github.com/kubowania/airbnb-sanity-backend

## Overview

##### Project Type & Purpose
- This is a headless-CMS backend for an AirBnB-style clone, built with Sanity.io.
- Its sole responsibility is to define/content-model your data (properties, users, reviews, images), expose it via Sanity’s Content Lake, and be consumed by a Next.js front end.

##### File Structure
- Top-level config directory holds Sanity Studio configuration (layouts, logins, form-builder).
- `schemas/` defines all document and object types: Host, Traveller, Person, Property, PropertyImage, Review, plus the root schema.
- `sanity.json` and `package.json` define the project’s Sanity CLI settings, Studio plugins, scripts and dependencies.
- `static/` is for any static assets you might surface in Studio.
- `tsconfig.json` for TypeScript typing in your schema code.

##### README for Additional Insights
- The README describes the tutorial flow: schema creation, Studio data entry, then a separate Next.js front-end that queries these schemas via GROQ and the Sanity SDK.
- External dependencies include Google Maps API for geolocation and marker clustering on the front end.

##### Main Components & Their Relationships
a. Developer Machine & Sanity Studio (local)
- Schema JS/TS files + config → Sanity Studio UI
- Studio’s “Deploy” or “Start” commands push schemas to Sanity’s managed Content Lake
b. Sanity Content Lake (hosted)
- Stores Documents (properties, users, reviews, images)
- Enforces schema validations & types
c. Next.js Front-end (separate repo)
- Uses `@sanity/client` SDK to run GROQ queries against Content Lake
- Renders pages via `getServerSideProps`/`getStaticProps` and React hooks
d. External Services
- Google Maps API: used by front end for geolocation, clustering, map display

##### Architectural Patterns & Design Principles
- Headless CMS pattern: content modeling (backend) decoupled from presentation (frontend)
- Single source of truth for data in Content Lake
- Clear separation of concerns:
- Schema code & Studio config in this repo
- Presentation & data-fetching logic in the Next.js repo
- Type-safe schemas via TypeScript

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers and Components

    Developer["Developer Environment<br/>(IDE + Sanity CLI)"]:::devStudio

    subgraph "Sanity Studio"
        direction TB
        StudioUI["Sanity Studio UI"]:::devStudio

        subgraph "Schema Modules & Config"
            direction TB
            ConfigDir["Studio Config<br/>(config/@sanity/*.json)"]:::devStudio
            DAS["data-aspects.json"]:::devStudio
            DLT["default-layout.json"]:::devStudio
            DLN["default-login.json"]:::devStudio
            FBD["form-builder.json"]:::devStudio

            SchemasDir["Schema Definitions<br/>(schemas/*.js)"]:::devStudio
            Host["host.js"]:::devStudio
            Person["person.js"]:::devStudio
            Property["property.js"]:::devStudio
            PropImg["propertyImage.js"]:::devStudio
            Review["review.js"]:::devStudio
            Traveller["traveller.js"]:::devStudio

            RootSchema["schema.js"]:::devStudio
        end

        CLIConfig["sanity.json"]:::devStudio
        Package["package.json"]:::devStudio
        TSConfig["tsconfig.json"]:::devStudio
        README["README.md"]:::devStudio
        Static["static/"]:::devStudio
    end

    ContentLake[(Sanity Content Lake)]:::data

    Frontend["Next.js Front-end<br/>(GROQ Client + React)"]:::frontend

    GoogleMaps["Google Maps API"]:::external

    %% Connections
    Developer -->|"write & deploy schemas"| StudioUI
    StudioUI -->|"Deploy Schemas & Data Writes"| ContentLake
    Frontend -->|"GROQ Queries via Sanity SDK"| ContentLake
    Frontend -->|"map/geolocation requests"| GoogleMaps

    %% Click Events
    click DAS "https://github.com/kubowania/airbnb-sanity-backend/blob/main/config/@sanity/data-aspects.json"
    click DLT "https://github.com/kubowania/airbnb-sanity-backend/blob/main/config/@sanity/default-layout.json"
    click DLN "https://github.com/kubowania/airbnb-sanity-backend/blob/main/config/@sanity/default-login.json"
    click FBD "https://github.com/kubowania/airbnb-sanity-backend/blob/main/config/@sanity/form-builder.json"
    click Host "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/host.js"
    click Person "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/person.js"
    click Property "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/property.js"
    click PropImg "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/propertyImage.js"
    click Review "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/review.js"
    click Traveller "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/traveller.js"
    click RootSchema "https://github.com/kubowania/airbnb-sanity-backend/blob/main/schemas/schema.js"
    click CLIConfig "https://github.com/kubowania/airbnb-sanity-backend/blob/main/sanity.json"
    click Package "https://github.com/kubowania/airbnb-sanity-backend/blob/main/package.json"
    click TSConfig "https://github.com/kubowania/airbnb-sanity-backend/blob/main/tsconfig.json"
    click README "https://github.com/kubowania/airbnb-sanity-backend/blob/main/README.md"
    click Static "https://github.com/kubowania/airbnb-sanity-backend/tree/main/static/"

    %% Styles
    classDef devStudio fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef data fill:#d4edda,stroke:#333,stroke-width:1px
    classDef frontend fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
