Before you start and running this project, you need to install the following tools:
- Make sure you already have or install node.js/npm.
- Clone this project https://github.com/prasajaa/simple-pos.git.
- Install the dependencies by running
npm install. - Renaming the
.env.examplecomponent to.envis mandatory. - Run
npm run devto start the development server.
- Sign up for a account at https://clerk.com.
- Create a new project application.
- Once the app is created, get the following values from the Clerk Dashboard:
- Publishable Key
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
- Secret Key
CLERK_SECRET_KEY
Add them to the .env file.
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key- Register for an account at https://supabase.com.
- Create a new project.
- In the Supabase dashboard, click on your project name in the topbar.
- Click the Connect button on the top right.
- Open the ORMs tab.
- Copy the .env.local file provided, and insert it into the variable below.
- Don't forget to replace
YOUR_PASSWORDin the string with your database password (can be found in Project Settings > Database).
Add them to the .env file:
# Connect to Supabase via connection pooling
DATABASE_URL=your_supabase_connection_pooling_url
# Direct connection to the database. Used for migrations
DIRECT_URL=your_supabase_direct_connection_url- Run the
npx prisma migrate devcommand to create a new table in the database. - Run the
npm run db:pushcommand to push the changes to the database.
- Open the database that you have created.
- Notice on the left sidebar, there is a Settings menu.
- Click the Settings menu, then in the
Project Settingssection, click theAPI Keysmenu. - In the
service_rolesecretsection, copy and save thesecretvalue. - Place the
secretvalue in theSUPABASE_ROLE_KEYvariable in the.envfile. - Notice in the header, to the right of your database menu, there is a Connect menu, click the menu.
- Click the
App Frameworkssection, make sure to select theNext.jsframework, usingPages Router, and withSupabase-Js. - Then copy everything in the
.env.localcolumn, to getNEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_AMON_KEY. - Don't forget to install the
Supabase-Jsdepedency, with the promptnpm install @supabase/supabase-js. - Open the Supabase sidebar again, in the Storage menu section, create a storage inside the supabase named
product-images(optional name) make sure to enablePublic bucket, so that the images uploaded to the Supabase database, will appear in the Product Management frontend, align it with thebucket.tscomponent.
Add them to the .env & bucket.ts file:
.env
NEXT_PUBLIC_SUPABASE_URL=your_api_key
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_api_key
SUPABASE_ROLE_KEY=your_api_keybucket.ts
export enum Bucket {
ProductImages = "product-images", //optional
}Activity Result :
- Create product
- Read Product
- Include file uploads with signed URL
- Forms -> RHF (React Hook Form)
- Update Product
- Filter products by category
- Delete Product
PRE-SIGNED URL -> POST https://.......
- Send a request to the backend to get a presigned URL
- Upload the image to the presigned URL
- Retrieve the object URL (product image)
- Send the image URL to the tRPC mutation
Cons
- Requires two requests
- The uploaded image might not be used
Pros
- Does not burden the server
This is a T3 Stack project bootstrapped with create-t3-app.
We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.
If you are not familiar with the different technologies used in this project, please refer to the respective docs. If you still are in the wind, please join our Discord and ask for help.
To learn more about the T3 Stack, take a look at the following resources:
- Documentation
- Learn the T3 Stack — Check out these awesome tutorials
You can check out the create-t3-app GitHub repository — your feedback and contributions are welcome!
Follow our deployment guides for Vercel, Netlify and Docker for more information.