|
| 1 | +# MovieVerse AI Platform |
| 2 | + |
| 3 | +MovieVerse-AI is a production-grade machine learning platform that powers recommendations, similarity search, sentiment analysis, and ranking for MovieVerse. It includes data ingestion, feature store, model training, registry, inference APIs, and monitoring. |
| 4 | + |
| 5 | +## Capabilities |
| 6 | + |
| 7 | +- Personalized recommendations (collaborative + content-aware) |
| 8 | +- Movie similarity search using vector embeddings |
| 9 | +- Review sentiment classification |
| 10 | +- Ranking model for feed/search ordering |
| 11 | +- Feature store with offline/online serving (Feast + Redis) |
| 12 | +- MLflow model registry and experiment tracking |
| 13 | +- Kafka-driven event ingestion |
| 14 | +- Drift monitoring with Evidently |
| 15 | + |
| 16 | +## Stack |
| 17 | + |
| 18 | +- Python 3.11 |
| 19 | +- FastAPI + Uvicorn for online inference |
| 20 | +- LightFM for recommender models |
| 21 | +- SentenceTransformers + FAISS for embeddings |
| 22 | +- scikit-learn for sentiment and ranking models |
| 23 | +- Feast for feature storage |
| 24 | +- MLflow for registry and experiments |
| 25 | +- Kafka for event streaming |
| 26 | +- PostgreSQL + MySQL + MongoDB data sources |
| 27 | +- Redis online store |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +Online inference flow: |
| 32 | + |
| 33 | +```mermaid |
| 34 | +flowchart LR |
| 35 | + Backend[MovieVerse Backend] -->|HTTP| API[MovieVerse AI API] |
| 36 | + API --> Reco[Recommender Service] |
| 37 | + API --> Similar[Similarity + Embeddings] |
| 38 | + API --> Ranker[Ranking Service] |
| 39 | + API --> Sentiment[Sentiment Service] |
| 40 | + API --> Summarize[Summarization Service] |
| 41 | + API --> Vision[Vision Service] |
| 42 | + Reco --> Redis[(Redis Online Store)] |
| 43 | + Similar --> FAISS[(FAISS Index)] |
| 44 | + API --> Feast[Feature Store] |
| 45 | + Feast --> Redis |
| 46 | + Feast --> Postgres[(PostgreSQL Feature Repo)] |
| 47 | + API --> MLflow[(MLflow Registry)] |
| 48 | +``` |
| 49 | + |
| 50 | +Training + feature pipeline flow: |
| 51 | + |
| 52 | +```mermaid |
| 53 | +flowchart TD |
| 54 | + Kafka[(Kafka Events)] --> Ingest[Event Ingestion] |
| 55 | + MySQL[(MySQL Movies)] --> Ingest |
| 56 | + Postgres[(PostgreSQL Ratings/Reviews)] --> Ingest |
| 57 | + Mongo[(Mongo Metadata)] --> Ingest |
| 58 | + Ingest --> Features[Build Feature Tables] |
| 59 | + Features --> Feast[Feast Feature Store] |
| 60 | + Feast --> Materialize[Materialize Online Features] |
| 61 | + Materialize --> Redis[(Redis Online Store)] |
| 62 | + Features --> Train[Train Models] |
| 63 | + Train --> MLflow[(MLflow Registry)] |
| 64 | + MLflow --> Sync[Sync Latest Models] |
| 65 | + Sync --> API[MovieVerse AI API] |
| 66 | +``` |
| 67 | + |
| 68 | +## Directory Layout |
| 69 | + |
| 70 | +``` |
| 71 | +MovieVerse-AI/ |
| 72 | +├── movieverse_ai/ # Core package (API, models, pipelines) |
| 73 | +├── feature_repo/ # Feast feature store definitions |
| 74 | +├── airflow/dags/ # Training + materialization workflows |
| 75 | +├── sql/ # Database schema for AI data |
| 76 | +├── k8s/ # Kubernetes deployment assets |
| 77 | +├── docker-compose.ai.yml # Local AI stack runtime |
| 78 | +├── docker-compose.airflow.yml # Airflow scheduler/runtime |
| 79 | +├── requirements.txt # Production dependencies |
| 80 | +└── Dockerfile # Inference service image |
| 81 | +``` |
| 82 | + |
| 83 | +## Services |
| 84 | + |
| 85 | +- `movieverse_ai.api.main`: Online inference API |
| 86 | +- `movieverse_ai.pipelines.ingest_events`: Kafka ingestion into Postgres |
| 87 | +- `movieverse_ai.pipelines.train_recommender`: Recommendation training |
| 88 | +- `movieverse_ai.pipelines.train_sentiment`: Review sentiment training |
| 89 | +- `movieverse_ai.pipelines.build_ranking_features`: Ranking feature generation |
| 90 | +- `movieverse_ai.pipelines.train_ranker`: Ranking model training |
| 91 | +- `movieverse_ai.pipelines.build_embeddings`: Embedding + FAISS index |
| 92 | +- `movieverse_ai.pipelines.build_feature_tables`: User/movie feature tables for Feast |
| 93 | +- `movieverse_ai.pipelines.materialize_features`: Feast materialization |
| 94 | +- `movieverse_ai.pipelines.sync_models`: Pull latest artifacts from MLflow |
| 95 | +- `movieverse_ai.monitoring.drift_monitor`: Drift reports |
| 96 | + |
| 97 | +## Local Run |
| 98 | + |
| 99 | +1) Start the AI stack (Postgres, Redis, Kafka, MLflow, MinIO): |
| 100 | + |
| 101 | +```bash |
| 102 | +docker compose -f MovieVerse-AI/docker-compose.ai.yml up -d |
| 103 | +``` |
| 104 | + |
| 105 | +The AI API is exposed at `http://localhost:9100` when running via Docker Compose. |
| 106 | + |
| 107 | +2) Initialize the AI database schema: |
| 108 | + |
| 109 | +```bash |
| 110 | +psql postgresql://movieverse:movieverse@localhost:5433/movieverse_ai \ |
| 111 | + -f MovieVerse-AI/sql/postgres_init.sql |
| 112 | +``` |
| 113 | + |
| 114 | +3) (Optional) Start Airflow for scheduled pipelines: |
| 115 | + |
| 116 | +```bash |
| 117 | +psql postgresql://movieverse:movieverse@localhost:5433/postgres -c "CREATE DATABASE airflow" |
| 118 | +docker compose -f MovieVerse-AI/docker-compose.airflow.yml up -d |
| 119 | +``` |
| 120 | + |
| 121 | +Airflow connects to the AI stack over the `movieverse-ai` Docker network, so start the AI stack first. |
| 122 | + |
| 123 | +4) Train models and build embeddings: |
| 124 | + |
| 125 | +```bash |
| 126 | +cd MovieVerse-AI |
| 127 | +python -m movieverse_ai.pipelines.train_recommender |
| 128 | +python -m movieverse_ai.pipelines.train_sentiment |
| 129 | +python -m movieverse_ai.pipelines.build_ranking_features |
| 130 | +python -m movieverse_ai.pipelines.train_ranker |
| 131 | +python -m movieverse_ai.pipelines.build_embeddings |
| 132 | +python -m movieverse_ai.pipelines.build_feature_tables |
| 133 | +``` |
| 134 | + |
| 135 | +5) Start the inference API: |
| 136 | + |
| 137 | +```bash |
| 138 | +cd MovieVerse-AI |
| 139 | +uvicorn movieverse_ai.api.main:app --host 0.0.0.0 --port 9000 |
| 140 | +``` |
| 141 | + |
| 142 | +## Environment Variables |
| 143 | + |
| 144 | +All configuration is driven by `MOVIEVERSE_AI_` prefixed environment variables. Defaults are set for the local AI stack. |
| 145 | + |
| 146 | +Key variables: |
| 147 | + |
| 148 | +- `MOVIEVERSE_AI_POSTGRES_DSN` |
| 149 | +- `MOVIEVERSE_AI_MYSQL_DSN` |
| 150 | +- `MOVIEVERSE_AI_MONGO_URI` |
| 151 | +- `MOVIEVERSE_AI_REDIS_URL` |
| 152 | +- `MOVIEVERSE_AI_KAFKA_BOOTSTRAP_SERVERS` |
| 153 | +- `MOVIEVERSE_AI_MLFLOW_TRACKING_URI` |
| 154 | +- `MOVIEVERSE_AI_S3_ENDPOINT_URL` |
| 155 | + |
| 156 | +## Production Deployment |
| 157 | + |
| 158 | +- Kubernetes manifests live in `MovieVerse-AI/k8s/` and deploy the inference API. |
| 159 | +- Use managed AWS services (RDS, MSK, OpenSearch, ElastiCache) and point the AI stack to them via environment variables. |
| 160 | +- MLflow artifacts are stored in S3/MinIO; align this with the same bucket used in your infra stack. |
| 161 | + |
| 162 | +## Data Requirements |
| 163 | + |
| 164 | +The AI pipelines expect these tables: |
| 165 | + |
| 166 | +- `ratings` (user_id, movie_id, rating, created_at) |
| 167 | +- `reviews` (user_id, movie_id, rating, review_text, created_at) |
| 168 | +- `ranking_features` (movie_id, popularity, avg_rating, rating_count, recency_days, label) |
| 169 | +- `user_features` and `movie_features` for Feast |
| 170 | + |
| 171 | +Movie metadata is sourced from MySQL `movies` (movie_id, title, overview, genres, release_date). |
| 172 | + |
| 173 | +## API Endpoints |
| 174 | + |
| 175 | +- `GET /healthz` |
| 176 | +- `GET /metrics` |
| 177 | +- `POST /recommendations` |
| 178 | +- `POST /similar` |
| 179 | +- `POST /sentiment` |
| 180 | +- `POST /rank` |
| 181 | +- `POST /summarize` |
| 182 | +- `POST /genres/classify` |
| 183 | +- `POST /vision/labels` |
0 commit comments