This is a modern e-commerce application built with Next.js, offering a robust and scalable platform for selling clothes, sneakers, and more.
- Product Catalog: Browse and search for products by category.
- Product Variants: Select different product variations (e.g., size, color).
- Shopping Cart: Add, remove, and update products in the cart.
- Authentication: User sign-up and sign-in with Google.
- Responsive Design: Fully responsive layout for a seamless experience on any device.
This project is built with a modern tech stack, including:
- Framework: Next.js
- Styling: Tailwind CSS
- UI Components: Radix UI, shadcn/ui, and Lucide Icons
- State Management: TanStack Query
- Database ORM: Drizzle ORM
- Database: PostgreSQL
- Authentication: Better Auth
- Form Management: React Hook Form and Zod
- Component Development: Storybook
- Testing: Jest and React Testing Library
- Linting & Formatting: ESLint and Prettier
- Git Hooks: Husky
- Containerization: Docker
To get a local copy up and running, follow these simple steps.
-
Clone the repository:
git clone https://github.com/your-username/e-commerce.git cd e-commerce -
Install dependencies:
yarn install # or npm install -
Set up environment variables:
Create a
.envfile in the root of the project and add the following variables:DATABASE_URL="postgresql://user:password@localhost:5432/dbname" # Add other environment variables from enviroment-example.env
You can use the
enviroment-example.envfile as a template. -
Start the database:
This project uses Docker to run a local PostgreSQL database.
yarn docker:start
-
Run database migrations:
Apply the database schema to your local database.
yarn drizzle
-
Seed the database:
Populate the database with initial data.
yarn db:seed
To start the development server, run:
yarn devOpen http://localhost:3000 with your browser to see the result.
dev: Starts the development server.build: Creates a production build.start: Starts the production server.lint: Lints the codebase using ESLint.docker:start: Starts the Docker container for the database.docker:stop: Stops the Docker container for the database.drizzle: Pushes the database schema changes.drizzle:generate: Generates SQL migration files.drizzle:studio: Opens the Drizzle Studio.drizzle:migrate: Applies pending migrations.db:seed: Seeds the database with initial data.test: Runs the test suite.test:watch: Runs the test suite in watch mode.commit: A utility script to help with conventional commits.storybook: Starts the Storybook development server.build-storybook: Builds the Storybook for deployment.
The project structure is organized as follows:
.
├── src/
│ ├── actions/ # Server actions
│ ├── app/ # Next.js App Router pages and layouts
│ ├── components/ # Reusable UI components
│ ├── db/ # Drizzle ORM schema and seed scripts
│ ├── helpers/ # Helper functions
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Library and utility functions
│ └── providers/ # React context providers
├── drizzle/ # Drizzle ORM output
...
Authentication is handled by Better Auth, which provides a simple and secure way to manage user authentication. The configuration can be found in src/lib/auth.ts and the API route in src/app/api/auth/[...all]/route.ts.
This project uses Jest and React Testing Library for testing. Test files are located alongside the files they are testing or in the .jest directory.
To run the tests, use the following command:
yarn testContributions are welcome! Please follow the Conventional Commits specification for commit messages.
To contribute:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
yarn commit) - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for more information.