Skip to content

etaelith/supabase-react

Repository files navigation

Supabase React TypeScript Project

This is a project leveraging Supabase, React, and TypeScript.

Overview

The application is built using several prominent technologies and frameworks, including:

  • Supabase: An open-source Firebase alternative, used as the backend for this application.
  • React: A popular JavaScript library for building the user interface.
  • TypeScript: A strongly typed superset of JavaScript, providing static types to the application.
  • Vite: A modern front-end build tool, used for bundling the application.

Getting Started

To get a local copy up and running, follow these steps:

  1. Clone the repository.
  2. Install the dependencies with npm install, pnpm install or yarn install.
  3. Start the project with npm run dev, pnpm dev or yarn dev.

Database Tables

This project uses the following database tables:

bill:

table stores information about bills or invoices. Here is a description of the table columns:

  • id: A unique identifier for each bill. It is an auto-incrementing integer.
  • created_at: The timestamp when the bill was created. It has a default value of the current timestamp.
  • name: The name or description of the bill. It is a non-null text field.
  • paid_up: A boolean field indicating whether the bill has been paid or not. It has a default value of false.
  • user_id: The UUID of the user associated with the bill. It is a non-null field.
  • amount: The numeric value representing the amount of the bill. It is a non-null field.
create table
  public.bill (
    id bigint generated by default as identity not null,
    created_at timestamp with time zone null default now(),
    name text not null,
    paid_up boolean not null default false,
    user_id uuid not null,
    amount numeric not null,
    constraint Bill_pkey primary key (id)
    constraint non_empty_string check ((name <> ''::text))
  ) tablespace pg_default;

create trigger trigger_update_user_summary_bill
after insert
or delete
or
update on bill for each row
execute function update_user_summary ();
id created_at name paid_up user_id amount
int8 now() text boolean uuid() numeric
125 2023-05-17 21:07:30.96618+00 electricity false 9311e255-4a5b-4222-b0b4-36547a2b0bf9 2500.75

The table also has a primary key constraint on the id column.

Additionally, there is a trigger named trigger_update_user_money associated with the bill table. The trigger is fired after any insert, delete, or update operation on the bill table. It executes a function named update_user_money().

user_summary:

The user_summary table stores information about the money balance for each user. Here is a description of the table columns:

  • id: A unique identifier for each record in the table. It is an auto-incrementing integer.
  • created_at: The timestamp when the record was created. It has a default value of the current timestamp.
  • total_paid: The total amount of money associated with the user. It is a non-null numeric field with a default value of 0.
  • total_unpaid: The amount of money paid out by the user. It is a non-null numeric field with a default value of 0.
  • total_user_amount: The amount of money the user have. It is a non-null numeric field with a default value of 0.
  • user_id: The UUID of the user associated with the money balance. It is a non-null field.

The table also has a primary key constraint on the id column and a unique constraint on the user_id column.

create table
  public.user_summary (
    id bigint generated by default as identity not null,
    created_at timestamp with time zone null default now(),
    user_id uuid not null,
    total_paid numeric not null default '0'::numeric,
    total_unpaid numeric not null default '0'::numeric,
    total_user_amount numeric not null default '0'::numeric,
    constraint user_summary_pkey primary key (id),
    constraint user_summary_user_id_key unique (user_id)
  ) tablespace pg_default;
id created_at total_paid total_unpaid total_user_amount user_id
int8 now() numeric numeric numeric uuid()
2 2023-05-17 21:07:30.96618+00 25.50 0 50000 9311e255-4a5b-4222-b0b4-36547a2b0bf9

user_amount:

The user_summary table stores information about the money balance for each user. Here is a description of the table columns:

  • id: A unique identifier for each record in the table. It is an auto-incrementing integer.
  • created_at: The timestamp when the record was created. It has a default value of the current timestamp.
  • amount: The total amount of money associated with the user. It is a non-null numeric field with a default value of 0.
  • description: The name or description of the pay.
  • user_id: The UUID of the user associated with the money balance. It is a non-null field.
create table
  public.user_amount (
    id bigint generated by default as identity not null,
    created_at timestamp with time zone null default now(),
    user_id uuid not null,
    amount numeric not null,
    name text null,
    constraint user_amount_pkey primary key (id)
    constraint non_empty_string check ((name <> ''::text))
  ) tablespace pg_default;

create trigger trigger_update_user_summary_user_amount
after insert
or delete
or
update on user_amount for each row
execute function update_user_summary ();
id created_at amount name user_id
int8 now() numeric text uuid()
2 2023-05-17 21:07:30.96618+00 25.50 0 9311e255-4a5b-4222-b0b4-36547a2b0bf9
Please note that this description is based on the provided table structure, and you may have additional columns or constraints in your actual implementation. Feel free to customize the description to fit your specific use case.

License

This project is licensed under the terms of the MIT license.


Please remember to replace any specific details as necessary for your project, including installation and usage instructions, and license details.

Releases

No releases published

Packages

No packages published

Languages