A Next.js frontend for logging and visualizing expenses stored in Supabase.
- Install dependencies:
pnpm install- Create
.env.local:
Fill in:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY
- Ensure the Supabase tables exist (schema below) and configure RLS.
create table public.category (
id bigint generated by default as identity not null,
category text not null,
constraint category_pkey primary key (id)
) TABLESPACE pg_default;
create table public.budget (
id bigint generated by default as identity not null,
category_id bigint not null,
budget bigint not null,
year bigint not null,
month integer not null,
constraint budget_pkey primary key (id),
constraint budget_category_id_fkey foreign KEY (category_id) references category (id)
) TABLESPACE pg_default;
create table public.expense (
id bigint generated by default as identity not null,
item text not null,
price bigint not null,
category_id integer not null,
tag text null,
user_id uuid null,
date date null,
constraint expenses_pkey primary key (id),
constraint expense_category_id_fkey foreign KEY (category_id) references category (id)
) TABLESPACE pg_default;
create index IF not exists idx_expense_date on public.expense using btree (date);Enable row level security and policies:
alter table public.category enable row level security;
alter table public.budget enable row level security;
alter table public.expense enable row level security;
create policy "Users can read categories"
on public.category
for select
to authenticated
using (true);
create policy "Users can read budgets"
on public.budget
for select
to authenticated
using (true);
create policy "Users can upsert budgets"
on public.budget
for insert
to authenticated
with check (true);
create policy "Users can update budgets"
on public.budget
for update
to authenticated
using (true);
create policy "Users can read their expenses"
on public.expense
for select
to authenticated
using (user_id = auth.uid());
create policy "Users can insert their expenses"
on public.expense
for insert
to authenticated
with check (user_id = auth.uid());
create policy "Users can update their expenses"
on public.expense
for update
to authenticated
using (user_id = auth.uid());- Run the app:
pnpm dev- Currency formatting is set to NOK with a
krsuffix inlib/format.ts. - Prices and budgets use whole numbers (integer kroner).
- Frontend documentation is available in
docs/.