Genkit version: 1.7.0 for Node.js
Gemini Models: Gemini 2.0 Flash amd Flash Lite
Embedding Models: textEmbedding005
This version is a minimal version of the frontend and backend that doesn't have complex login logic like the version in the cloud-movieguru branch. It is meant to be run fully locally while using Vertex AI APIs. If you want to run this demo entirely in the cloud, please use the cloud-movieguru branch.
Movie Guru is a website that helps users find movies to watch through an RAG powered chatbot. The movies are all fictional and are generated using GenAI. The goal of this repo is to explore the best practices when building AI powered applications.
The repo is intended for educational/hobbyists use only.
- Frontend (Vue.js): User interface for interacting with the chatbot.
- Web Backend (Go): Handles API requests and communicates with the Flows Backend.
- Flows Backend (Genkit for Node): Orchestrates AI tasks, connects to GenAI models, and interacts with a vector database.
- Database: Stores movie data, embeddings, and user profiles in a local Postgres databse with
pgvector. - Cache (Redis): Caches conversation history and session data.
- Frontend: Vue.js application.
- Web Backend: Go-based API server.
- Flows Backend: Node.js-based AI task orchestrator.
- Cache: Redis for caching chat history and sessions.
- Database: Postgres with
pgvector.
- Safety Flow: Checks each user statement to validate whether or not it is safe to proceed with.
- Query Transform Flow: Maps vague user queries to specific database queries.
- Movie QA Flow: Combines user data and relevant documents to provide responses.
- Movie Doc Flow: Retrieves relevant documents from the vector database. Performs a keyword-based, vector-based, or mixed search based on the type of query.
- Chat Flow: Combines all the aforementioned prompts and flows into a single flow that is used by the chat server.
- User Preferences Flow: Additional flow that extracts user preferences from conversations.
- Indexer Flow: Parses movie data and adds it to the vector database.
- Movie data is stored in a PostgreSQL database with the
pgvectorextension. This includes details for approximately 600 fictional movies (plot, actors, director, rating, genre, poster link). Posters are stored in a Cloud Storage bucket. - User profile data (likes and dislikes) is stored in the PostgreSQL database.
- User conversation history (most recent 10 messages, configurable) and webserver session info are stored in a local Redis cache.
There are 2 important tables:
- movies: This contains the information about the AI Generated movies and their embeddings. The data for the table is found in dataset/movies_with_posters.csv. If you choose to host your own posters, replace the links in this file.
- user_preferences: This contains the user's long term preferences profile information.
- movies: Contains information about the AI-generated movies and their embeddings. Initial data is sourced from
dataset/movies_with_posters.csv. If hosting your own posters, update the links in this file. - user_preferences: Stores users' long-term preference profiles.
- A Google Cloud project with owner permissions.
- Tools:
- Google Cloud CLI
- Docker and Docker Compose
- Required APIs enabled (will be performed in
setup_local.sh).
-
Clone the Repository
git clone https://github.com/MKand/movie-guru.git cd movie-guru git checkout main -
Authenticate with Google Cloud
gcloud auth login gcloud config set project <YOUR_PROJECT_ID>
-
Run the interactive environment setup script where you will be prompted to enter values like PROJECT_ID and REGION (which region do you want to consume the models from)
chmod +x ./setup/configure_env_simple.sh && ./setup/configure_env_simple.sh -
Make sure the required APIs are enabled and create a service account. You will need owner level access to the project. This enables the required APIs and creates the necessary service account with roles.
chmod +x ./setup/setup_cloud_simple.sh && ./setup/setup_cloud_simple.sh -
Start the app.
chmod +x ./setup/launch_app.sh && ./setup/launch_app.sh -
Access the Frontend Application Open http://localhost:8080 in your browser.
-
To stop the app, press Ctrl+C in the terminal. Then run
./setup/launch_app.sh --stop
This uses firebase authentication for the frontend of the application.
-
Clone the Repository
git clone https://github.com/MKand/movie-guru.git cd movie-guru git checkout main -
Authenticate with Google Cloud
gcloud auth login gcloud config set project <YOUR_PROJECT_ID>
-
Setup a firebase web app.
- Go to the firebase console. Follow the steps here.
- Create a new firebase web app and note down the values of the APP ID, API KEY and AUTH DOMAIN. You'll need them in the next step.
-
Run the interactive environment setup script where you will be prompted to enter values like PROJECT_ID and REGION (which region do you want to consume the models from) and the firebase web app's config values that you noted in the previous step.
chmod +x ./setup/configure_env.sh && ./setup/configure_env.sh -
Make sure the required APIs are enabled and create a service account. You will need owner level access to the project. This enables the required APIs and creates the necessary service account with roles.
chmod +x ./setup/setup_cloud_simple.sh && ./setup/setup_cloud_simple.sh -
Start the app.
chmod +x ./setup/launch_app.sh && ./setup/launch_app.sh -
Access the Frontend Application Open http://localhost:8080 in your browser. Use 0000 as the invite code.
-
To stop the app, press Ctrl+C in the terminal. Then run
./setup/launch_app.sh --stop
WIP
To update the data in the database, you can run the indexer.
-
Start the local application by following the steps outlined here: Run the application step. (The indexer requires the database to be running which this step does for you).
-
Run the javascript indexer so it can add movies data into the database. The database comes pre-populated with the required data, but you can choose to re-add the data. The execution of this intentionally slowed down to stay below the rate-limits.
docker compose -f docker-compose.indexer.yaml up --build -d
This takes about 10-15 minutes to run, so be patient. The embedding creation process is slowed down intentionally to ensure we stay under the rate limit.
-
Shut down the indexer container.
docker compose -f docker-compose-indexer.yaml down
-
Verify the number of entries in the DB by using Adminer that is running at http://localhost:8082. Use the minimal user credentials (user name: minimal-user, password: minimal). Make sure you set System as PostgresSQL and Server as db, and Database as fake-movies-db.
There should be 652 entries in the movies table.
SELECT COUNT(*)
FROM "movies";This ensures that all the movies are updated in the db.
