How vijay-baunthiyal/post_generator works
Purpose and Top-Level Entry Points
This is a two-process AI-agent demo: a Next.js 15 frontend presents CopilotKit-powered interfaces, while a Python FastAPI service runs Gemini/LangGraph agents. The application supports social-post generation and website technology-stack analysis.
Frontend entry/layout: app/layout.tsx, app/page.tsx, app/wrapper.tsx. Backend entry: agent/main.py.
Frontend Application Shell
The Next.js App Router provides the shared document layout, global styling, theme/UI context, and agent integration wrapper. The wrapper is the likely boundary where CopilotKit client capabilities are configured for descendant pages.
Key paths: app/layout.tsx, app/wrapper.tsx, app/contexts/LayoutContext.tsx.
Task-Specific User Experiences
The frontend separates the two agent workflows into dedicated routes:
• Post generation accepts user context and renders platform-specific LinkedIn/X content.
• Stack analysis accepts a site URL and presents inferred technologies and tool activity.
Key paths: app/post-generator/page.tsx, app/stack-analyzer/page.tsx, components/ui/linkedin-post.tsx, components/ui/stack-analysis-cards.tsx.
CopilotKit and Chat API Boundary
Next.js route handlers expose CopilotKit and chat endpoints to the browser. These form the frontend server boundary for agent conversations/actions and likely proxy or coordinate with the Python agent runtime.
Key paths: app/api/copilotkit/route.ts, app/api/chat/route.ts, app/prompts/prompts.ts.
Python Agent Service
The FastAPI backend hosts the executable agent runtime. It contains distinct agent definitions for each task and shared prompt material. The frontend requires this service to be running, making it the primary AI-execution boundary rather than a purely client-side Gemini integration.
Key paths: agent/main.py, agent/posts_generator_agent.py, agent/stack_agent.py, agent/prompts.py.
Agent Processing Flow
Requests flow from task pages through CopilotKit/API handlers to FastAPI agents. Each agent uses LangGraph orchestration and Google Gemini inference, then returns structured/conversational outputs for UI rendering. The post agent transforms supplied context into LinkedIn and Twitter/X copy; the stack agent analyzes a supplied URL to identify frameworks, libraries, and infrastructure.
Key paths: agent/posts_generator_agent.py, agent/stack_agent.py, components/ui/x-post.tsx, components/ui/tool-logs.tsx.
Runtime and External Dependencies
The frontend runs on Node.js/Next.js and is managed with pnpm (package.json, pnpm-workspace.yaml). The backend is a Python project (agent/pyproject.toml) served via FastAPI. Gemini access depends on GOOGLE_API_KEY; CopilotKit links UI interactions to agent workflows; LangGraph structures agent execution. Deployment is compatible with the hosted Vercel frontend, while the Python service must be independently available.
Key paths: package.json, agent/pyproject.toml, next.config.mjs.
Main entry points: stack_agent.py Stack agent · wrapper.tsx CopilotKit wrapper · page.tsx Stack analyzer · main.py Agent runtime
Components 17
Next.js frontend
App Router UI and browser-facing integration.
- App shell · Provides shared layout, styling, and UI context.
app/layout.tsx - CopilotKit wrapper · Configures agent capabilities for descendant pages.
app/wrapper.tsx - Layout context
app/contexts/LayoutContext.tsx - Home page
app/page.tsx - Post generator · Collects context and displays generated social copy.
app/post-generator/page.tsx - Stack analyzer · Accepts a URL and presents inferred technologies.
app/stack-analyzer/page.tsx - Post renderers · Renders LinkedIn and X content.
components/ui/linkedin-post.tsx - Analysis results · Shows technology cards and agent tool activity.
components/ui/stack-analysis-cards.tsx - Tool logs
components/ui/tool-logs.tsx
Next.js API boundary
Server handlers for CopilotKit and chat requests.
- CopilotKit endpoint · Browser-facing CopilotKit conversation and action boundary.
app/api/copilotkit/route.ts - Chat endpoint · Chat request boundary for agent interactions.
app/api/chat/route.ts - Frontend prompts
app/prompts/prompts.ts
Python agent service
FastAPI-hosted task agents and orchestration.
- Agent runtime · Independently deployed Python execution boundary.
agent/main.py - Post agent · Produces LinkedIn and X copy from supplied context.
agent/posts_generator_agent.py - Stack agent · Analyzes URLs for frameworks, libraries, and infrastructure.
agent/stack_agent.py - Agent prompts
agent/prompts.py
Other components
- Google Gemini · Model inference authenticated with GOOGLE_API_KEY.
Connections 23
- App shell → CopilotKit wrapper: wraps
- App shell → Layout context: provides
- App shell → Home page: serves
- CopilotKit wrapper → Post generator: enables agent UI
- CopilotKit wrapper → Stack analyzer: enables agent UI
- Post generator → Post renderers: renders output
- Stack analyzer → Analysis results: renders output
- Stack analyzer → Tool logs: shows activity
- CopilotKit wrapper → CopilotKit endpoint: agent requests
- Post generator → Chat endpoint: chat requests
- Stack analyzer → Chat endpoint: analysis requests
- Frontend prompts → CopilotKit endpoint: supplies instructions
- CopilotKit endpoint → Agent runtime: forwards workflows
- Chat endpoint → Agent runtime: forwards requests
- Agent runtime → Post agent: runs post workflow
- Agent runtime → Stack agent: runs analysis workflow
- Agent prompts → Post agent: guides
- Agent prompts → Stack agent: guides
- Post agent → Google Gemini: LangGraph inference
- Stack agent → Google Gemini: LangGraph inference
- Post agent → Post renderers: structured copy
- Stack agent → Analysis results: technology findings
- Stack agent → Tool logs: tool events