Skip to content

Ganasekhar-gif/RecoStream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฌ RecoStream: Emotion + Behavior Aware Recommendation System

RecoStream is a fullโ€‘stack, Netflixโ€‘style recommendation system that provides personalized movie suggestions based on a userโ€™s preferences, behaviors, and the semantic meaning of their inputs.

It combines Sentenceโ€‘BERT semantic search with Collaborative Filtering (Surprise) and a feedback loop (like/dislike/click). The project exposes a FastAPI backend and a modern React frontend.

Linkedin Post Link: https://www.linkedin.com/posts/ganasekhark_machinelearning-recommendationsystems-ai-activity-7374888182980653056-ozCa?utm_source=share&utm_medium=member_desktop&rcm=ACoAAD89BZIBRKWU64_jsUAxvhPir2TtHKAUOXY


๐Ÿ“Œ Features

Module Description
๐Ÿ‘ค User Auth Secure login/signup using hashed passwords and JWT tokens
๐Ÿ“ฝ Movie Recommender Semantic similarity via Sentence-BERT + genre filtering
๐Ÿ“Š Collaborative Filtering Learns from user likes/dislikes/clicks using Surprise KNN
๐Ÿง  Emotion Awareness Recommends based on user tone: e.g., "I want a feel-good sci-fi movie"
๐Ÿ” Feedback Loop Logs "like", "dislike", and "click" feedback for model improvement
๐Ÿš€ Scalable Backend FastAPI backend with modular architecture
๐Ÿ’ฌ Explainability "Because you liked Interstellar and it had a sci-fi genre..."

โš™๏ธ Tech Stack

Layer Tools
Frontend React (Vite, Tailwind, Framer Motion, Axios)
Backend FastAPI, SQLAlchemy, JWT, Pydantic
Recommender Sentence-BERT, Surprise (Collaborative Filtering), Vowpal Wabbit (RL)
Storage Local files (JSON/NumPy/FAISS index)

๐Ÿ“ Project Structure

RecoStream/
โ”œโ”€โ”€ backend/
โ”‚   โ””โ”€โ”€ app/
โ”‚       โ”œโ”€โ”€ main.py                 # FastAPI entrypoint
โ”‚       โ”œโ”€โ”€ database.py             # DB connection
โ”‚       โ”œโ”€โ”€ models.py               # ORM models (User, Feedback)
โ”‚       โ”œโ”€โ”€ schemas.py              # Pydantic schemas
โ”‚       โ”œโ”€โ”€ recommender.py          # BERT/FAISS, incremental index update
โ”‚       โ”œโ”€โ”€ hybrid.py               # (Optional) hybrid logic
โ”‚       โ””โ”€โ”€ routers/
โ”‚           โ”œโ”€โ”€ user.py             # Signup API
โ”‚           โ”œโ”€โ”€ auth.py             # Login/auth API
โ”‚           โ”œโ”€โ”€ recommendation.py   # Recommendation API (single endpoint)
โ”‚           โ””โ”€โ”€ feedback.py         # Like/Dislike/Click endpoints
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ index.html
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ main.jsx
โ”‚       โ”œโ”€โ”€ utils/api.js            # Axios, endpoints, poster helpers
โ”‚       โ”œโ”€โ”€ contexts/               # Auth, Toast, Profile contexts
โ”‚       โ”œโ”€โ”€ components/             # MovieCard, MovieModal, MovieGrid, Layout
โ”‚       โ””โ”€โ”€ pages/                  # Home, Search, Genre, Profile, Login, Signup
โ”œโ”€โ”€ requirements.txt                # Python dependencies (install with conda)
โ”œโ”€โ”€ .env                            # Backend environment variables
โ”œโ”€โ”€ DockerFile
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ build-and-deploy.sh
โ”œโ”€โ”€ init.sql
โ”œโ”€โ”€ .env.docker                        
โ””โ”€โ”€ README.md

๐Ÿงฑ System Architecture

recommendation_architecture


๐Ÿš€ Local Development Setup

The commands below assume you are in the project root: RecoStream/.

1) Prerequisites

  • Anaconda/Miniconda installed (for the recostream environment)
  • Node.js 18+

2) Create and activate the conda environment

conda create -n recostream python=3.10 -y
conda activate recostream

3) Install backend dependencies (via conda)

Use conda to install dependencies from requirements.txt.

conda activate recostream
conda install --file requirements.txt -c conda-forge -y
# If any packages are missing on conda, you can fallback to pip:
# pip install -r requirements.txt

4) Configure backend environment variables

SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# Add any other keys required by your app

Create this .env file at backend/app/.env or load using your preferred config strategy.

5) Run the backend (from project root)

conda activate recostream
uvicorn backend.app.main:app --reload

The API will be available at: http://127.0.0.1:8000

Interactive docs: http://127.0.0.1:8000/docs

6) Run the frontend (in a second terminal)

conda activate recostream
cd frontend
npm install
npm run dev

By default Vite will start on: http://localhost:5173


Docker Deployment

For quick setup using Docker and Docker Compose:

# Build and start all services
docker-compose up --build

# Access the app
# - Frontend: http://localhost:5173
# - API docs: http://localhost:8000/docs

To Stop Services:

docker-compose down

use the optional deployment script for advanced management:

./build-and-deploy.sh build
./build-and-deploy.sh prod

โœ… Current Capabilities

  • โœ… User Signup/Login (JWT)
  • โœ… BERT-based recommendations
  • โœ… Feedback logging (like/dislike/click)
  • โœ… Collaborative Filtering with Surprise
  • โœ… Feedback-based learning
  • โœ… Modular FastAPI backend

๐Ÿงช Example API Usage

POST /recommend/

{
  "user_input": "I like sci-fi space movies"
}

Response

[
  {"title": "Interstellar", "score": 0.401},
  {"title": "Spaceman", "score": 0.323},
  {"title": "Shutter Island", "score": 0.182}
]

๐Ÿง  Future Work (Planned)

Feature Status
๐Ÿค– Reinforcement Learning (VW) ๐Ÿšง In Progress
๐Ÿ“ˆ Dynamic CF Retraining โœ… Done
๐Ÿงพ Movie-to-ID Mapping โœ… Done
๐ŸŽฏ Learnable Ranking (BERT + CF) โœ… Hybrid done
๐Ÿง User Clustering ๐Ÿ”œ Planned
๐Ÿ“ฑ Frontend UI (React) โœ… Implemented
๐Ÿ›ก๏ธ OAuth + Refresh Tokens ๐Ÿ”œ Planned

๐ŸŽฏ Roadmap

  • โœ… Integrate Vowpal Wabbit into /bandit_recommend route
  • โœ… Track real-time feedback for Bandit reward learning
  • โณ Retrain VW model incrementally on new interactions
  • ๐Ÿ”ฎ Add visual analytics (feedback trends, popular genres)
  • ๐Ÿ“ฒ Build mobile-ready frontend with personalized dashboards

๐Ÿค Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss your ideas.


๐Ÿ“„ License

This project is open-source under the MIT License.


โœจ Inspiration


๐Ÿ”ง Troubleshooting

  • CORS errors during local dev

    • Ensure the FastAPI CORS middleware allows http://localhost:5173.
  • Missing posters

    • The frontend uses poster_path returned by the backend. If a movie has no poster, a placeholder is shown.
  • Profile shows movie ID instead of title

    • Ensure the backend feedback stats endpoint returns movie_title and movie_year for each feedback entry (join with your movie dataset or store these values at feedback time).
  • FAISS index updates

    • Add new movies to the source JSON used by recommender.py and call the update function (e.g., expose an admin route that calls update_faiss_index() to append to the index without full rebuild).

Inspired by Netflix, Spotify, and real-world hybrid recommender systems with:

  • NLP + emotion modeling
  • Collaborative filtering
  • Online learning (bandits)

๐Ÿ’ฌ Built with passion for learning how recommendation systems like Netflix actually work โ€”
blending machine learning, software engineering, and personalization.


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors