Skip to content

πŸ“° ArticleHorizon is a smart news article recommender webapp that helps users discover relevant and engaging content tailored to their interests.

License

Notifications You must be signed in to change notification settings

RedDotz20/article-horizon

Repository files navigation

🧠 Hybrid Recommendation Algorithm

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.


πŸš€ Project Setup

βœ… Prerequisites

  • Node.js v18+
  • Supabase account with PostgreSQL
  • Git
  • Bun (or npm/yarn/pnpm)
  • Recommended: Visual Studio Code (for REACT_EDITOR integration)

πŸ“¦ Installation

  1. Clone the repository
git clone https://github.com/RedDotz20/news-content-recommender-system.git
cd news-content-recommender-system
  1. Install dependencies
bun install
# or npm install / yarn install / pnpm install
  1. Create and configure environment variables Copy .env.example and fill in .env.local:
cp .env.example .env.local

Fill 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

πŸ› οΈ Database Setup (Prisma + Supabase)

  1. Generate Prisma client
npx prisma generate
  1. Run migrations:
npx prisma migrate dev --name init
  1. (Optional) seed database if applicable:
npx prisma db seed

πŸ§ͺ Running the Application

bun run dev
# or npm run dev / yarn dev / pnpm dev

πŸ—‚οΈ Project Structure

src/
β”œβ”€β”€ 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

βš™οΈ Environment File Reference

File Description
.env.local Development-only configuration
.env.production Production deployment configuration
.env.example Template showing required keys

🧠 Algorithm Architecture

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.

πŸ“Œ Developer Notes

  • Use REACT_EDITOR=code in .env.local for better stack traces
  • You can extend the recommendation logic in lib/algorithms/hybridRecommendation/
  • Secure API routes using the secret key in API_SECRET_KEY

About

πŸ“° ArticleHorizon is a smart news article recommender webapp that helps users discover relevant and engaging content tailored to their interests.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages