Skip to content

Commit

Permalink
Merge pull request #81 from hoangsonww/homepage-enhancements
Browse files Browse the repository at this point in the history
Updated mobile app (75)
  • Loading branch information
hoangsonww authored Mar 11, 2024
2 parents 33817ad + 2cf88d4 commit 0e19f34
Show file tree
Hide file tree
Showing 197 changed files with 5,136 additions and 1,548 deletions.
450 changes: 266 additions & 184 deletions MovieVerse-Mobile/.idea/workspace.xml

Large diffs are not rendered by default.

150 changes: 94 additions & 56 deletions MovieVerse-Mobile/platforms/android/app/src/main/assets/www/404.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Son Nguyen Hoang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# The MovieVerse - `MovieVerse-Databases` Directory

Welcome to the `MovieVerse-Database` directory of the MovieVerse App! This directory contains the SQL and JavaScript files essential for setting up and managing the databases used in the application, including Firebase, MySQL, and MongoDB. NOTE: These files are only placeholders and do not reflect what are actually used by us in production or development - you need to contact us for more details about using our databases if you would like to contribute and need database access!

---

## Overview

The `MovieVerse-Database` directory is critical for managing the data structures and schemas for the MovieVerse application. It includes files for setting up relational databases (MySQL) and NoSQL databases (MongoDB, Firebase).

### movie-user.sql

A SQL script file for creating and setting up user-related tables in a MySQL database. It defines the schema for storing user data, such as profiles, preferences, and authentication details.

### movieverse_chatbot.sql

This SQL file contains the schema and data for the chatbot feature in the application. It includes tables for storing chatbot responses, user queries, and interaction logs.

### movieverse_nosql_setup.js

A JavaScript file to set up and configure the NoSQL databases (Firebase, MongoDB). It contains scripts for initializing collections, defining documents, and setting up initial data or rules.

### movieverse_schema.sql

A comprehensive SQL script that defines the entire database schema for the MovieVerse application. It includes tables for movies, genres, reviews, ratings, and other related data.

### movieverse_user_management.sql

Contains SQL scripts related to user management features. This includes user roles, permissions, account settings, and other functionalities necessary for user account handling.

### firebase.json

A configuration file for Firebase, containing settings and rules for the Firebase Realtime Database. It defines the access rules, security settings, and other configurations for the Firebase database.

### firestore.indexes.json

A configuration file for Firestore, containing indexes and settings for the Firestore database. It defines the indexes, sorting, and other configurations for the Firestore database.

### firestore.rules

A configuration file for Firestore, containing access rules and settings for the Firestore database. It defines the access rules, security settings, and other configurations for the Firestore database.

### storage.rules

A configuration file for Firebase Storage, containing access rules and settings for the Firebase Storage service. It defines the access rules, security settings, and other configurations for the Firebase Storage.

### test_api_db.py

A Python script for testing the API and database connections. It includes sample queries, data retrieval, and other operations to test the database connections and API endpoints.

## Using these Files

These files are crucial for setting up the backend of the application. Ensure that you have the necessary database servers (MySQL, MongoDB, Firebase) running and accessible. Run these scripts to create and configure your databases according to the project's requirements.

## Customization and Adaptation

You may need to customize these scripts to fit the specific needs of your application. Be sure to regularly back up your databases before making any changes to these scripts.

## Contact

As mentioned, you'll need to contact us if you would like to access our databases or other back-end features. Feel free to reach out to us at [[email protected]]([email protected]). We look forward to collaborating with you!

---
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"storage": {
"rules": "storage.rules"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"indexes": [
{
"collectionGroup": "movies",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "genre", "order": "ASCENDING" },
{ "fieldPath": "releaseYear", "order": "ASCENDING" }
]
},
{
"collectionGroup": "directors",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "name", "order": "ASCENDING" }
],
"fieldOverrides": [
{
"fieldPath": "name",
"arrayConfig": "CONTAINS"
}
]
},
{
"collectionGroup": "actors",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "name", "order": "ASCENDING" }
],
"fieldOverrides": [
{
"fieldPath": "name",
"arrayConfig": "CONTAINS"
}
]
},
{
"collectionGroup": "users",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "name", "order": "ASCENDING" }
],
"fieldOverrides": [
{
"fieldPath": "name",
"arrayConfig": "CONTAINS"
}
]
},
{
"collectionGroup": "reviews",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "rating", "order": "ASCENDING" }
]
}
],
"fieldOverrides": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
service cloud.firestore {
match /databases/{database}/documents {
match /movies/{movie} {
allow read: if true;
allow write: if request.auth != null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
-- Create a databases (Uncomment if needed)
CREATE DATABASE MovieVerseDB;

-- Switch to the MovieVerseDB databases (Uncomment if needed)
\c MovieVerseDB

-- Create table for storing movie details
CREATE TABLE movies (
movie_id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
release_date DATE,
genre VARCHAR(100),
director VARCHAR(255),
description TEXT,
duration INT,
language VARCHAR(50),
country VARCHAR(100),
poster_url VARCHAR(255)
);

-- Create table for storing movie cast
CREATE TABLE cast (
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
actor VARCHAR(255),
role VARCHAR(255),
PRIMARY KEY (movie_id, actor)
);

-- Create table for storing movie crew
CREATE TABLE crew (
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
crew_member VARCHAR(255),
role VARCHAR(255),
PRIMARY KEY (movie_id, crew_member)
);

-- Create table for storing movie trailers
CREATE TABLE trailers (
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
trailer_url VARCHAR(255),
PRIMARY KEY (movie_id, trailer_url)
);

-- Create table for storing user information
CREATE TABLE users (
user_id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
join_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_admin BOOLEAN DEFAULT FALSE
);

-- Create table for storing reviews
CREATE TABLE reviews (
review_id SERIAL PRIMARY KEY,
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
review_text TEXT,
review_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
rating DECIMAL(2, 1) CHECK (rating >= 0 AND rating <= 10)
);

-- Create table for storing ratings
CREATE TABLE ratings (
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
rating DECIMAL(2, 1) NOT NULL CHECK (rating >= 0 AND rating <= 10),
rating_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, movie_id)
);

-- Create table for storing movie favorites
CREATE TABLE favorites (
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
favorited_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, movie_id)
);

-- Create table for storing movie watchlist
CREATE TABLE watchlist (
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
added_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, movie_id)
);

-- Create table for storing movie watch history
CREATE TABLE watch_history (
user_id INT REFERENCES users(user_id) ON DELETE CASCADE,
movie_id INT REFERENCES movies(movie_id) ON DELETE CASCADE,
watched_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (user_id, movie_id)
);

-- Indexes for performance optimization
CREATE INDEX idx_movies_title ON movies(title);
CREATE INDEX idx_reviews_user_id ON reviews(user_id);
CREATE INDEX idx_reviews_movie_id ON reviews(movie_id);
CREATE INDEX idx_ratings_user_id ON ratings(user_id);
CREATE INDEX idx_ratings_movie_id ON ratings(movie_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- Drop existing tables if they exist to prevent errors
DROP TABLE IF EXISTS Movies;
DROP TABLE IF EXISTS Genres;
DROP TABLE IF EXISTS Actors;
DROP TABLE IF EXISTS Directors;
DROP TABLE IF EXISTS MovieGenres;
DROP TABLE IF EXISTS MovieActors;
DROP TABLE IF EXISTS MovieDirectors;

-- Table for storing movie genres
CREATE TABLE Genres (
GenreID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL
);

-- Table for storing actors
CREATE TABLE Actors (
ActorID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
Birthdate DATE,
Country VARCHAR(100)
);

-- Table for storing directors
CREATE TABLE Directors (
DirectorID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(255) NOT NULL,
Birthdate DATE,
Country VARCHAR(100)
);

-- Table for storing movies
CREATE TABLE Movies (
MovieID INT PRIMARY KEY AUTO_INCREMENT,
Title VARCHAR(255) NOT NULL,
ReleaseDate DATE,
Language VARCHAR(50),
Runtime INT,
Budget DECIMAL(15, 2),
Revenue DECIMAL(15, 2),
Plot TEXT
);

-- Many-to-many relationship table between Movies and Genres
CREATE TABLE MovieGenres (
MovieID INT,
GenreID INT,
PRIMARY KEY (MovieID, GenreID),
FOREIGN KEY (MovieID) REFERENCES Movies(MovieID) ON DELETE CASCADE,
FOREIGN KEY (GenreID) REFERENCES Genres(GenreID) ON DELETE CASCADE
);

-- Many-to-many relationship table between Movies and Actors
CREATE TABLE MovieActors (
MovieID INT,
ActorID INT,
PRIMARY KEY (MovieID, ActorID),
FOREIGN KEY (MovieID) REFERENCES Movies(MovieID) ON DELETE CASCADE,
FOREIGN KEY (ActorID) REFERENCES Actors(ActorID) ON DELETE CASCADE
);

-- Many-to-many relationship table between Movies and Directors
CREATE TABLE MovieDirectors (
MovieID INT,
DirectorID INT,
PRIMARY KEY (MovieID, DirectorID),
FOREIGN KEY (MovieID) REFERENCES Movies(MovieID) ON DELETE CASCADE,
FOREIGN KEY (DirectorID) REFERENCES Directors(DirectorID) ON DELETE CASCADE
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- Create 'chatbot_sessions' table
CREATE TABLE chatbot_sessions (
session_id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
end_time TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id)
);

-- Create 'chatbot_messages' table
CREATE TABLE chatbot_messages (
message_id INT AUTO_INCREMENT PRIMARY KEY,
session_id INT,
message TEXT NOT NULL,
sender ENUM('user', 'bot') NOT NULL,
message_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (session_id) REFERENCES chatbot_sessions(session_id)
);

-- Create 'chatbot_logs' table for logging purposes
CREATE TABLE chatbot_logs (
log_id INT AUTO_INCREMENT PRIMARY KEY,
session_id INT,
log_message TEXT NOT NULL,
log_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (session_id) REFERENCES chatbot_sessions(session_id)
);

-- Indexes for optimizing queries
CREATE INDEX idx_session_user ON chatbot_sessions (user_id);
CREATE INDEX idx_messages_session ON chatbot_messages (session_id);
Loading

0 comments on commit 0e19f34

Please sign in to comment.