Skip to content

up2dul/cake-commerce

Repository files navigation

🍰 Cake Commerce

App screenshot

🌐 Built with Next.js, TypeScript, and Tailwind CSS for fast, responsive shopping experience

Table of Contents

Technologies

Some of the technologies used in this project:

  • βš›οΈ React β€” The main frontend library
  • β–² Next.js (App Router) β€” React framework with server components
  • 🎨 Tailwind CSS v4 β€” Utility-first CSS framework
  • πŸ”· TypeScript β€” A typed superset of JavaScript
  • πŸ›‘οΈ Zod β€” TypeScript-first schema validation with static type inference
  • 🐻 Zustand β€” Lightweight state management
  • ✨ Motion β€” Animation library for smooth transitions
  • 🍞 Lenis β€” Smooth scrolling library
  • 🎯 Sonner β€” Toast notifications
  • 🎨 Phosphor Icons β€” Beautiful icon library

Some additional development tools:

  • πŸ“ Biome β€” Code formatter and linter
  • πŸ”€ Commitlint β€” Ensure well-formatted commit messages
  • 🐢 Husky β€” Git hooks
  • πŸ“‹ Lint Staged β€” Run scripts before committing

Setup Instructions

1. Prerequisites

  • Node.js >=18.x
  • pnpm >=9.x (recommended as the package manager)

2. Clone the Repository

git clone https://github.com/up2dul/cake-commerce.git

# or if using ssh
git clone git@github.com:up2dul/cake-commerce.git

3. Installation

Go to the project directory and install dependencies

# Go to the project directory
cd cake-commerce

# Install dependencies
pnpm install

4. Environment Variables

Create a .env.local file in the root directory and add the following variables:

API_BASE_URL=https://api-example.com

Usage

Start the development server

pnpm dev

Open http://localhost:3000 with your browser to see the result.

Build for production

pnpm build
pnpm start

Project Structure

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ (main)/              # Main app routes
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx         # Home page
β”‚   β”‚   β”‚   β”œβ”€β”€ account/         # Account page
β”‚   β”‚   β”‚   β”œβ”€β”€ shop/            # Shop page
β”‚   β”‚   β”‚   β”‚   └── product/
β”‚   β”‚   β”‚   β”‚       └── [slug]/  # Product detail page
β”‚   β”‚   β”‚   └── _components/     # Shared components
β”‚   β”‚   β”œβ”€β”€ auth/                # Auth routes
β”‚   β”‚   β”‚   β”œβ”€β”€ login/
β”‚   β”‚   β”‚   β”‚   └── _components/
β”‚   β”‚   β”‚   └── register/
β”‚   β”‚   β”‚       └── _components/
β”‚   β”‚   β”œβ”€β”€ actions/             # Server actions
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts          # Auth server actions
β”‚   β”‚   β”‚   └── cart.ts          # Cart server actions
β”‚   β”‚   β”œβ”€β”€ globals.css          # Global styles
β”‚   β”‚   β”œβ”€β”€ layout.tsx           # Root layout
β”‚   β”‚   └── not-found.tsx        # 404 page
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ common/              # Common components
β”‚   β”‚   β”‚   β”œβ”€β”€ cart-drawer.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ cart-item-card.tsx
β”‚   β”‚   β”‚   └── cart-line-edit.tsx
β”‚   β”‚   β”œβ”€β”€ layout/              # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ navbar.tsx
β”‚   β”‚   β”‚   └── footer.tsx
β”‚   β”‚   └── ui/                  # Reusable UI components
β”‚   β”‚       β”œβ”€β”€ button.tsx
β”‚   β”‚       β”œβ”€β”€ input.tsx
β”‚   β”‚       β”œβ”€β”€ label.tsx
β”‚   β”‚       β”œβ”€β”€ checkbox.tsx
β”‚   β”‚       β”œβ”€β”€ textarea.tsx
β”‚   β”‚       β”œβ”€β”€ field.tsx
β”‚   β”‚       β”œβ”€β”€ tag.tsx
β”‚   β”‚       └── separator.tsx
β”‚   β”œβ”€β”€ hooks/                   # Custom React hooks
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ api.ts               # API client with error handling
β”‚   β”‚   β”œβ”€β”€ auth.ts              # Auth utilities
β”‚   β”‚   β”œβ”€β”€ config.ts            # Configuration
β”‚   β”‚   β”œβ”€β”€ utils.ts             # Utility functions
β”‚   β”‚   β”œβ”€β”€ data/                # Data fetching functions
β”‚   β”‚   β”‚   β”œβ”€β”€ product.ts       # Product data fetching
β”‚   β”‚   β”‚   β”œβ”€β”€ customer.ts      # Customer data fetching
β”‚   β”‚   β”‚   └── cart.ts          # Cart data fetching
β”‚   β”‚   β”œβ”€β”€ store/               # Zustand stores
β”‚   β”‚   β”‚   └── cart.ts          # Cart state management
β”‚   β”‚   └── types/               # TypeScript types
β”‚   β”‚       β”œβ”€β”€ product.ts
β”‚   β”‚       β”œβ”€β”€ cart.ts
β”‚   β”‚       β”œβ”€β”€ auth.ts
β”‚   β”‚       └── common.ts
β”‚   β”œβ”€β”€ assets/                  # Static images and assets
β”‚   └── proxy.ts                 # Proxy configuration
β”œβ”€β”€ public/                      # Static files
β”œβ”€β”€ biome.json                   # Biome configuration
β”œβ”€β”€ commitlint.config.ts         # Commitlint configuration
β”œβ”€β”€ next.config.ts              # Next.js configuration
β”œβ”€β”€ tsconfig.json               # TypeScript configuration
β”œβ”€β”€ tailwind.config.ts          # Tailwind CSS configuration
β”œβ”€β”€ postcss.config.mjs          # PostCSS configuration
β”œβ”€β”€ pnpm-workspace.yaml         # pnpm workspace config
β”œβ”€β”€ package.json
└── README.md

Development Workflow

Code Quality

The project uses Biome for automatic code formatting and linting:

# Format code
pnpm format

# Check code quality
pnpm lint

# Format and lint
pnpm check

Git Hooks

Husky and lint-staged ensure code quality before commits:

  • Pre-commit hook runs Biome formatting
  • Commit messages are validated with commitlint

Next Steps / Future Improvements

  • Fix the edit cart line bug
  • Checkout