How I Built an AI Agent for my Portfolio (Yabasha.dev) using Laravel & Next.js
Source: Dev.to

As a Tech Lead and AI Engineer, I often tell my colleagues: “The cobbler’s children have no shoes.” We build sophisticated, high‑performance systems for others, but our own portfolio sites often gather dust, lacking the polish we demand in our professional work.
I decided to fix this for my own platform, Yabasha.dev. I didn’t just want a blog; I wanted a living playground for my expertise in AI Agents and Full‑Stack Architecture.
So, I built an AI Agent to be my “Senior Editor” and “SEO Manager,” automating the tedious parts of content creation so I could focus on writing. Here is a deep dive into how I built it using Laravel, Next.js, and OpenRouter.
The Architecture: Hybrid Power
Backend: Laravel 12 (API, Admin Panel via Filament)
Frontend: Next.js 15 (Static Generation, React Server Components)
AI Gateway: OpenRouter (Unified API for OpenAI, Anthropic, Google, and Meta models)
This setup gives me the developer experience and stability of Laravel for data management, while delivering the blazing‑fast performance of Next.js for the end user.
The Problem: Friction
Writing a technical article is only 50 % of the work. The other 50 % is:
- Writing a compelling meta description.
- Figuring out the primary and secondary SEO keywords.
- Generating Open Graph (OG) tags so it looks good on Twitter/LinkedIn.
- Categorizing the content.
- Estimating reading time and difficulty level.
This friction often prevented me from hitting “Publish”.
The Solution: The “Editor” Agent
I created a background service in Laravel (PostAiService) that acts as an autonomous agent. It doesn’t just “summarize” text; it analyzes it with a specific persona.
The Brain
The core logic resides in a dedicated service that constructs a complex prompt. I instruct the LLM to act as an “Expert SEO Specialist and Content Editor.”
// app/Services/PostAiService.php
protected function buildAnalysisPrompt(string $content): string
{
return apiKey)
->post($this->baseUrl . '/chat/completions', [
'model' => $model->request_id,
'messages' => [
['role' => 'user', 'content' => 'Count from 1 to 10.']
],
]);
// Calculate tokens per second (TPS) and store it
// ...
$model->update(['actual_speed' => $tps]);
}
In the admin panel I can sort models by Cost and Speed (Tokens/Sec) and toggle the active model for my agent instantly. When a new, cheaper model appears, I add it, benchmark it, and switch the agent to use it.
The Result: Zero‑Friction Publishing
My workflow is now:
- Write a rough draft in Markdown.
- Save it.
- The
PostObserverdetects the change and queues a job. - The AI Agent reads the draft and fills in all SEO metadata, summaries, and categorization.
- Next.js rebuilds the page, pulling this rich metadata into the “ of the document.
The result is a perfectly optimized page on Yabasha.dev without spending a single second on “optimization.”
Conclusion
AI isn’t about replacing engineers; it’s about amplifying them. By building this agent, I’ve removed the administrative burden of blogging, allowing me to focus entirely on sharing knowledge.
If you’re interested in building similar AI‑driven architectures or need a senior pair of hands on your Next.js/Laravel stack, feel free to reach out or check out my work at Yabasha.dev.