Professional Documents
Culture Documents
Filmlane
Filmlane
Since movies are fetched from an external API like TMDb and not stored locally, we don't need to
create a movie table. Instead, we'll have tables for users, their history, and their watchlist.
1. Users Table:
- user_id (Primary Key)
- username
- email
- password (hashed)
- created_at
- updated_at
With this schema, users can have their own history of watched movies and a watchlist. Here's
how each feature maps to the database:
- Stream Movie:
- Fetch movie details from the external API.
- Update user history upon watching.
- History Management:
- View, clear, search, and remove movies from the history based on the user_id.
- Watchlist Management:
- View, clear, search, and remove movies from the watchlist based on the user_id.
- Login and Logout:
- Authenticate users based on username/email and password from the Users table.
- Update Account:
- Update user details in the Users table.
- Home Page:
- Display personalized recommendations based on user history and watchlist.
- Movie Info:
- Fetch detailed information about a selected movie from the external API.
Database
Here's a list of necessary database interactions based on the functionalities you provided:
1. User Registration:
- Insert new user data into the Users table.
2. User Login:
- Retrieve user data based on username/email and password from the Users table for
authentication.
3. User Logout:
- No direct interaction with the database, typically handled in the application's session
management.
4. Update Account:
- Update user details (username, email, password) in the Users table.
5. Stream Movie:
- Fetch movie details from the external API.
- Insert a new record into the User History table indicating the movie the user watched and the
date they watched it.
6. View History:
- Retrieve movie history records based on the user_id from the User History table.
7. Clear History:
- Delete history records based on the user_id from the User History table.
8. Search History:
- Retrieve history records based on search criteria and user_id from the User History table.
controller
Here's an explanation of each controller, detailing what they do and how they achieve it:
1. Login Controller (`login.php`):
- Functionality: Handles user login.
- How it works:
- Receives POST request with username/email and password.
- Validates the credentials against the database (using the User model).
- If valid, sets session data to mark the user as logged in.
- Redirects to the home page or displays an error message.
Each controller encapsulates specific functionality and interacts with the models to retrieve or
manipulate data from the database. It then passes the data to the corresponding view for
rendering to the user.
Model
here's an explanation of each model in your project, detailing what they do and how they
achieve it:
Each model encapsulates specific functionality related to its domain and interacts with the
database or external API to perform data operations. The controllers in your application use
these models to fetch or manipulate data and pass it to the views for rendering.