A modern e-commerce platform built with Next.js 13, focusing on physical media collections like DVDs and Blu-rays.
- ποΈ Product catalog with collections
- π User authentication with Google
- π Shopping cart functionality
- π§ Newsletter subscription
- π Contact form with reCAPTCHA
- π Dark/Light mode
- π± Responsive design
- βοΈ SendGrid email integration
- π¬ TMDB API integration for movie data
- Next.js 13.4.5
- TypeScript
- Tailwind CSS
- Prisma
- NextAuth.js
- SendGrid
- reCAPTCHA
- Sonner (Toast notifications)
- TMDB API
Before you begin, ensure you have:
- Node.js (v16 or higher)
- npm or yarn
- PostgreSQL database
- Accounts/API keys for:
- SendGrid
- Google Cloud Console
- reCAPTCHA
- TMDB
- Create a SendGrid account
- Navigate to Settings > API Keys
- Click "Create API Key"
- Choose "Full Access" or customize permissions
- Copy the generated API key (you'll only see it once!)
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the OAuth 2.0 API:
- Go to APIs & Services > Library
- Search for "OAuth" and enable it
- Configure OAuth consent screen:
- Go to APIs & Services > OAuth consent screen
- Choose User Type (External)
- Fill in application information
- Create credentials:
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web application"
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/google
(development)https://your-domain.com/api/auth/callback/google
(production)
- Copy the Client ID and Client Secret
- Visit Google reCAPTCHA Admin
- Click the + (plus) sign to add a new site
- Choose reCAPTCHA v2 Invisible
- Add your domains (localhost for development)
- Copy the Site Key and Secret Key
- Create an account on TMDB
- Go to your account settings
- Click "API" in the left sidebar
- Follow the steps to request an API key
- Copy your API key (v3 auth)
Create a .env
file in the root directory:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/your_database"
# Authentication
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-generated-secret" # Generate with: openssl rand -base64 32
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# SendGrid
SENDGRID_API_KEY="your-sendgrid-api-key"
NEXT_PUBLIC_CONTACT_EMAIL="your-contact-email"
# reCAPTCHA
NEXT_PUBLIC_RECAPTCHA_SITE_KEY="your-recaptcha-site-key"
RECAPTCHA_SECRET_KEY="your-recaptcha-secret-key"
# TMDB
NEXT_PUBLIC_TMDB_API_KEY="your-tmdb-api-key"
- Clone the repository:
git clone https://github.com/yourusername/trpc-shop.git
cd trpc-shop
- Install dependencies:
npm install
- Set up the database:
# Generate Prisma client
npx prisma generate
# Push schema to database
npx prisma db push
# (Optional) Seed the database
npx prisma db seed
- Run development server:
npm run dev
trpc-shop/
βββ app/ # Next.js 13 app directory
β βββ api/ # API routes
β βββ components/ # React components
β βββ contexts/ # Context providers
β βββ hooks/ # Custom hooks
β βββ lib/ # Utility functions
β βββ providers/ # Service providers
βββ prisma/ # Database schema
βββ public/ # Static assets
βββ styles/ # Global styles
app/api/auth/[...nextauth]/route.ts
: Authentication endpointsapp/api/contact/route.ts
: Contact form handlingapp/api/newsletter/route.ts
: Newsletter subscription
app/page.tsx
: Home pageapp/about/page.tsx
: About pageapp/contact/page.tsx
: Contact formapp/profile/page.tsx
: User profileapp/new-releases/page.tsx
: New releases
Header
: Navigation and authenticationFooter
: Newsletter subscription and linksBenefits
: Product benefits displayFeaturedCollections
: Collection showcaseProductListing
: Product grid display
- Log in to SendGrid
- Go to Email API > Dynamic Templates
- Create a template for:
- Newsletter Welcome
- Contact Form Notifications
- Copy template IDs to your environment variables
Using NextAuth.js with Prisma adapter:
<AuthProvider>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
<CartProvider>
<Header />
<main className="pt-16 transition-all duration-300">{children}</main>
<Footer />
</CartProvider>
</ThemeProvider>
</AuthProvider>
Using Tailwind CSS with custom configuration:
- Dark/Light mode support
- Responsive design
- Custom components
- Choose a hosting platform (Vercel recommended)
- Set up environment variables
- Connect your repository
- Deploy:
# Build the application
npm run build
# Start production server
npm start
- Fork the repository
- Create your feature branch:
git checkout -b feature/AmazingFeature
- Commit your changes:
git commit -m 'Add some AmazingFeature'
- Push to the branch:
git push origin feature/AmazingFeature
- Open a Pull Request
-
Database Connection
- Verify PostgreSQL is running
- Check DATABASE_URL format
- Ensure database exists
-
Authentication
- Verify redirect URIs in Google Console
- Check NEXTAUTH_URL matches your domain
- Ensure all auth environment variables are set
-
Email Not Sending
- Verify SendGrid API key
- Check sender verification
- Review SendGrid activity logs
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work
- Next.js team
- Tailwind CSS
- Vercel
- SendGrid
- TMDB
- All contributors
For more detailed documentation, please refer to individual component files and the official documentation of used libraries.