π About β’
β¨ Features β’
π» Technologies β’
π Project structure β’
βοΈ Environment variables β’
π How to run β’
βοΈ API endpoints β’
π License
E-Commerce Admin is a web application that allows you to manage your e-commerce store. I have created this project to learn more about next js app router. I have use nextjs as fullstack framework, tailwind css as css framework, clerk as authentication provider, planetscale as mysql database, prisma as orm, zustand as state management, shadcn/ui as ui components, react-hook-form for form validation, zod for data validation, axios for mutations, next-cloudinary for image upload, next-themes for dark mode, stripe for payment. I know that there are many things that I can improve in this project, I will try to improve it in the future. Feel free to contribute to this project. I will be very happy if you give this project a star β.
βββ .eslintrc.json
βββ .gitignore
βββ README.md
βββ actions
β βββ get-revenue-data.ts
β βββ get-sales-data.ts
β βββ get-stock-data.ts
βββ app
β βββ (auth)
β β βββ (routes)
β β β βββ sign-in
β β β β βββ [[...sign-in]]
β β β β βββ components
β β β β β βββ sign-in-with-theme.tsx
β β β β βββ page.tsx
β β β βββ sign-up
β β β βββ [[...sign-up]]
β β β βββ components
β β β β βββ sign-up-with-theme.tsx
β β β βββ page.tsx
β β βββ layout.tsx
β βββ (dashboard)
β β βββ [storeId]
β β β βββ (routes)
β β β β βββ billboards
β β β β β βββ [billboardId]
β β β β β β βββ components
β β β β β β β βββ billboard-form.tsx
β β β β β β βββ error.tsx
β β β β β β βββ loading.tsx
β β β β β β βββ page.tsx
β β β β β βββ components
β β β β β β βββ cell-action.tsx
β β β β β β βββ client.tsx
β β β β β β βββ columns.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ categories
β β β β β βββ [categoryId]
β β β β β β βββ components
β β β β β β β βββ category-form.tsx
β β β β β β βββ error.tsx
β β β β β β βββ loading.tsx
β β β β β β βββ page.tsx
β β β β β βββ components
β β β β β β βββ cell-action.tsx
β β β β β β βββ client.tsx
β β β β β β βββ columns.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ colors
β β β β β βββ [colorId]
β β β β β β βββ components
β β β β β β β βββ color-form.tsx
β β β β β β βββ error.tsx
β β β β β β βββ loading.tsx
β β β β β β βββ page.tsx
β β β β β βββ components
β β β β β β βββ cell-action.tsx
β β β β β β βββ client.tsx
β β β β β β βββ columns.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ error.tsx
β β β β βββ loading.tsx
β β β β βββ orders
β β β β β βββ components
β β β β β β βββ client.tsx
β β β β β β βββ columns.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ page.tsx
β β β β βββ products
β β β β β βββ [productId]
β β β β β β βββ components
β β β β β β β βββ product-form.tsx
β β β β β β βββ error.tsx
β β β β β β βββ loading.tsx
β β β β β β βββ page.tsx
β β β β β βββ components
β β β β β β βββ cell-action.tsx
β β β β β β βββ client.tsx
β β β β β β βββ columns.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ settings
β β β β β βββ components
β β β β β β βββ settings-form.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ sizes
β β β β βββ [sizeId]
β β β β β βββ components
β β β β β β βββ size-form.tsx
β β β β β βββ error.tsx
β β β β β βββ loading.tsx
β β β β β βββ page.tsx
β β β β βββ components
β β β β β βββ cell-action.tsx
β β β β β βββ client.tsx
β β β β β βββ columns.tsx
β β β β βββ error.tsx
β β β β βββ loading.tsx
β β β β βββ page.tsx
β β β βββ layout.tsx
β β βββ user-profile
β β βββ [[...user-profile]]
β β βββ layout.tsx
β β βββ page.tsx
β βββ (root)
β β βββ (routes)
β β β βββ page.tsx
β β βββ layout.tsx
β βββ api
β β βββ [storeId]
β β β βββ billboards
β β β β βββ [billboardId]
β β β β β βββ route.ts
β β β β βββ route.ts
β β β βββ categories
β β β β βββ [categoryId]
β β β β β βββ route.ts
β β β β βββ route.ts
β β β βββ checkout
β β β β βββ route.ts
β β β βββ colors
β β β β βββ [colorId]
β β β β β βββ route.ts
β β β β βββ route.ts
β β β βββ products
β β β β βββ [productId]
β β β β β βββ route.ts
β β β β βββ route.ts
β β β βββ sizes
β β β βββ [sizeId]
β β β β βββ route.ts
β β β βββ route.ts
β β βββ stores
β β β βββ [storeId]
β β β β βββ route.ts
β β β βββ route.ts
β β βββ webhook
β β βββ route.ts
β βββ favicon.ico
β βββ globals.css
β βββ layout.tsx
β βββ loading.tsx
βββ components.json
βββ components
β βββ main-nav.tsx
β βββ modals
β β βββ alert-modal.tsx
β β βββ store-modal.tsx
β βββ navbar-actions.tsx
β βββ navbar.tsx
β βββ overview.tsx
β βββ store-switcher.tsx
β βββ theme-toggle.tsx
β βββ ui
β βββ alert.tsx
β βββ api-alert.tsx
β βββ api-list.tsx
β βββ avatar.tsx
β βββ badge.tsx
β βββ button.tsx
β βββ card.tsx
β βββ checkbox.tsx
β βββ command.tsx
β βββ data-table.tsx
β βββ dialog.tsx
β βββ dropdown-menu.tsx
β βββ form.tsx
β βββ heading.tsx
β βββ image-upload.tsx
β βββ input.tsx
β βββ label.tsx
β βββ loader.tsx
β βββ modal.tsx
β βββ popover.tsx
β βββ select.tsx
β βββ separator.tsx
β βββ table.tsx
β βββ toast.tsx
β βββ toaster.tsx
β βββ use-toast.ts
βββ hooks
β βββ use-origin.tsx
β βββ use-store-modal.tsx
βββ lib
β βββ prismadb.ts
β βββ stripe.ts
β βββ utils.ts
βββ middleware.ts
βββ next.config.js
βββ package-lock.json
βββ package.json
βββ postcss.config.js
βββ prisma
β βββ schema.prisma
βββ providers
β βββ modal-provider.tsx
β βββ nprogress-provider.tsx
β βββ theme-provider.tsx
βββ public
β βββ next.svg
β βββ vercel.svg
βββ tailwind.config.ts
βββ tsconfig.json
βοΈ Environment variables
Create a .env.local
file in the root directory and add the following variables:
# CLERK
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=< CLERK_PUBLISHABLE_KEY>
CLERK_SECRET_KEY=< CLERK_SECRET_KEY>
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL=< PLANETSCALE_DATABASE_URL>
# Cloudinary
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=< CLOUDINARY_CLOUD_NAME>
NEXT_PUBLIC_CLOUDINARY_UPLOAD_PRESET=< CLOUDINARY_UPLOAD_PRESET>
# Stripe
STRIPE_SECRET_KEY=< STRIPE_SECRET_KEY>
STRIPE_WEBHOOK_SECRET=< STRIPE_WEBHOOK_SECRET>
# Frontend
FRONTEND_STORE_URL=< FRONTEND_STORE_URL>
Clone this repository
git clone https://github.com/b-l-i-n-d/ecommerce-admin.git
Install dependencies
Generate prisma client
dotenv -e .env.local -- npx prisma generate
# make sure to install dotenv-cli globally first
# npm install -g dotenv-cli
# or to be hassle free, just rename .env.local to .env
# and run npx prisma generate
Push prisma schema to database
dotenv -e .env.local -- npx prisma db push
Run the development server
Open http://localhost:3001 with your browser to see the result.
Endpoint
Method
Description
/api/stores
POST
Create new store
/api/stores/:id
PATCH
Update store
/api/stores/:id
DELETE
Delete store
Endpoint
Method
Description
/api/:storeId/billboards
GET
Get all billboards
/api/:storeId/billboards/:id
GET
Get billboard by id
/api/:storeId/billboards
POST
Create new billboard
/api/:storeId/billboards/:id
PATCH
Update billboard
/api/:storeId/billboards/:id
DELETE
Delete billboard
Endpoint
Method
Description
/api/:storeId/categories
GET
Get all categories
/api/:storeId/categories/:id
GET
Get category by id
/api/:storeId/categories
POST
Create new category
/api/:storeId/categories/:id
PATCH
Update category
/api/:storeId/categories/:id
DELETE
Delete category
Endpoint
Method
Description
/api/:storeId/sizes
GET
Get all sizes
/api/:storeId/sizes/:id
GET
Get size by id
/api/:storeId/sizes
POST
Create new size
/api/:storeId/sizes/:id
PATCH
Update size
/api/:storeId/sizes/:id
DELETE
Delete size
Endpoint
Method
Description
/api/:storeId/colors
GET
Get all colors
/api/:storeId/colors/:id
GET
Get color by id
/api/:storeId/colors
POST
Create new color
/api/:storeId/colors/:id
PATCH
Update color
/api/:storeId/colors/:id
DELETE
Delete color
Endpoint
Method
Description
/api/:storeId/products
GET
Get all products
/api/:storeId/products/:id
GET
Get product by id
/api/:storeId/products
POST
Create new product
/api/:storeId/products/:id
PATCH
Update product
/api/:storeId/products/:id
DELETE
Delete product
Endpoint
Method
Description
/api/:storeId/orders
GET
Get all orders
MIT