AI Interior Design
Introduction
The AI Interior Design Generator is a tool that leverages Replicate's API to generate interior design ideas based on user input. Users can specify the type of room, theme, and upload a reference image to receive AI-generated designs. This tool uses Supabase for database management.
Quickstart Guide
Installation
-
Clone the repository:
terminalgit clone https://github.com/1811-Labs-LLC/BuilderKit-Starter.git [YOUR_APP_NAME] cd [YOUR_APP_NAME] git checkout interior-design-generator
Remove the
origin remote
to ensure that you can work locally without pushing the changes back to the original repository.terminalgit remote remove origin
However, note that after removing the remote, you won't be able to switch between the branches, so you'll need to clone the repository again if you want to work on another branch.
-
Install dependencies:
terminalnpm install
-
Environment Variables:
Copy the required variables from
.env.example
to.env.local
as mentioned and update the values.terminalcp .env.example .env.local
Or, manually create a
.env.local
file in the root directory with the following env variables (make sure to update the values with your actual keys):.env.local# Host NEXT_PUBLIC_APP_URL=<your-app-url> # Supabase NEXT_PUBLIC_SUPABASE_URL=<your-supabase-url> NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-supabase-anon-key> SUPABASE_SERVICE_ROLE_KEY=<your-supabase-service-role-key> # Replicate REPLICATE_API_TOKEN=<your-replicate-api-key> # Google Analytics NEXT_PUBLIC_GOOGLE_ANALYTICS_KEY=<your-google-analytics-key>
Setup Supabase
If you have not setup the supabase yet, go through the detailed documentation to set up the supabase for BuilderKit.ai. Make sure that you are creating the user table as mentioned in the supabase setup doc as it is required for the tool.
-
Create Interior Design Table in Supabase:
sql-- Create a table for AI Interior Design create table interior_designs ( id uuid not null default uuid_generate_v4 (), created_at timestamp with time zone not null default now(), user_id uuid not null, prompt text not null, room_type text not null, theme text not null, prediction_id text not null, ref_image text not null, image_urls text[] null, error text null, constraint interior_designs_pkey primary key (id), constraint interior_designs_user_id_fkey foreign key (user_id) references users (id) ); -- Set up Row Level Security (RLS) alter table interior_designs enable row level security; create policy "Users can insert their own row." on interior_designs for insert with check (auth.uid () = user_id); create policy "Users can update own row" on interior_designs for update using (auth.uid () = user_id); create policy "Users can read own row" on interior_designs for select using (auth.uid () = user_id); -- Optional: Add policy to allow users to delete their own interior_designs create policy "Users can delete own row" on interior_designs for delete using (auth.uid() = user_id); -- Enable Realtime alter publication supabase_realtime add table interior_designs;
- For Interior Design tool, we are enabling Supabase Realtime (last line of the script)
- For all the tables, we enable the RLS policy by default with necessary permissions as mentioned in the script.
-
Sync Supabase Types:
To sync the supabase table schema with your project follow the steps here.
Running the Application
-
Run the development server:
terminalnpm run dev
This will start the development server on http://localhost:3000 (opens in a new tab).
-
Build for production:
terminalnpm run build
This command compiles the application for production usage.
-
Start the production server:
terminalnpm start
This will start the application in production mode.
Additional Scripts
-
Prepare Husky for Git hooks:
terminalnpm run prepare
-
Validate the code with Linting, Formatting & Typecheck:
terminalnpm run validate
Creating a Public URL for Local Webhook Testing
This app uses a webhook to handle responses from the AI server. Since the server cannot recognize a localhost URL (http://localhost:3000 (opens in a new tab)), we need to set up a tunnel to create a public URL that can accept webhook requests from the server and redirect them to your localhost URL for testing purposes.
We will use ngrok (opens in a new tab) to create this tunnel. The public URL generated by ngrok will redirect all external requests to your configured localhost URL. Follow the steps to set up ngrok and create the public URL here: https://ngrok.com/docs/getting-started (opens in a new tab).
Once ngrok is set up, test your project using the ngrok public URL instead of http://localhost:3000 (opens in a new tab).
Requirements
- Node.js: Download and install from here (opens in a new tab).
- Supabase: Check out Supabase Setup Documentation to get all the required details.
- Replicate API Key: Create an account on Replicate (opens in a new tab) to get the api token.