This project is a web application featuring an interactive 3D Rubik's Cube showcasing videos from the VU JA DE archive. It combines a Flask backend API with a React frontend. Users can explore videos via the cube or a menu, view details in a modal, and visit an "About" section.
Live at: https://www.vujade.world/
- Interactive 3D Cube: Displays a manipulable Rubik's Cube textured with video scene thumbnails.
- Video Discovery: Browse videos by interacting with the cube or using the expandable menu.
- Video Modal: Displays detailed video information (title, description, published date) and an embedded YouTube player upon selection.
- "About" Section: Accessible via a dedicated button, featuring custom animations and a Substack embed.
- Smooth Animations: Utilizes Framer Motion for UI transitions and effects.
- Routing: Uses React Router for handling navigation and direct links to videos or the about page.
- REST API: Flask backend provides endpoints to fetch video and scene data from a PostgreSQL database.
- Static File Serving: Flask serves the optimized React build for production.
- CORS Enabled: Configured for development and production environments.
- Google Analytics: Integrated for page view tracking.
- Backend:
- Python 3.x
- Flask
- Flask-SQLAlchemy
- Flask-CORS
- PostgreSQL
- Gunicorn (Recommended for production deployment)
- Frontend:
- React
- JavaScript (ES6+)
- HTML5 / CSS3
- Axios (for API requests)
- React Router DOM
- Framer Motion (for animations)
cube-master(Custom 3D cube library)react-icons
- Database:
- PostgreSQL
Prerequisites:
- Node.js and npm (or yarn)
- Python 3.x and pip
- PostgreSQL Server running
Steps:
-
Clone the repository:
git clone <your-repository-url> cd <repository-directory>
-
Backend Setup:
- Create and activate a Python virtual environment:
python -m venv venv # On Windows: # venv\Scripts\activate # On macOS/Linux: # source venv/bin/activate
- Install Python dependencies:
(Note: If
pip install -r requirements.txt
requirements.txtdoesn't exist, create it by runningpip freeze > requirements.txtafter installing Flask, Flask-SQLAlchemy, Flask-Cors, psycopg2-binary, gunicorn etc.) - Set up your PostgreSQL database and obtain the connection URI.
- Set the
DATABASE_URLenvironment variable. You can use a.envfile (withpython-dotenvpackage) or set it directly:(Remember to replace# On macOS/Linux: export DATABASE_URL='postgresql://user:password@host:port/database' # On Windows CMD: set DATABASE_URL='postgresql://user:password@host:port/database' # On Windows PowerShell: $env:DATABASE_URL='postgresql://user:password@host:port/database'
postgres://withpostgresql://if needed, as handled inapi.py)
- Create and activate a Python virtual environment:
-
Frontend Setup:
- Navigate to the frontend source directory (e.g.,
frontend/):cd frontend - Install Node.js dependencies:
npm install # or yarn install
- Navigate to the frontend source directory (e.g.,
1. Development:
-
Run the Backend (Flask API):
- Make sure your virtual environment is active and
DATABASE_URLis set. - Navigate to the directory containing
api.py. - Set Flask to debug mode (optional, for auto-reloading):
# On macOS/Linux: export FLASK_DEBUG=true # On Windows CMD: set FLASK_DEBUG=true # On Windows PowerShell: $env:FLASK_DEBUG='true'
- Run the Flask development server:
(The API will likely run on
python api.py
http://127.0.0.1:5000)
- Make sure your virtual environment is active and
-
Run the Frontend (React Dev Server):
-
Navigate to the frontend source directory (e.g.,
frontend/). -
Start the React development server:
npm start # or yarn start(The frontend will likely run on
http://localhost:3000and proxy API requests to Flask) -
Access the application at
http://localhost:3000.
-
2. Production:
-
Build the Frontend:
- Navigate to the frontend source directory (e.g.,
frontend/). - Create the optimized production build:
(This will generate the
npm run build # or yarn buildbuild/directory)
- Navigate to the frontend source directory (e.g.,
-
Run the Backend (Serving Frontend Build):
- Make sure your virtual environment is active and
DATABASE_URLis set appropriately for production. - Navigate to the directory containing
api.py. - Run the Flask app using a production-ready WSGI server like Gunicorn:
(Consult Gunicorn documentation for configuration options like workers, host, and port. Ensure the
gunicorn api:app
builddirectory is correctly located relative toapi.py) - Alternatively, for simpler setups (like Heroku often handles):
(Ensure
python api.py
FLASK_DEBUGis not set totruein production)
- Make sure your virtual environment is active and
GET /api/videos: Returns a list of all videos with basic details and associated scenes. Ordered by published date descending.GET /api/scenes: Returns a list of all scenes with their associatedvideoID.GET /api/scenes/<videoID>: Returns a list of scenes belonging to the specifiedvideoID.GET /api/video_info/<videoID>: Returns detailed information for a specific video, including its scenes.GET /,GET /<path:path>: Serves the React application (index.html or specific static assets from thebuildfolder).
This application is configured for deployment on platforms like Railway and Heroku:
- It reads the database configuration from the
DATABASE_URLenvironment variable. - It uses relative paths for the React build directory.
- A
Procfile(not provided, but typical) would likely define the command to start the web server (e.g.,web: gunicorn api:app). - A
runtime.txt(not provided, but typical) might specify the Python version.