Personalized AI Feed Flow (Planned)¶
This document outlines the plan to implement a personalized homepage feed based on user interests.
1. Current Implementation Analysis¶
Frontend¶
- The homepage is rendered by the
HomeFeedPagecomponent (src/app/home/page.tsx). - It uses
HomeFeedMainto display the content. - The
getCombinedNewsAndPodcastsfunction insrc/services/modules/home-feed/queries.tsis responsible for fetching data. - It currently fetches news, podcasts, and AI companies in parallel and combines them on the client-side.
- Data fetching is not personalized and is based on generic filters like category and sorting.
- User data is managed in the
UserStore.
Backend (Inferred)¶
- Separate API endpoints exist for news, podcasts, and companies.
- The backend supports pagination, searching, and filtering on these endpoints.
- There is no concept of user interests or personalized content retrieval.
2. User Interest Definition¶
User interests are composed of both static and dynamic data points.
Static Interests¶
These are explicitly provided by the user, likely during onboarding or in their profile settings, based on the provided Figma design. They are categorized as follows:
- Your Role:
- Product Manager
- Data Scientist
- Marketing Lead
- AI Researcher
- Founder / CEO
- Investor / VC
- Operations / Strategy
- Student / Academic
- Industry You Work In:
- Healthcare
- Finance
- Retail & eCommerce
- Manufacturing
- Media & Entertainment
- Logistics & Supply Chain
- Cybersecurity
- EdTech
- LegalTech
- Government
- AI Technologies You’re Interested In:
- Generative AI
- NLP / Chatbots
- Computer Vision
- Predictive Analytics
- Machine Learning Ops
- Robotics & Automation
- Speech Recognition
- Recommendation Systems
- Sentiment Analysis
- What Are You Looking To Do?:
- Discover AI vendors
- Compare AI solutions
- Connect with AI professionals
- Get product inspiration
- Understand market trends
- Stay updated with AI news
- Find investment opportunities
Dynamic Interests¶
These are implicitly gathered by tracking user actions on the platform.
CompanyFollow: When a user follows a company.NewsFeedView: When a user views a news feed item.FavoriteNewsFeed: When a user favorites a news feed item.PodcastView: When a user views a podcast.PodcastLike: When a user likes a podcast.
3. Proposed Implementation Steps¶
Phase 1: Backend Development¶
-
User Interest Model:
- Create a new
Interestmodel withnameandcategoryfields. Thecategoryfield will store the type of interest (e.g., “Your Role”, “Industry You Work In”). This will store the static interests. - Add a
ManyToManyFieldfrom theUsermodel to theInterestmodel to store user preferences. - The dynamic interests (
CompanyFollow, etc.) will be stored in their respective tables and used to influence the feed algorithm.
- Create a new
-
Content Tagging:
- Add a
ManyToManyFieldfrom theNewsFeed,Podcast, andCompanymodels to theInterestmodel. This will allow us to tag content with relevant static interests.
- Add a
-
Interest API Endpoint:
- Create a new API endpoint
/api/v1/interests/. GET /api/v1/interests/: Returns a list of all available static interests.GET /api/v1/user/interests/: Returns the static interests for the currently logged-in user.POST /api/v1/user/interests/: Allows the user to set or update their static interests. It will expect a list of interest IDs.
- Create a new API endpoint
-
Personalized Feed Endpoint (Vectorization Approach):
- Create a new API endpoint
/api/v1/home-feed/. - This endpoint will be responsible for generating the personalized feed using vectorization.
- Logic:
- Collect User Interests:
- Gather the user’s static interests from their profile.
- Gather the user’s dynamic interests by analyzing their recent activity (e.g.,
CompanyFollow,NewsFeedView,FavoriteNewsFeed,PodcastView,PodcastLike).
- Generate Weighted Keywords:
- Create a combined list of keywords from both static and dynamic interests.
- Assign weights to the keywords based on their source (e.g., higher weight for explicit static interests and favorited items).
- Create User Interest Vector:
- Use OpenAI’s GPT embedding models to generate an embedding vector for the user’s weighted keywords.
- Create Content Vectors:
- For each piece of content (news, podcast, company), create an embedding vector from its title, description, and tags.
- These vectors can be pre-computed and stored in the database for efficiency.
- Calculate Cosine Similarity:
- For each content item, calculate the cosine similarity between its vector and the user’s interest vector. This will produce a relevance score.
- Rank and Sort:
- Sort the content items by their relevance score in descending order.
- Pagination:
- Implement pagination on the sorted list of content.
- Collect User Interests:
- Create a new API endpoint
Phase 2: Frontend Development¶
-
Interest Selection UI:
- Create a new component (e.g., a modal or a dedicated page) for users to select their static interests.
- This component will be shown to new users during onboarding and will be accessible from the user’s profile settings.
- It will fetch the list of interests from
GET /api/v1/interests/. - Upon saving, it will send the selected interest IDs to
POST /api/v1/user/interests/.
-
Update Homepage:
- Modify the
HomeFeedMaincomponent to fetch data from the new/api/v1/home-feed/endpoint. - Remove the client-side logic for combining and sorting different content types, as this will now be handled by the backend.
- The component will simply render the list of items returned by the API.
- Modify the
-
UI/UX:
- The homepage will now display the personalized “For You” feed.
- The existing filters for “News”, “Podcasts”, and “Companies” can be kept to allow users to browse specific content types.