Skip to content

Ashishamar99/AI-Coffee-Breaks

Repository files navigation

AI Coffee Breaks

5-10 minute AI dev guides for your coffee break. Built with Next.js, Supabase, and OpenAI/Gemini.

Setup

1. Install dependencies

npm install

2. Create a Supabase project

Go to supabase.com and create a new project. Then open the SQL Editor and run:

create table guides (
  slug text primary key,
  title text not null,
  description text not null,
  category text not null,
  date date not null,
  reading_time text not null,
  difficulty text not null,
  tags text[] not null default '{}',
  sections jsonb not null default '[]',
  videos jsonb not null default '[]',
  resources jsonb not null default '[]',
  source text not null default 'generated',
  created_at timestamptz not null default now()
);

create index idx_guides_date on guides(date desc);
create index idx_guides_category on guides(category);
create index idx_guides_source on guides(source);

3. Configure environment

Copy .env.example to .env and fill in your keys:

OPENAI_API_KEY=sk-...
GEMINI_API_KEY=AI...                    # fallback LLM
SUPABASE_URL=https://xxx.supabase.co
SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...
TELEGRAM_BOT_TOKEN=...                  # error alerts
TELEGRAM_CHAT_ID=...

4. Seed the database

Load the curated guides into Supabase:

npm run seed

5. Run the app

npm run dev

API Endpoints

Get all guides

curl http://localhost:3000/api/guides

Filter by category:

curl "http://localhost:3000/api/guides?category=AI%20Tools"

Filter by source (curated, fundamental, generated):

curl "http://localhost:3000/api/guides?source=generated"

Fetch latest news

curl http://localhost:3000/api/news
curl "http://localhost:3000/api/news?hours=48"

Refresh — generate new guides from today's news

curl -X POST http://localhost:3000/api/refresh

This fetches RSS feeds, filters for dev-relevant topics, checks for duplicates against existing guides in Supabase, generates new guides (OpenAI with Gemini fallback), and saves them to the database.

Run the pipeline from CLI

npm run pipeline

Same flow as the refresh endpoint but runs as a standalone script.

Scripts

Command Description
npm run dev Start dev server
npm run build Production build
npm run seed Seed Supabase with curated guides
npm run pipeline Generate new guides from today's news

Architecture

  • Storage: Supabase PostgreSQL (single guides table, JSONB for sections/videos/resources)
  • Guide generation: OpenAI (primary) → Gemini (fallback) → heuristic filter
  • News sources: RSS feeds from TechCrunch, Hacker News, The Verge, Dev.to, MIT Tech Review
  • Error alerts: Telegram bot notifications on LLM failures, DB errors, pipeline crashes

About

AI Coffee Breaks

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages