built a multi-tenant property analysis app with supabase RLS and edge functions and the whole backend is like 200 lines
a friend who invests in rentals asked me to build him a tool where he pastes an address and sees if the numbers work. zestimate vs asking price, rent estimate, cash flow at different down payments, price history chart. he showed it to two other investors and they wanted their own accounts. so now i needed multi-tenancy.
supabase made the multi-tenant part almost trivial. the schema is simple:
sql
create table properties (
id uuid default gen_random_uuid() primary key,
user_id uuid references auth.users(id),
address text,
data jsonb,
deal_score text,
created_at timestamptz default now()
);
alter table properties enable row level security;
create policy "users see own properties"
on properties for all
using (auth.uid() = user_id);
that's it for multi-tenancy. each investor only sees their own saved properties. no middleware, no tenant filtering in every query, no "where tenant_id = X" sprinkled everywhere. RLS handles it at the database level. i've built multi-tenant apps before in django and rails and it was always way more code than this.
for pulling property data i wrote a supabase edge function that takes an address, calls a rest api called zillapi that returns zillow data as json, calculates a deal score, and returns the result. the edge function is about 40 lines of typescript. the score is based on rent-to-price ratio, zestimate gap, and price trend direction. green/yellow/red.
the jsonb column for storing the full api response was a good call. the api returns 300+ fields per property and i only display about 15. but when one of the investors asked me to add tax assessed value to the dashboard i didn't need a new api call or a migration. the data was already sitting in the jsonb. just updated the frontend to read one more field.
i also set up a scheduled edge function that runs every sunday. it loops through all saved properties across all users and refreshes the data from the api. if any zestimate changed more than 5% it flags it. one investor caught a $30k valuation drop on a property he was watching because the refresh flagged it on a monday morning.
for the ai side i also set up a skill so the investors can ask claude about their properties:
npx clawhub@latest install zillow-full
three investors using it now. the whole backend is supabase auth, one table with RLS, two edge functions (lookup + scheduled refresh), and a next.js frontend. no separate server, no celery, no redis. total cost is $0 on the supabase free tier.