Getting Started
This guide will help you set up your local development environment for Popcorn Vision.Prerequisites
Before you begin, ensure you have the following installed:- Node.js (v18 or higher)
- pnpm (v9.15.5 or higher)
- Git
- TMDB API Key (get one at themoviedb.org)
Popcorn Vision uses pnpm as its package manager. The project is configured to use pnpm 9.15.5+.
Setting Up Your Development Environment
Install Dependencies
Install all project dependencies using pnpm:This will install all dependencies listed in
package.json, including Next.js, React, Tailwind CSS, and other required packages.Configure Environment Variables
Copy the example environment file and configure your TMDB API credentials:Edit
.env and add your TMDB API credentials:The image URLs are already pre-configured in
.env.example and don’t need to be changed.Start the Development Server
Available NPM Scripts
Popcorn Vision includes several npm scripts to help with development:Script Details
pnpm dev- Starts Next.js in development mode with hot module replacement (HMR). Changes to files are automatically reflected in the browser.pnpm build- Creates an optimized production build. Run this before deploying or testing production performance.pnpm start- Starts the production server. You must runpnpm buildfirst.pnpm lint- Runs ESLint using Next.js’s built-in configuration to check for code quality issues.
Project Structure
Understanding the project structure will help you navigate the codebase:Key Directories
src/app/- Next.js 14 uses the App Router. Each folder with route groups (in parentheses) organizes related pages.src/components/- Reusable React components organized by feature.src/zustand/- Global state management using Zustand for user data, favorites, and watchlist.src/lib/- Third-party library configurations and API clients.src/hooks/- Custom React hooks for shared logic.
Development Workflow
Hot Module Replacement (HMR)
When runningpnpm dev, Next.js automatically enables HMR:
- Component changes are reflected instantly without page refresh
- CSS changes are applied immediately
- API route changes require a manual refresh
- Configuration file changes (e.g.,
next.config.mjs) require server restart
Working with the TMDB API
Popcorn Vision integrates with The Movie Database (TMDB) API:- All API calls are made through the server-side or API routes to keep credentials secure
- API utilities are located in
src/lib/ - API responses are cached using Next.js’s built-in caching
- Rate limiting is handled by the
limiterpackage
State Management
The project uses Zustand for global state management:- User authentication state
- Favorites and watchlist
- UI state (modals, filters, etc.)
src/zustand/.
Styling
Popcorn Vision uses a combination of styling solutions:- Tailwind CSS - Utility-first CSS framework
- DaisyUI - Component library built on Tailwind
- Material UI - For specific components like date pickers
- Custom theme - Dark theme configured in
tailwind.config.js
Running Tests
Popcorn Vision currently does not have a test suite configured. Contributions to add testing infrastructure (Jest, React Testing Library, Playwright) are welcome!
Troubleshooting
Port Already in Use
If port 3000 is already in use, you can specify a different port:API Errors
If you’re seeing API errors:- Verify your TMDB API key is correct in
.env - Check that you have both
API_KEYandAPI_READconfigured - Ensure your API key has the necessary permissions
Build Errors
If you encounter build errors:- Clear the Next.js cache:
rm -rf .next - Delete
node_modulesand reinstall:rm -rf node_modules && pnpm install - Check for ESLint errors:
pnpm lint
Next Steps
Now that you have your development environment set up:- Review the Code Style guidelines
- Read the Contributing Guidelines
- Check the GitHub Issues for tasks to work on