watermoviemelon is a fun, interactive web application designed to bring friends, family, and movie lovers together to organize unforgettable movie nights! It makes planning and hosting movie events a breeze. Users can create a movie night, add movie options, and let the app randomly select a film for the evening—keeping the suspense alive until showtime! Once the night ends, everyone can rate the film!
- Event Creation: Easily set up movie nights or join to the existing one.
- Movie List Management: Add movies to a global list shared across all movie nights. Once a film is added, it remains in the pool, keeping the options fresh and interesting for future events until it's finally selected!
- Random Movie Selector: Let watermoviemelon randomly pick a movie from the curated list, adding a touch of excitement to each night.
- Rating System: Rate the film after the event to capture everyone's opinions and build a record of past movie nights.
- Account Statistics: Keep track of your movie-night stats! Check out how many movie nights you've hosted, how many you've watched and many more!
- Automated Movie Selection: The system automatically selects movies for upcoming movie nights using a built-in cron job that runs every minute.
.
├── backend # Backend service (e.g., API, database models)
│ ├── ...
│ ├── Dockerfile # Docker configuration for the backend
│ ├── movies # Application directory for managing movie-related features
│ ├── requirements.txt # Python dependencies
│ └── watermoviemelon # Project configuration and main app settings for backend
│
├── compose.yaml # Docker Compose configuration for orchestrating services
│
├── frontend # Frontend service (React application)
│ ├── ...
│ ├── Dockerfile # Docker configuration for the frontend
│ ├── public # Public assets, like icons and images
│ └── src # Source code, organized by components, pages, utilities, etc.
├── ...
└── README.md # Project documentation
Before running the app, ensure that you have the following installed:
- Docker: Required for running the application using Docker containers. Get Docker
- Docker Compose: Used to manage multi-container applications. Get Docker Compose
- Node.js: For the frontend to work locally. Get Node.js
- Python 3.x: Required for the backend. Get Python
To make sure your application can access required APIs and other configurations, set up environment variables by
creating a .env file in each relevant directory.
- Create a .env file in the root directory
cd frontend
touch .env- Add required environment variables:
# OMDb API Key for fetching movie details
VITE_OMDB_API_KEY="OMDB_KEY_HERE"- Create a .env file in the
backenddirectory:
cd backend
touch .env- Add required environment variables:
# PostgreSQL database configuration
POSTGRES_DB=your_db_name
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_HOST=db
# For register view rate limiting
RATE_LIMIT_ENABLED=True
# Business timezone for consistent day-boundary logic (optional)
# Used for movie night scheduling and conflict detection
# Default: Europe/Warsaw
BUSINESS_TIMEZONE=Europe/WarsawTo run the application using docker compose simply navigate to the water-movie-melon project directory in terminal. Then type:
docker compose upApp will start, you can connect locally to the frontend at http://localhost:4173, and to the backend at http://localhost:8000.
The application includes an automated movie selection system that runs in a separate cron container. This feature:
- Automatically selects movies for upcoming movie nights that are within 1 minute of their start time
- Runs every minute to ensure timely movie selection
- Prevents duplicate selections by checking if a movie has already been selected for a night
- Logs all activities to
/tmp/movie_selection.logwithin the cron container
The cron service is automatically started when you run docker compose up -d. You can view the selection logs by accessing the cron container:
docker compose logs -f cronThe cron service runs in its own container for better separation of concerns:
- View cron logs:
docker compose logs -f cron - Restart cron service:
docker compose restart cron - Access cron container:
docker compose exec cron bash - Run cron job manually (for testing):
docker compose exec cron python manage.py select_movie_for_nights
This architecture provides better resource management and easier debugging by isolating scheduled tasks from the web server.
- navigate to the frontend folder:
cd watermoviemelon/frontend- Install dependencies using npm or yarn:
If you're using npm
npm installOr if you prefer yarn:
yarn install- Start the development server:
If you're using npm:
npm run devOr with yarn:
yarn dev- The app should now be running locally at http://localhost:5173. You can make changes to the source code, and the development server will automatically reload the page.
- To stop the server, use Ctrl+C in your terminal.
- navigate to the backend folder:
cd watermoviemelon/backend- Create and activate a virtual environment (recommended for managing Python dependencies)::
python3 -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate- Install backend dependencies:
pip install -r requirements.txt- Run database migrations (if applicable):
python manage.py migrate- Start the backend server
python manage.py runserver-
The backend will now be running locally on http://localhost:8000. You can make changes to the backend code, and the server will automatically reload when saved.
-
To stop the server, use Ctrl+C in your terminal.
To run frontend of the app using docker first navigate to the water-movie-melon/frontend directory in terminal. Then build the image using:
docker build . -t {frontend_image_name}And next run the docker:
docker run -p 4173:4173 {frontend_image_name}To run backend of the app using docker first navigate to the water-movie-melon/backend directory in terminal. Then build the image using:
docker build . -t {backend_image_name}And next run the docker:
docker run -p 8000:8000 {backend_image_name}To start database using docker run this command in terminal:
docker run -d --name postgres -e POSTGRES_PASSWORD=mypassword -p 5432:5432 postgresThe backend uses Django's built-in testing framework along with pytest (if configured) for more flexibility. Here's how to run the backend tests:
- Navigate to the backend directory:
cd watermoviemelon/backend- Activate the virtual environment (if using a manual setup):
source venv/bin/activate # On Windows use: venv\Scripts\activate- Run all test cases by executing:
python manage.py test