This is the source code of SnapStager.com, a SaaS to do Virtual Staging with AI. Feel free to play around with and use the code in your project.
DEPRECATED - This project is now unmaintained and deprecated. Archive only
How it works
It uses a custom ML model called hosted on replicate similar to Stable Diffusion Inpainting. SnapStager gives you the ability to upload a photo of any room, mask the room in the web using canvas, then send both the original Image and Mask through the ML Model using a Next.js API route, and return your staged room.
Tech stack used for this app are:
Check presentation video if you want to see how to use.
Running Locally
Cloning the repository the local machine.
git clone https://github.com/robertwt7/snapstager.git
Storing the API keys in .env
Copy env.example
to .env
at the root of the project to start filling in the API keys
Creating a account on Replicate to get an API key.
- Go to Replicate to make an account.
- Click on your profile picture in the top left corner, and click on "API Tokens".
- Here you can find your API token. Copy it.
- Store it in the .env file
Create a free account on Supabase and get the API key.
- Go to Supabase
- Create a new organisation and project.
- Go to "Project Settings" at the bottom left, click on "API" under configuration
- Copy the URL and anon key under Project API Keys.
- Store it in the .env file
Next you need to store the database env which is located at prisma/env.example
, copy this file to prisma/.env
- Go to "Project Settings" at the bottom left, click on "Database" under configuration
- Copy the connection string for the Session mode ending with port
:5432
to the DIRECT_URL
env
- Copy the connection string for the Transaction mode ending with port
:6543
to the DATABASE_URL
env, then add this query param at the end of the connection string: ?pgbouncer=true&connection_limit=1
- Open your db in the DB Client like Dbeaver, open Databases, create a new database with the name
shadow_postgres
as the shadow db for prisma
- Repeat step 2 for the
SHADOW_DATABASE_URL
and change the db after 5432/postgres
to 5432/shadow_postgres
Create an account at cloudflare (Need subscription)
- Go to Cloudflare and create an account
- Login to dashboard
- Go to "Images" at the sidebar, then click "Overview" (you have to subscribe for this)
- Copy the "Account ID" on the right and add it to the environment file under
CLOUDFLARE_ACCOUNT_ID
- Click Use API and click get API Token
- Create a new one and copy it to the environment file under
CLOUDFLARE_TOKEN
Create a stripe account
- Go to Stripe
- Create an account
- Follow the guide to create a product catalogue
- Go to each product and copy the ID at the top right to each environment var that starts with
STRIPE_PRICE_ID_<YOUR-VARIANT>
- Finally click "Developers" on the top right menu, then find your API key and create a webhook key with the correct endpoint at
https://yourdomain.com/api/stripe-webhook
and copy it to the environment file.
Installing the dependencies.
yarn
Running the application.
Then, run the application in the command line and it will be available at http://localhost:3000
.
yarn dev
License
This repo is MIT licensed.