Skip to content

peternordby/budget

Repository files navigation

Budget Ledger

A Next.js frontend for logging and visualizing expenses stored in Supabase.

Setup

  1. Install dependencies:
pnpm install
  1. Create .env.local:

Fill in:

  • NEXT_PUBLIC_SUPABASE_URL
  • NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY
  1. 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());
  1. Run the app:
pnpm dev

Notes

  • Currency formatting is set to NOK with a kr suffix in lib/format.ts.
  • Prices and budgets use whole numbers (integer kroner).
  • Frontend documentation is available in docs/.

About

New and improved personal finance tracker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors