A production-inspired movie recommendation platform built with Node.js, TensorFlow.js, PostgreSQL, and pgvector.
This project demonstrates how Machine Learning can be integrated into a modern backend architecture to deliver personalized movie recommendations for both:
- New users using profile-based prediction
- Existing users using learned embedding similarity search
The system combines:
- Neural network training with TensorFlow.js
- Feature engineering pipelines
- Vector embeddings
- Vector similarity search with pgvector
- REST APIs with Express.js
- Interactive frontend visualization
This application implements a hybrid recommendation architecture composed of two complementary recommendation strategies:
For users without historical interactions, the system predicts movie ratings using:
- User demographic information
- Movie metadata
- Engineered numerical features
- A trained TensorFlow.js neural network
The model estimates which movies the user is likely to enjoy even before they rate any content.
For users with historical ratings, the system:
- Learns dense vector embeddings for users and movies
- Stores embeddings in PostgreSQL using pgvector
- Uses vector similarity search to find the most relevant movies
- Excludes already watched/rated movies
This creates a scalable recommendation pipeline similar to real-world ML recommendation systems.
The training pipeline uses TensorFlow.js with a dense neural network architecture:
- Dense Layers
- Batch Normalization
- Dropout Regularization
- Adam Optimizer
- Early Stopping
| Component | Description |
|---|---|
| Framework | TensorFlow.js (Node.js) |
| Task | Regression |
| Loss Function | Mean Squared Error |
| Optimizer | Adam |
| Validation | Validation Split + Early Stopping |
| Output | Predicted Movie Rating |
The project also trains embedding vectors for:
- Users
- Movies
Those embeddings are persisted in PostgreSQL using the pgvector extension.
- Fast similarity search
- Scalable recommendation retrieval
- Collaborative filtering behavior
- Real-world vector database integration
- Node.js
- Express.js
- TensorFlow.js
- PostgreSQL
- pgvector
- JavaScript (ES Modules)
- HTML
- CSS
- Vanilla JavaScript
- TensorFlow.js
- Feature Engineering
- Embedding Learning
- Neural Networks
- Vector Similarity Search
- Docker Compose
- PostgreSQL Container
- Personalized movie recommendations
- Cold-start recommendation pipeline
- Existing-user collaborative filtering
- Vector similarity recommendations
- Exclusion of already-rated movies
- TensorFlow.js neural network training
- User/movie embeddings
- Feature normalization
- Feature engineering pipeline
- Batch normalization
- Dropout regularization
- Early stopping
- Embedding persistence
- RESTful API architecture
- Modular service layer
- Recommendation caching structure
- Database initialization scripts
- Dataset loading utilities
- Vector database integration
- Interactive recommendation UI
- Existing/new user modes
- Real-time recommendation visualization
- One-click environment setup
movies-recommender/
โ
โโโ backend/
โ โโโ src/
โ โ โโโ db/
โ โ โ โโโ initDb.js
โ โ โ โโโ postgres.js
โ โ โ
โ โ โโโ routes/
โ โ โ โโโ recommendations.js
โ โ โ โโโ trainModel.js
โ โ โ โโโ seedDb.js
โ โ โ โโโ users.js
โ โ โ
โ โ โโโ services/
โ โ โ โโโ trainingService.js
โ โ โ โโโ recommendationService.js
โ โ โ โโโ existingUserRecommendationService.js
โ โ โ โโโ vectorDBService.js
โ โ โ โโโ modelPersistenceService.js
โ โ โ
โ โ โโโ utils/
โ โ โ โโโ datasetLoader.js
โ โ โ โโโ datasetJoiner.js
โ โ โ โโโ featureEngineering.js
โ โ โ
โ โ โโโ server.js
โ โ
โ โโโ package.json
โ โโโ .env
โ
โโโ frontend/
โ โโโ index.html
โ โโโ app.js
โ โโโ style.css
โ
โโโ db/
โ โโโ db-init.sql
โ
โโโ docker-compose.yml
โโโ README.md
Before running the project, make sure you have:
- Node.js 18+
- Docker Desktop
- npm
Run the database container:
docker compose up -dThis starts PostgreSQL with the pgvector extension enabled.
Default database configuration:
| Variable | Value |
|---|---|
| Database | movies |
| User | postgres |
| Password | postgres |
| Port | 5432 |
Navigate to the backend folder:
cd backendInstall dependencies:
npm installThe project already includes a default .env file:
PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=moviesUpdate values if your local environment differs.
Run the development server:
npm run devBackend API:
http://localhost:3000
Open the frontend directly in your browser:
frontend/index.html
Or use a lightweight local server extension such as:
- VSCode Live Server
- Python HTTP Server
- Any static file server
Populate the database with movies, users, and ratings:
POST /seed-dbExample using curl:
curl -X POST http://localhost:3000/seed-dbTrain both:
- Neural network recommendation model
- Embedding generation pipeline
POST /train-modelExample:
curl -X POST http://localhost:3000/train-modelThis step:
- Trains the TensorFlow.js model
- Generates user embeddings
- Generates movie embeddings
- Persists vectors to PostgreSQL
POST /train-modelTriggers:
- Neural network training
- Embedding generation
- Vector persistence
POST /seed-dbSeeds:
- Users
- Movies
- Ratings
POST /recommendations{
"age": 25,
"gender": "M",
"occupation": "engineer"
}GET /recommendations/:userIdExample:
GET /recommendations/10GET /usersThe system performs feature engineering to transform raw data into numerical tensors used by the neural network.
Examples include:
- Rating normalization
- User demographic encoding
- Movie statistics aggregation
- Numerical scaling
- Feature vector construction
Dataset Loading
โ
Feature Engineering
โ
Tensor Conversion
โ
Model Training
โ
Validation
โ
Embedding Generation
โ
Vector Persistence (pgvector)
โ
Recommendation Serving
The backend is organized into:
- Routes
- Services
- Utilities
- Database Layer
This separation improves:
- Scalability
- Maintainability
- Testability
- Extensibility
The project uses pgvector to:
- Persist embeddings
- Execute cosine similarity search
- Retrieve semantically similar movies
This demonstrates modern AI infrastructure patterns increasingly used in:
- Recommendation systems
- Retrieval systems
- Generative AI applications
- Semantic search platforms
This project demonstrates practical experience with:
- Backend API architecture
- Modular service design
- Database integration
- Docker-based local infrastructure
- RESTful APIs
- TensorFlow.js training pipelines
- Feature engineering
- Neural network design
- Embedding systems
- Recommendation systems
- Vector databases
- pgvector integration
- Similarity search
- Embedding persistence
- ML inference pipelines
Potential next steps for the platform:
- Model persistence to disk
- Automated retraining pipeline
- GPU acceleration
- Top-K ANN indexing
- Hybrid recommendation scoring
- User authentication
- Streaming recommendations
- Kubernetes deployment
- CI/CD integration
- Monitoring & observability
For portfolio presentation, consider including:
- Recommendation UI screenshots
- Training logs
- Embedding similarity examples
- Database vector examples
- API response samples
- Architecture diagrams
Built as a Machine Learning + Backend Engineering portfolio project focused on recommendation systems, neural networks, and vector databases.
This project is available for educational and portfolio purposes.