A modern Next.js e-commerce application for a cocktail business, featuring dynamic product pages, shopping cart functionality, and Stripe payment integration.
- Next.js 15 - React framework with App Router
- React 18 - UI library
- TypeScript - Type-safe JavaScript
- Styled-components - CSS-in-JS styling solution
- Prisma - Database ORM with PostgreSQL
- Stripe - Payment processing
- ESLint - Code linting
- Jest - Testing framework
- PostCSS - CSS processing
- Autoprefixer - CSS vendor prefixing
- PostgreSQL - Production database
- SQLite - Development database
- Prisma Accelerate - Database connection pooling and caching
- Vercel - Deployment platform
- Geist Font - Optimized font family by Vercel
- next/font - Font optimization
βββ src/
β βββ app/ # App Router directory
β β βββ api/ # API routes
β β βββ cart/ # Shopping cart pages
β β βββ checkout/ # Checkout flow
β β βββ shop/ # Product pages
β β βββ globals.css # Global styles
β β βββ layout.tsx # Root layout component
β β βββ page.tsx # Home page component
β βββ components/ # Reusable components
β β βββ CartIcon/ # Shopping cart icon
β β βββ Navigation/ # Navigation components
β β βββ ProductPage/ # Product display components
β β βββ ... # Other components
β βββ contexts/ # React contexts
β βββ data/ # Data fetching services
β βββ lib/ # Utility libraries
β βββ theme/ # Styled-components theme
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
βββ prisma/ # Database configuration
β βββ migrations/ # Database migrations
β βββ schema.prisma # Database schema
β βββ schema.dev.prisma # Development schema
β βββ schema.prod.prisma # Production schema
β βββ seed.ts # Database seeding
βββ public/ # Static assets
βββ __tests__/ # Test files
βββ ... # Configuration files
- Node.js 18.17 or later
- npm, yarn, pnpm, or bun package manager
- PostgreSQL database (for production)
-
Clone the repository
git clone <repository-url> cd cocktail-business-project
-
Install dependencies
npm install
-
Set up environment variables
Create
.env.localfor development:DATABASE_URL="file:./dev.db" NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="your_stripe_public_key" STRIPE_SECRET_KEY="your_stripe_secret_key"
-
Set up the database
# For development (SQLite) npm run db:dev npm run db:seed # For production (PostgreSQL) npm run db:prod npx prisma migrate deploy npm run db:seed:prod
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000 to see the result.
npm run dev- Start development servernpm run build- Build for productionnpm run build:prod- Build for production with production databasenpm run start- Start production servernpm run lint- Run ESLintnpm run test- Run testsnpm run db:dev- Switch to development database (SQLite)npm run db:prod- Switch to production database (PostgreSQL)npm run db:seed- Seed development databasenpm run db:seed:prod- Seed production database
This project uses Styled-components for styling with a comprehensive theme system:
- Colors: Primary, secondary, accent colors with light/dark variants
- Typography: Font families, sizes, weights, and line heights
- Spacing: Consistent spacing scale
- Breakpoints: Responsive design breakpoints
- Shadows: Elevation and depth system
- Each component has its own
.styles.tsxfile - Styled-components provide CSS-in-JS with TypeScript support
- Theme-aware components that adapt to light/dark modes
- Responsive design with mobile-first approach
model Product {
id String @id @default(cuid())
name String
subtitle String
description String
longDescription String
price String
priceSubtext String
imageColor String
imageUrl String?
features Json
ingredients Json? // Array of ingredient strings
productBrief String? // Product introduction
nutritionFacts Json? // Array of nutrition facts
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("products")
}- Ingredients: JSON array of ingredient lists
- Product Brief: Detailed product descriptions
- Nutrition Facts: Nutritional information tables
- Image Management: Color placeholders with optional image URLs
- Features: Product feature badges and highlights
- Push your code to GitHub
- Import your project to Vercel
- Configure environment variables:
DATABASE_URL- Prisma Accelerate connectionDIRECT_URL- Direct PostgreSQL connectionNEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY- Stripe public keySTRIPE_SECRET_KEY- Stripe secret key
- Deploy automatically on every push
# Deploy to production
vercel --prod
# Seed production database
npm run db:seed:prodThe project includes comprehensive testing with Jest:
- Unit Tests: Component and utility function tests
- Integration Tests: API route and data service tests
- Test Utilities: Custom test helpers and mocks
npm run test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverageGET /api/products- Get all productsGET /api/products/[id]- Get specific productPOST /api/create-checkout-session- Create Stripe checkout sessionPOST /api/checkout-session- Handle checkout completionPOST /api/seed-production- Seed production database
- Dynamic Loading: Skeleton loading states for better UX
- Rich Information: Ingredients, nutrition facts, and product briefs
- Image Management: Color placeholders with fallback images
- Responsive Design: Mobile-first approach
- Cart Management: Add/remove items with quantity controls
- Checkout Flow: Seamless Stripe integration
- Order Confirmation: Success pages with order details
- Database Optimization: Prisma Accelerate for connection pooling
- Image Optimization: Next.js Image component with optimization
- Code Splitting: Automatic route-based code splitting
- Caching: Intelligent caching strategies
- Image optimization settings
- Environment variable configuration
- Custom webpack configuration
- Database schema definition
- Prisma client configuration
- Migration settings
- TypeScript compiler options
- Path mapping configuration
- Strict type checking
- Next.js Documentation - Learn about Next.js features and API
- Styled-components Documentation - Learn Styled-components
- Prisma Documentation - Learn Prisma ORM
- Stripe Documentation - Learn Stripe integration
- TypeScript Documentation - Learn TypeScript
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Next.js GitHub repository
- Open an issue in this repository
- Consult the documentation links above
Happy coding! π