create-mc-e-commerce-starter
v0.1.9
Published
This is a [E-commerce-starter](https://moccotech.com) project as a starting boilerplate for our clients projects.
Readme
MC E-Commerce-Starter
This is a E-commerce-starter project as a starting boilerplate for our clients projects.
Getting Started
First, setup the DB Supabase through the SQL command line -> Supabase dashboard:
# Create users table
create table public.users (
id uuid not null,
created_at timestamp with time zone not null default now(),
first_name text null,
last_name text null,
email text not null,
company_name text null,
address text null,
postal_code text null,
city text null,
country text null,
dealer_level public.dealer_level not null default '1'::dealer_level,
company_number text null,
shipping_address text null,
shipping_city text null,
shipping_country text null,
shipping_postal_code text null,
phone text null,
status public.account_status not null default 'pending'::account_status,
constraint users_pkey primary key (id),
constraint users_email_key unique (email),
constraint users_id_key unique (id),
constraint users_id_key1 unique (id),
constraint users_id_key2 unique (id),
constraint users_id_fkey foreign KEY (id) references auth.users (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
# Create products table
create table public.products (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
handle text null,
title text null,
description jsonb null,
price double precision null,
weight double precision null,
images text[] null,
sport public.sport not null default 'finswimming'::sport,
updated_at timestamp with time zone not null default (now() AT TIME ZONE 'utc'::text),
discount_price double precision null,
constraint products_pkey primary key (id)
) TABLESPACE pg_default;
# Create products attributes table
create table public.product_attributes (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
price_increase bigint null default '0'::bigint,
value text null,
category public.attribute_category null,
constraint product_attributes_pkey primary key (id),
constraint product_attributes_id_key unique (id)
) TABLESPACE pg_default;
# Create products and attributes connection table
create table public.product_attributes_values (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
product bigint null,
attribute bigint null,
constraint product_attributes_values_pkey primary key (id),
constraint product_attributes_values_id_key unique (id),
constraint product_attributes_values_unique unique (product, attribute),
constraint product_attributes_values_attribute_fkey foreign KEY (attribute) references product_attributes (id) on update CASCADE on delete CASCADE,
constraint product_attributes_values_product_fkey foreign KEY (product) references products (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
# Create product categories table
create table public.product_categories (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
handle text not null,
title jsonb null default '{"en": ""}'::jsonb,
description jsonb null default '{"en": ""}'::jsonb,
parent bigint null,
constraint product_categories_pkey primary key (id),
constraint product_categories_handle_key unique (handle),
constraint product_categories_parent_fkey foreign KEY (parent) references product_categories (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
# Create products and categories connection table
create table public.product_categories_values (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
product bigint not null,
category bigint not null,
constraint product_categories_values_pkey primary key (id),
constraint product_categories_values_category_fkey foreign KEY (category) references product_categories (id) on update CASCADE on delete CASCADE,
constraint product_categories_values_product_fkey foreign KEY (product) references products (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
# Create Orders table
create table public.orders (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
amount text null,
user_email text null,
status public.order_status not null default 'pending-payment'::order_status,
address text null,
postal_code text null,
country text null,
rev_token text null,
city text null,
billing_address text null,
billing_postal_code text null,
billing_city text null,
billing_country text null,
shipping double precision null,
constraint orders_pkey primary key (id),
constraint orders_user_email_fkey foreign KEY (user_email) references users (email) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
# Create Order Items table
create table public.order_items (
id bigint generated by default as identity not null,
created_at timestamp with time zone not null default now(),
order_id bigint null,
amount double precision null,
product_id bigint null,
quantity bigint null,
attributes jsonb[] null,
constraint order_items_pkey primary key (id),
constraint order_items_order_id_fkey foreign KEY (order_id) references orders (id) on update CASCADE on delete CASCADE,
constraint order_items_product_id_fkey foreign KEY (product_id) references products (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;
Add the Supabase API keys to the .env file:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
# Site Data
NEXT_PUBLIC_SITE_URL=
NEXT_PUBLIC_SITE_NAME=
NEXT_PUBLIC_DEFAULT_LOCALE=
# Revolut
REVOLUT_SECRET_KEY=
# Captcha
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=
# Email
HOST_EMAIL=
ADMIN_EMAIL=
ADMIN_EMAIL_PASSWORD=Then run the development server:
npm run devOpen http://localhost:3000 with your browser to see the result.
Internationalization
- Use the
constants.tsfile to change or add a locales by editing theAVAILABLE_LOCALESarray. - Add your locale to the
types/index.tsfile. - Add your new internalization file in the
.jsonformat to themessagesfolder. - Change your locales array in the
i18n/routing.tsfile. - Change the default locale in the middleware.
Learn More
To learn more about the project.
- Next.js Documentation - learn about Next.js features and API.
- Next-Intl Documentation - learn about next-intl (internationalization library for Next.js).
- Supabase Documentation - learn about Supabase (BAAS).
- Shadcn/ui Documentation - learn about Shadcn/ui components library.
- Revolut Payments - learn about Revolut Payments API
