How bhushan4work/roastmyblog works
Purpose and Runtime
RoastMyBlog is a unified Next.js 15 full-stack application that accepts blog URLs or pasted text, extracts/analyzes writing, generates AI critique, and stores analysis history. It runs as a React 19 client UI plus Next.js route handlers, backed by MongoDB and Google/Groq AI APIs.
Key entry points:
• src/app/page.tsx
• src/app/layout.tsx
• src/app/api/analyze/route.ts
• src/app/api/stats/route.ts
Client Interaction Layer
The root page coordinates user submission, loading state, API calls, and result rendering. Presentation is separated into focused UI components for the landing/input experience, progress indication, and returned roast content.
• src/app/page.tsx
• src/components/Hero.tsx
• src/components/Results.tsx
• src/components/Loading.tsx
HTTP API Boundary
Next.js route handlers are the server boundary between browser interactions and backend workflows. The analysis endpoint is the primary orchestration entry point; the stats endpoint exposes persisted-history-derived data to the UI.
• src/app/api/analyze/route.ts
• src/app/api/stats/route.ts
• src/lib/api.ts
Content Acquisition and Normalization
Submitted URLs require server-side fetching and article extraction before analysis. The scraper service, supported by Cheerio, JSDOM, and Readability, isolates usable blog text; text utilities provide shared cleanup or preparation behavior before downstream analyzers and model prompts consume it.
• src/services/scraperService.ts
• src/utils/textUtil.ts
Analysis Pipeline
Analysis combines local deterministic assessments with AI-generated feedback. Readability and structure analyzers establish writing-specific signals, while the analyzer service composes these signals and the extracted or pasted source into the application’s final analysis workflow.
• src/services/analyzerService.ts
• src/analyzers/readabilityAnalyzer.ts
• src/analyzers/structureAnalyzer.ts
AI Provider Integration
AI generation is isolated behind a service boundary rather than called directly from routes or components. groqService represents the external LLM integration; the README also establishes Google Generative AI as a required provider. This boundary is where provider prompts, requests, failures, and model responses should remain contained.
• src/services/groqService.ts
• src/services/analyzerService.ts
Persistence and Domain Model
Completed analyses are persisted as roast/history records in MongoDB. The database service owns persistence operations, while the model defines the stored domain shape. API handlers and analysis orchestration should exchange typed application data rather than database-specific structures where possible.
• src/models/Roast.ts
• src/services/roastDbService.ts
• src/types/index.ts
Infrastructure and External Dependencies
Deployment requires Node.js, a Next.js-compatible runtime, and environment-provided credentials: MONGODB_URI, GOOGLE_API_KEY, and GROQ_API_KEY. External boundaries include arbitrary target websites for scraping, MongoDB/Atlas for history, and Google/Groq model APIs for critique generation. Styling is application-local through Tailwind and global CSS, not a separate frontend service.
• next.config.ts
• src/app/globals.css
• tailwind.config.ts
Main entry points: analyzerService.ts Analysis orchestrator · page.tsx Root page · route.ts Analyze endpoint · roastDbService.ts Roast repository
Components 20
React client
- App layout
src/app/layout.tsx - Root page · Owns submission, loading state, and result rendering.
src/app/page.tsx - Input landing
src/components/Hero.tsx - Progress UI
src/components/Loading.tsx - Roast results
src/components/Results.tsx - API client
src/lib/api.ts
Next.js server
- Analyze endpoint · Primary backend workflow entry point.
src/app/api/analyze/route.ts - Stats endpoint
src/app/api/stats/route.ts
Analysis pipeline
- Article extraction · Fetches URLs and extracts usable article text.
src/services/scraperService.ts - Text preparation
src/utils/textUtil.ts - Analysis orchestrator · Combines source text, local signals, and AI critique.
src/services/analyzerService.ts - Readability signals
src/analyzers/readabilityAnalyzer.ts - Structure signals
src/analyzers/structureAnalyzer.ts - LLM gateway · Contains model prompts, requests, and provider failures.
src/services/groqService.ts
Persistence
- Roast repository
src/services/roastDbService.ts - Roast record
src/models/Roast.ts - Application types
src/types/index.ts
External systems
- Target websites · Arbitrary submitted blog URLs.
- MongoDB / Atlas · Stores completed analysis history.
- Groq and Google AI · External critique-generation providers.
Connections 22
- App layout → Root page: hosts
- Root page → Input landing: renders
- Root page → Progress UI: renders state
- Root page → Roast results: renders
- Root page → API client: submits via
- API client → Analyze endpoint: analyze request
- API client → Stats endpoint: history stats
- Analyze endpoint → Article extraction: URL source
- Article extraction → Target websites: fetches
- Article extraction → Text preparation: normalizes
- Analyze endpoint → Analysis orchestrator: source text
- Text preparation → Analysis orchestrator: prepared text
- Analysis orchestrator → Readability signals: measures
- Analysis orchestrator → Structure signals: measures
- Analysis orchestrator → LLM gateway: requests critique
- LLM gateway → Groq and Google AI: generates via
- Analyze endpoint → Roast repository: persists result
- Stats endpoint → Roast repository: queries history
- Roast repository → Roast record: stores
- Roast repository → MongoDB / Atlas: reads and writes
- Analyze endpoint → Application types: uses contracts
- Analysis orchestrator → Application types: returns typed data