How rohitdayal-jktech/blog-post-generator works
Project Type and Purpose
• This is a full-stack web application (“AI Blog Post Generator”) with a React/Next.js front end and a Python/FastAPI back end.
• Purpose: Let users enter blog parameters (topic, tone, length, audience, keywords) in a responsive UI, then generate a full blog post via a local LLM (Ollama) or remote APIs (OpenAI, Claude, Gemini).
File Structure Analysis
• Top-level:
• backend/ – Python FastAPI service with main.py and chatbot adapters (gemini_chatbot.py, ollama_chatbot.py), config.py, and conversation_history.json.
• src/app/ – Next.js “App Router” pages and components (BlogForm, BlogOutput, Navbar, Landing, etc.).
• src/app/contexts – ThemeContext for dark-mode toggle.
• src/app/utils/api.ts – front-end HTTP client to talk to the back end.
• public/ – static assets and screenshots.
• Configuration/build: package.json, next.config.ts, tsconfig.json, tailwind.config.js, backend/requirements.txt.
Architectural Patterns and Key Components
• Front-end (React/Next.js + Tailwind + ThemeContext)
• UI Components: Form (left pane), Output (right pane), Navbar, Footer, Landing.
• State & Context: Theme management, form state.
• API Client: src/app/utils/api.ts calls POST /generate on backend.
• API Layer (FastAPI)
• Endpoint POST /generate (main.py)
• Chatbot Adapters:
– Ollama adapter → local LLM server llama3.2:1b
– Gemini or other cloud adapters
• Persistence: conversation_history.json
• External/Infrastructure
• Local LLM Server (Ollama)
• Remote LLM APIs (OpenAI, Claude, Gemini)
• (Optional) Hosting platform for front end and back end
Relationships & Data Flow
1. User interacts with Next.js UI (blog parameters form)
2. Front-end calls FastAPI POST /generate via api.ts
3. FastAPI service selects adapter (Ollama or cloud)
4. Adapter sends prompt to local LLM server or remote API
5. Response flows back to FastAPI → appended to conversation_history.json → returned as structured JSON
6. Front-end receives JSON → BlogOutput component renders intro, body, conclusion