Welcome to Popcorn Pal, a modern movie review and rating platform built to connect movie enthusiasts with their favorite films. Powered by Spring Boot on the backend and integrated with The Movie Database (TMDB) API, Popcorn Pal allows users to browse trending, popular, top-rated, and upcoming movies, add films to a personal watchlist, and share reviews with sentiment analysis. With secure user authentication via JWT, Popcorn Pal provides a seamless and engaging experience for cinephiles.
- Features
- Tech Stack
- Project Structure
- Setup and Installation
- API Endpoints
- Database Schema
- Authentication
- Sentiment Analysis
- Contributing
- License
- Movie Discovery: Browse trending, now playing, popular, top-rated, and upcoming movies using the TMDB API.
- Search Functionality: Search for movies with pagination support for a streamlined experience.
- User Management: Register, log in, and manage user profiles with secure JWT-based authentication.
- Watchlist: Add or remove movies from a personalized watchlist, enriched with movie details like title and poster.
- Reviews with Sentiment Analysis: Write, view, and delete movie reviews, with sentiment analysis powered by an n8n webhook.
- Secure APIs: Protected endpoints requiring authentication for user-specific actions.
- CORS Support: Configured to allow seamless communication with a React frontend running on
http://localhost:5173.
- Backend: Spring Boot 3.3.3 (Java 21)
- Database: PostgreSQL
- Authentication: Spring Security with JWT (JSON Web Tokens)
- API Client: RestTemplate for TMDB API integration
- ORM: Spring Data JPA with Hibernate
- Logging: SLF4J with Logback
- Dependencies:
spring-boot-starter-webspring-boot-starter-data-jpaspring-boot-starter-securityjjwt(JWT handling)postgresql(Database driver)lombok(Code simplification)spring-boot-starter-validation(Input validation)
The backend is organized into packages for clarity and maintainability:
com.edwin.Popcorn_Pal
βββ config
β βββ JwtAuthenticationFilter.java # JWT token validation filter
β βββ SecurityConfig.java # Spring Security configuration
β βββ WebConfig.java # CORS configuration for frontend
βββ controller
β βββ movieController.java # Handles movie-related API requests
β βββ ReviewController.java # Manages review CRUD operations
β βββ userController.java # User registration, login, and profile
β βββ WatchlistController.java # Watchlist management
βββ model
β βββ Review.java # Review entity
β βββ User.java # User entity
β βββ Watchlist.java # Watchlist entity
βββ repository
β βββ ReviewRepository.java # JPA repository for reviews
β βββ UserRepository.java # JPA repository for users
β βββ WatchlistRepository.java # JPA repository for watchlist
βββ service
β βββ movieService.java # Movie data fetching from TMDB
β βββ ReviewService.java # Review management with sentiment analysis
β βββ userService.java # User authentication and management
β βββ WatchlistService.java # Watchlist operations
βββ PopcornPalApplication.java # Main Spring Boot application
βββ pom.xml # Maven dependencies
βββ application.properties # Configuration properties
- Java 21
- Maven 3.8+
- PostgreSQL 13+
- TMDB API Key (get one from TMDB)
- n8n instance for sentiment analysis (optional, defaults to "Neutral" if unavailable)
-
Clone the Repository:
git clone https://github.com/<your-username>/Popcorn-Pal.git cd Popcorn-Pal
-
Configure the Database:
- Create a PostgreSQL database named
popcorn_pal. - Update
application.propertieswith your database credentials:spring.datasource.url=jdbc:postgresql://localhost:5432/popcorn_pal spring.datasource.username=your-username spring.datasource.password=your-password
- Create a PostgreSQL database named
-
Add TMDB API Key:
- Add your TMDB API key to
application.properties:tmdb.api.key=your-tmdb-api-key
- Add your TMDB API key to
-
Build and Run:
mvn clean install mvn spring-boot:run
-
Access the API:
- The backend runs on
http://localhost:8080. - Test endpoints using tools like Postman or integrate with a frontend (e.g., React on
http://localhost:5173).
- The backend runs on
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/api/users/register |
POST | Register a new user | None |
/api/users/login |
POST | Log in and receive JWT token | None |
/api/users/me |
GET | Get current user details | JWT |
/api/users/{username} |
GET | Get user by username | None |
/api/users/{userId} |
DELETE | Delete a user by ID | None |
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/api/movies/trending |
GET | Get trending movies | None |
/api/movies/details/{movieId} |
GET | Get movie details by TMDB ID | None |
/api/movies/now-playing |
GET | Get now playing movies | None |
/api/movies/popular |
GET | Get popular movies | None |
/api/movies/top-rated |
GET | Get top-rated movies | None |
/api/movies/upcoming |
GET | Get upcoming movies | None |
/api/movies/search?query={q} |
GET | Search movies by query with paging | None |
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/api/reviews |
POST | Add a new review | JWT |
/api/reviews/movie/{movieId} |
GET | Get reviews for a movie (paged) | None |
/api/reviews/{reviewId} |
DELETE | Delete a review by ID | JWT |
| Endpoint | Method | Description | Authentication |
|---|---|---|---|
/api/watchlist |
POST | Add movie to watchlist | JWT |
/api/watchlist |
GET | Get user's watchlist | JWT |
/api/watchlist/check/{movieId} |
GET | Check if movie is in watchlist | JWT |
/api/watchlist/{watchlistId} |
DELETE | Remove movie from watchlist | JWT |
The application uses PostgreSQL with three main tables:
| Column | Type | Description |
|---|---|---|
userId |
UUID | Primary key |
name |
VARCHAR | User's full name |
username |
VARCHAR | Unique username |
email |
VARCHAR | Unique email address |
password |
VARCHAR | Hashed password (BCrypt) |
createdAt |
TIMESTAMP | Account creation timestamp |
| Column | Type | Description |
|---|---|---|
reviewId |
UUID | Primary key |
tmdb_movie_id |
BIGINT | TMDB movie ID |
username |
VARCHAR | Reviewing user's username |
rating |
DOUBLE | Rating (e.g., 7.5) |
review_text |
VARCHAR(1000) | Review content |
created_at |
TIMESTAMP | Review creation timestamp |
tag |
VARCHAR | Sentiment (Positive/Negative/Neutral) |
| Column | Type | Description |
|---|---|---|
watchlistId |
UUID | Primary key |
username |
VARCHAR | User's username |
tmdb_movie_id |
BIGINT | TMDB movie ID |
added_at |
TIMESTAMP | Timestamp when added |
Popcorn Pal uses JWT-based authentication:
- Registration: Users register with a username, email, and password (hashed with BCrypt).
- Login: Successful login returns a JWT token, valid for 24 hours.
- Protected Endpoints: Endpoints like
/api/users/me,/api/watchlist, and/api/reviewsrequire a valid JWT in theAuthorizationheader (Bearer <token>). - Security Filter:
JwtAuthenticationFiltervalidates tokens and sets the security context for authenticated requests.
Note: The JWT secret key in
userService.java(SECRET_KEY) should be replaced with a secure, environment-specific key in production.
- Review Sentiment: When a user submits a review, the
ReviewServicesends the review text to an n8n webhook (http://localhost:5678/webhook-test/...) for sentiment analysis. - Response: The webhook returns a sentiment tag ("Positive", "Negative", or "Neutral"), which is stored in the
tagcolumn of thereviewstable. - Fallback: If the webhook fails, the sentiment defaults to "Neutral".
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add YourFeature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
Please ensure your code follows the project's coding style and includes relevant tests.
This project is licensed under the MIT License. See the LICENSE file for details.
Popcorn Pal is your go-to platform for movie exploration and community-driven reviews. Start building your watchlist and sharing your thoughts today! π¬