A full-stack web application implementing a hybrid article recommendation engine using Content-Based Filtering and Collaborative Filtering, built with Next.js, TypeScript, Prisma, Supabase, and TailwindCSS.
- Node.js v18+
- Supabase account with PostgreSQL
- Git
- Bun (or npm/yarn/pnpm)
- Recommended: Visual Studio Code (for
REACT_EDITORintegration)
- Clone the repository
git clone https://github.com/RedDotz20/news-content-recommender-system.git
cd news-content-recommender-system- Install dependencies
bun install
# or npm install / yarn install / pnpm install- Create and configure environment variables Copy .env.example and fill in .env.local:
cp .env.example .env.localFill out all necessary fields:
# Supabase Database URL
DATABASE_URL=
# Supabase Env
NEXT_PUBLIC_SITE_URL=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
# Oauth Google Provider
AUTH_GOOGLE_ID=
AUTH_GOOGLE_SECRET=
# Facebook OAuth Provider
AUTH_FACEBOOK_ID=
AUTH_FACEBOOK_SECRET=
# API Route Secret Key
API_SECRET_KEY=
# React editor integration (local only)
REACT_EDITOR=code
- Generate Prisma client
npx prisma generate- Run migrations:
npx prisma migrate dev --name init- (Optional) seed database if applicable:
npx prisma db seedbun run dev
# or npm run dev / yarn dev / pnpm devsrc/
βββ app/ # App Router (Next.js 14+)
β βββ (auth)/ # Authentication pages
β βββ api/ # API routes (Next.js handlers)
β βββ home/ # Homepage
β βββ legal/ # Terms, privacy pages
β βββ globals.css
β βββ layout.tsx
β βββ loading.tsx
β βββ not-found.tsx
β βββ page.tsx
β
βββ components/ # Shared UI components (buttons, cards, etc.)
βββ features/ # Feature-specific logic
βββ hooks/ # Custom React hooks
β
βββ lib/
β βββ algorithms/ # Core recommendation logic
β β βββ collaborativeFiltering/ # CF logic
β β βββ contentBasedFiltering/ # CBF logic
β β βββ hybridRecommendation/ # Combines CF + CBF
β β βββ helper/ # Utility functions (similarity, normalization)
β βββ db.ts # Prisma DB connection
β βββ index.ts
β βββ safe-action.ts # Safe action pattern for server actions
β βββ utils.ts
β
βββ types/ # Global TS types/interfaces
βββ middleware.ts # Auth + protected routes| File | Description |
|---|---|
.env.local |
Development-only configuration |
.env.production |
Production deployment configuration |
.env.example |
Template showing required keys |
All algorithmic logic is encapsulated in lib/algorithms/:
-
Content-Based Filtering: Recommends based on article keywords, category, and matching user preferences.
-
Collaborative Filtering: Suggests based on interaction patterns of similar users (likes, clicks, bookmarks).
-
Hybrid Recommendation: Smartly merges both approaches with weight-based control.
-
Helpers: Utility functions for computing cosine similarity, vector scores, and merging results.
- Use
REACT_EDITOR=codein.env.localfor better stack traces - You can extend the recommendation logic in
lib/algorithms/hybridRecommendation/ - Secure API routes using the secret key in
API_SECRET_KEY