# nutlope/roomgpt architecture

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

- Interactive diagram: https://gitdiagram.com/nutlope/roomgpt
- Repository: https://github.com/nutlope/roomgpt

## Overview

This repository is a small Next.js App Router application for AI room redesign. The architecture is intentionally thin: a browser-based UI collects a room photo and preferences, a serverless API route invokes the ML model, and the generated result is sent back to the UI for comparison.

The top-level runtime is Next.js with React and TypeScript. `app/layout.tsx` provides the shared application shell, while `app/page.tsx` is the main landing/upload experience and `app/dream/page.tsx` appears to be the generated-result view.

The presentation layer is split into reusable UI pieces under `components/`. These include page chrome (`Header`, `Footer`), interaction controls (`DropDown`, `Toggle`), generation/preview affordances (`CompareSlider`, `ResizablePanel`), and loading/decoration components (`LoadingDots`, `SquigglyLines`). This suggests the app is centered around a highly visual before/after workflow rather than a multi-page information site.

The core data flow starts in the browser: the user uploads an input image of a room, selects generation options, and triggers a request to the backend. The client UI likely manages local state for the upload preview, selected room style/type, and loading state while the model runs.

The backend boundary is `app/generate/route.ts`, which is the main server-side execution point. This route is responsible for preparing the request to the AI model, handling the image pipeline, and returning the generated output to the client. In architectural terms, this is the only part that needs to know about model invocation and external storage details.

The AI/ML dependency is Replicate, as described in the README. The app uses ControlNet to transform an input room image into a redesigned version. That means the server route is the orchestration layer between user input and the hosted inference service.

Image handling is offloaded to external storage, with Bytescale named in the README as the image host. The `utils/downloadPhoto.ts` and `utils/appendNewToName.ts` helpers indicate a small image-processing pipeline around fetching, storing, and renaming generated assets before they are displayed or returned.

There is also an optional persistence/rate-limiting boundary via Redis. `utils/redis.ts` connects to Upstash Redis when configured, which means the architecture can enforce request limits without adding a full database or auth system.

The app is styled with Tailwind CSS and global stylesheet files in `styles/`, with build/runtime config handled by `tailwind.config.js`, `postcss.config.js`, and `next.config.js`. These influence presentation and deployment behavior but do not add new business subsystems.

Static assets live in `public/`, which is used for screenshots and other browser-served files. The README and file structure together suggest a deploy-on-Vercel model, where the UI and the `/generate` route run as serverless functions backed by the external Replicate, Bytescale, and optional Upstash services.

For an architecture diagram, the key boundaries are: browser UI, Next.js serverless app, AI inference service, image storage service, and optional Redis rate limiter. The main end-to-end flow is user image upload → generate request → external model/storage processing → returned transformed room image → compare/display in the UI.

Main entry points: [`app/page.tsx`](https://github.com/nutlope/roomgpt/blob/main/app/page.tsx) (Upload page), [`app/generate/route.ts`](https://github.com/nutlope/roomgpt/blob/main/app/generate/route.ts) (Generate API), [`app/layout.tsx`](https://github.com/nutlope/roomgpt/blob/main/app/layout.tsx) (App shell), [`app/dream/page.tsx`](https://github.com/nutlope/roomgpt/blob/main/app/dream/page.tsx) (Result page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client UI"]
  node_app_layout["App shell<br/>Next.js layout<br/>[layout.tsx]"]
  node_app_page["Upload page<br/>Next.js page<br/>[page.tsx]"]
  node_app_dream_page["Result page<br/>Next.js page<br/>[page.tsx]"]
  node_header["Header<br/>Chrome component<br/>[Header.tsx]"]
  node_footer["Footer<br/>Chrome component<br/>[Footer.tsx]"]
  node_dropdown["DropDown<br/>Input component<br/>[DropDown.tsx]"]
  node_toggle["Toggle<br/>Input component<br/>[Toggle.tsx]"]
  node_compare_slider["Compare slider<br/>Preview component<br/>[CompareSlider.tsx]"]
  node_resizable_panel["Resizable panel<br/>Layout component<br/>[ResizablePanel.tsx]"]
  node_loading_dots(("Loading dots<br/>Status component<br/>[LoadingDots.tsx]"))
  node_squiggly_lines(("Squiggly lines<br/>Decoration<br/>[SquigglyLines.tsx]"))
end

subgraph group_server["Server API"]
  node_generate_route["Generate API<br/>Route handler<br/>[route.ts]"]
end

subgraph group_shared["Shared Utils"]
  node_download_photo["Download photo<br/>Image helper<br/>[downloadPhoto.ts]"]
  node_append_new_to_name["Rename asset<br/>Naming helper<br/>[appendNewToName.ts]"]
  node_redis_util["Redis client<br/>Cache helper<br/>[redis.ts]"]
end

subgraph group_integrations["External Services"]
  node_replicate[("Replicate<br/>ML inference")]
  node_bytescale[("Bytescale<br/>Image storage")]
  node_upstash_redis[("Upstash Redis<br/>Cache service")]
end

node_app_layout -->|"wraps"| node_header
node_app_layout -->|"wraps"| node_footer
node_app_page -->|"collects"| node_dropdown
node_app_page -->|"collects"| node_toggle
node_app_page -->|"previews"| node_compare_slider
node_app_page -->|"lays out"| node_resizable_panel
node_app_page -->|"shows"| node_loading_dots
node_app_page -->|"decorates"| node_squiggly_lines
node_app_page -->|"submits"| node_generate_route
node_app_dream_page -->|"displays"| node_compare_slider
node_app_dream_page -->|"lays out"| node_resizable_panel
node_generate_route -->|"uses"| node_download_photo
node_generate_route -->|"uses"| node_append_new_to_name
node_generate_route -->|"checks"| node_redis_util
node_generate_route -->|"invokes"| node_replicate
node_generate_route -->|"stores"| node_bytescale
node_download_photo -->|"downloads"| node_bytescale
node_redis_util -->|"connects"| node_upstash_redis

click node_app_layout "https://github.com/nutlope/roomgpt/blob/main/app/layout.tsx"
click node_app_page "https://github.com/nutlope/roomgpt/blob/main/app/page.tsx"
click node_app_dream_page "https://github.com/nutlope/roomgpt/blob/main/app/dream/page.tsx"
click node_generate_route "https://github.com/nutlope/roomgpt/blob/main/app/generate/route.ts"
click node_header "https://github.com/nutlope/roomgpt/blob/main/components/Header.tsx"
click node_footer "https://github.com/nutlope/roomgpt/blob/main/components/Footer.tsx"
click node_dropdown "https://github.com/nutlope/roomgpt/blob/main/components/DropDown.tsx"
click node_toggle "https://github.com/nutlope/roomgpt/blob/main/components/Toggle.tsx"
click node_compare_slider "https://github.com/nutlope/roomgpt/blob/main/components/CompareSlider.tsx"
click node_resizable_panel "https://github.com/nutlope/roomgpt/blob/main/components/ResizablePanel.tsx"
click node_loading_dots "https://github.com/nutlope/roomgpt/blob/main/components/LoadingDots.tsx"
click node_squiggly_lines "https://github.com/nutlope/roomgpt/blob/main/components/SquigglyLines.tsx"
click node_download_photo "https://github.com/nutlope/roomgpt/blob/main/utils/downloadPhoto.ts"
click node_append_new_to_name "https://github.com/nutlope/roomgpt/blob/main/utils/appendNewToName.ts"
click node_redis_util "https://github.com/nutlope/roomgpt/blob/main/utils/redis.ts"

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_app_layout,node_app_page,node_app_dream_page,node_header,node_footer,node_dropdown,node_toggle,node_compare_slider,node_resizable_panel,node_loading_dots,node_squiggly_lines toneBlue
class node_generate_route toneAmber
class node_download_photo,node_append_new_to_name,node_redis_util toneMint
class node_replicate,node_bytescale,node_upstash_redis toneRose
```

## Components

### Client UI

Browser-facing pages and reusable interaction components.

- [App shell](https://github.com/nutlope/roomgpt/blob/main/app/layout.tsx): Next.js layout · Shared application frame and global UI wrapper. · `app/layout.tsx`
- [Upload page](https://github.com/nutlope/roomgpt/blob/main/app/page.tsx): Next.js page · Main room upload and preference selection experience. · `app/page.tsx`
- [Result page](https://github.com/nutlope/roomgpt/blob/main/app/dream/page.tsx): Next.js page · Generated-room display and comparison view. · `app/dream/page.tsx`
- [Header](https://github.com/nutlope/roomgpt/blob/main/components/Header.tsx): Chrome component · Top-level page chrome. · `components/Header.tsx`
- [Footer](https://github.com/nutlope/roomgpt/blob/main/components/Footer.tsx): Chrome component · Bottom-level page chrome. · `components/Footer.tsx`
- [DropDown](https://github.com/nutlope/roomgpt/blob/main/components/DropDown.tsx): Input component · Selection control for room options. · `components/DropDown.tsx`
- [Toggle](https://github.com/nutlope/roomgpt/blob/main/components/Toggle.tsx): Input component · Binary preference control. · `components/Toggle.tsx`
- [Compare slider](https://github.com/nutlope/roomgpt/blob/main/components/CompareSlider.tsx): Preview component · Before/after image comparison UI. · `components/CompareSlider.tsx`
- [Resizable panel](https://github.com/nutlope/roomgpt/blob/main/components/ResizablePanel.tsx): Layout component · Flexible preview and content container. · `components/ResizablePanel.tsx`
- [Loading dots](https://github.com/nutlope/roomgpt/blob/main/components/LoadingDots.tsx): Status component · Generation-in-progress feedback. · `components/LoadingDots.tsx`
- [Squiggly lines](https://github.com/nutlope/roomgpt/blob/main/components/SquigglyLines.tsx): Decoration · Visual accent used in the landing experience. · `components/SquigglyLines.tsx`

### Server API

Next.js server route that orchestrates generation.

- [Generate API](https://github.com/nutlope/roomgpt/blob/main/app/generate/route.ts): Route handler · Server-side generation boundary for image transformation requests. · `app/generate/route.ts`

### Shared Utils

Small helper modules for image handling and optional rate limiting.

- [Download photo](https://github.com/nutlope/roomgpt/blob/main/utils/downloadPhoto.ts): Image helper · Fetches and prepares remote image assets. · `utils/downloadPhoto.ts`
- [Rename asset](https://github.com/nutlope/roomgpt/blob/main/utils/appendNewToName.ts): Naming helper · Creates derived filenames for generated images. · `utils/appendNewToName.ts`
- [Redis client](https://github.com/nutlope/roomgpt/blob/main/utils/redis.ts): Cache helper · Optional Upstash Redis connection for request limiting. · `utils/redis.ts`

### External Services

Hosted model, storage, and cache dependencies.

- **Replicate**: ML inference · Hosted model execution for room redesign.
- **Bytescale**: Image storage · External image hosting for uploaded and generated assets.
- **Upstash Redis**: Cache service · Optional hosted Redis backing for rate limiting.

## Connections

- App shell → Header: wraps · Shared shell provides top-level navigation chrome.
- App shell → Footer: wraps · Shared shell provides bottom-level page chrome.
- Upload page → DropDown: collects · Captures room and style choices.
- Upload page → Toggle: collects · Captures binary generation preferences.
- Upload page → Compare slider: previews · Supports before/after comparison while iterating.
- Upload page → Resizable panel: lays out · Uses responsive content panels for upload and preview.
- Upload page → Loading dots: shows · Indicates the model is running.
- Upload page → Squiggly lines: decorates · Adds visual emphasis to the landing flow.
- Upload page → Generate API: submits · Sends the upload and preferences to generation.
- Result page → Compare slider: displays · Presents the generated result against the source image.
- Result page → Resizable panel: lays out · Hosts the result comparison and related content.
- Generate API → Download photo: uses · Fetches source or generated image assets.
- Generate API → Rename asset: uses · Creates output asset names.
- Generate API → Redis client: checks · Applies optional request limiting.
- Generate API → Replicate: invokes · Runs the redesign model pipeline.
- Generate API → Bytescale: stores · Persists or retrieves image files.
- Download photo → Bytescale: downloads · Pulls remote image content from hosted storage.
- Redis client → Upstash Redis: connects · Backs the cache client with hosted Redis.
