<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by muhammadhalimdirgantara on Medium]]></title>
        <description><![CDATA[Stories by muhammadhalimdirgantara on Medium]]></description>
        <link>https://medium.com/@halimdirgantara?source=rss-9071d164c88a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0mL47so_jPdu_gWcVucxGA.png</url>
            <title>Stories by muhammadhalimdirgantara on Medium</title>
            <link>https://medium.com/@halimdirgantara?source=rss-9071d164c88a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:47:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@halimdirgantara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automate Your Laravel Setup: Deploy with One Script]]></title>
            <link>https://medium.com/@halimdirgantara/automate-your-laravel-setup-deploy-with-one-script-102bc5495079?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/102bc5495079</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[script]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[livewire]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 03:01:49 GMT</pubDate>
            <atom:updated>2025-10-19T03:01:49.068Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>We’ve all been there.<br>A fresh Laravel project, a blank terminal, and a mental checklist longer than a migration log.</blockquote><blockquote>Install Laravel.<br>Set up Tailwind.<br>Configure Livewire.<br>Add Spatie packages.<br>Pick a UI framework (and maybe change your mind halfway through).</blockquote><blockquote>Fifteen to thirty minutes later, we finally start coding.<br>And that’s for every new project.</blockquote><blockquote>What if all of that — every dependency, every config, every UI setup — could happen in one command?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YinJDXXK9dNmxKWIyaMFHw.png" /></figure><h3>The Problem: Repetition Without Progress</h3><p>As developers, we optimize everything — except our own setup flow.</p><p>Each time we start a new Laravel app, we repeat the same steps:<br>installing packages, configuring Tailwind, setting up permissions, running migrations, tweaking .env, and building assets.</p><p>Sometimes we forget a dependency.<br>Sometimes the configurations drift between projects.<br>And sometimes, testing new UI frameworks turns into hours of reinstalling just to compare styles.</p><p>The result? Inconsistent environments, slower onboarding, and a lot of wasted time.</p><h3>The Idea: A Single Script for Everything</h3><p>So we built a set of deployment scripts that automate every part of Laravel’s initial setup.<br>One command — and your environment comes alive.</p><p>They work across <strong>Linux</strong> and <strong>Windows</strong>, install all the right packages, and even let you choose your favorite <strong>UI framework</strong> from six options.</p><p>Everything’s pre-configured.<br>Everything just works.</p><h3>What These Scripts Do</h3><p>Let’s see what happens under the hood.</p><p>The scripts automatically install <strong>Laravel</strong>, set up a consistent <strong>stack</strong>, and configure every layer — from front-end scaffolding to database migrations.</p><h3>Pre-Configured Stack</h3><p>Each setup includes:</p><ul><li><strong>Laravel + Livewire</strong> for full-stack dynamic interfaces.</li><li><strong>Tailwind CSS</strong> for styling and design consistency.</li><li><strong>Spatie Permission</strong> for role-based access control.</li><li><strong>Spatie Activity Log</strong> for user tracking and auditing.</li></ul><p>It’s everything we need for a production-ready project — out of the box.</p><h3>UI Framework Choices</h3><p>Sometimes, the best UI depends on the project.<br>So these scripts let us pick from six popular frameworks:</p><ol><li>Mary UI</li><li>Wire UI</li><li>TallCraft UI</li><li>Sheaf UI</li><li>Flowbite</li><li>BladewindUI</li></ol><p>Or we can choose option <strong>7 — “All frameworks”</strong> — and install everything at once for side-by-side comparison.<br>Perfect for testing components or learning design systems.</p><h3>One-Command Automation</h3><p>The scripts handle everything:</p><ul><li>.env creation and database setup</li><li>Composer dependencies</li><li>Node installation and Tailwind compilation</li><li>Migration and seeding</li><li>Optional framework installation</li><li>Asset building</li></ul><p>It’s like cloning a ready-to-code project — but customized exactly how we want it.</p><h3>Technology Stack Breakdown</h3><p>Let’s walk through the foundations that make this automation stack powerful.</p><h3>Laravel + Livewire</h3><p>Laravel gives us structure; Livewire gives it breath.<br>Together, they let us build reactive interfaces without leaving PHP.</p><p>No complex JavaScript build chains, no full SPA overhead — just Blade, state, and reactivity.<br>We stay productive and focused on logic instead of framework plumbing.</p><h3>Tailwind CSS</h3><p>Tailwind’s utility-first approach complements this philosophy perfectly.<br>Instead of chasing pixel perfection through endless CSS files, we compose directly in markup.<br>It’s fast, predictable, and consistent — exactly what deployment scripts should aim for.</p><h3>Spatie Packages</h3><p>Spatie’s packages are the silent architects of many Laravel apps.</p><ul><li><strong>Permission</strong> gives us structured role-based access control with just a few artisan commands.</li><li><strong>Activity Log</strong> keeps transparent records of every significant user action.</li></ul><p>Both are pre-installed, configured, and ready the moment we hit Enter.</p><h3>UI Frameworks at a Glance</h3><p>Each UI library brings its own character:</p><ul><li><strong>Mary UI</strong> — Elegant simplicity for dashboards.</li><li><strong>Wire UI</strong> — Clean and modern, built for Livewire integration.</li><li><strong>TallCraft UI</strong> — Component-rich, ideal for admin panels.</li><li><strong>Sheaf UI</strong> — Lightweight and aesthetic.</li><li><strong>Flowbite</strong> — Tailwind-based with polished defaults.</li><li><strong>BladewindUI</strong> — Feature-rich, perfect for rapid prototyping.</li></ul><p>We can switch, compare, and build — without ever reconfiguring the core stack.</p><h3>Installation Guide</h3><p>Now it’s time to see the scripts in action.</p><h3>Prerequisites</h3><p>Make sure you have:</p><ul><li>PHP 8.2+</li><li>Composer</li><li>Node.js + npm</li><li>MySQL or SQLite</li><li>Git</li></ul><h3>Linux Setup</h3><p>Clone the repository and make the script executable:</p><pre>git clone https://github.com/halimdirgantara/laravel-deployment-script.git<br>cd laravel-deployment-script<br>chmod +x deploy-laravel.sh<br>./deploy-laravel.sh</pre><p>The script will guide you through setup:<br> project name, database configuration, and UI framework choice.</p><p>As it runs, the terminal fills with Composer logs, Node builds, and artisan outputs — like watching an automated orchestra set up your environment.</p><h3>Windows Setup</h3><p>For Windows users, there are three paths: <strong>Batch</strong>, <strong>PowerShell</strong>, or <strong>direct Git Bash execution</strong>.</p><p>PowerShell is recommended for better compatibility and colored output.</p><pre>Set-ExecutionPolicy RemoteSigned -Scope Process<br>.\deploy-laravel.ps1</pre><p>The script feels alive here too — colored prompts, real-time progress, and instant feedback.</p><h3>Interactive Prompts</h3><p>Each step asks simple, meaningful questions:</p><pre>Enter project name: blog-demo<br>Select UI framework (1-7): 7<br>Database name: blog_db</pre><p>From there, the automation takes over — creating your Laravel app, configuring the .env, installing dependencies, and compiling assets.</p><h3>The Multiple UI Option</h3><p>This is where the fun begins.</p><p>Installing multiple UI frameworks side-by-side opens up an entire playground for exploration.</p><h3>Why Install Them All?</h3><p>When working across clients or internal projects, every team prefers a different UI toolkit.<br>Instead of rebuilding the same base each time, we can now switch instantly.</p><p>Want to compare component syntax between Flowbite and Bladewind?<br>Or test Mary UI components next to Wire UI in the same project?<br>Done — all without reinstalling anything.</p><h3>How It’s Engineered</h3><p>Tailwind’s configuration is dynamically extended for each framework.<br>The script ensures no conflicting plugins or purge paths, so everything compiles cleanly.</p><p>It’s like sandboxing your design system — multiple personalities, one unified environment.</p><h3>Real-World Scenarios</h3><ul><li><strong>Agencies</strong> testing UI preferences for clients.</li><li><strong>Students</strong> comparing Livewire UI kits for learning.</li><li><strong>Developers</strong> prototyping admin dashboards faster.</li></ul><p>This is where automation meets curiosity — and both win.</p><h3>Under the Hood</h3><p>Let’s take a peek behind the curtain.</p><h3>Modular Script Architecture</h3><p>Each script is modular — separate functions handle Laravel installation, Tailwind setup, UI installation, and database configuration.<br>If one step fails, it provides clear logs and halts gracefully.</p><h3>Key Code Section</h3><pre># Install all UI frameworks<br>if [ &quot;$UI_CHOICE&quot; == &quot;7&quot; ]; then<br>    install_mary_ui<br>    install_wire_ui<br>    install_tallcraft_ui<br>    install_sheaf_ui<br>    install_flowbite<br>    install_bladewindui<br>fi</pre><p>This simple block enables a multi-framework universe.</p><h3>Tailwind Configuration</h3><p>The script merges Tailwind configs dynamically:</p><pre>npx tailwindcss init -p</pre><p>Then injects content paths for each framework, ensuring all components are scanned for classes.<br>No CSS bloat. No manual editing.</p><h3>Database Setup Automation</h3><p>The .env file is built automatically with your input:</p><pre>DB_DATABASE=blog_db<br>DB_USERNAME=root<br>DB_PASSWORD=</pre><p>Migrations run immediately after configuration — creating a ready-to-test schema before the first commit.</p><h3>Customization and Extension</h3><p>We made the scripts flexible — not fixed.</p><h3>Add Your Own Packages</h3><p>Want <strong>Inertia</strong>, <strong>Laravel Scout</strong>, or <strong>Pest</strong> pre-installed?<br> Just add them to the dependency section.</p><p>Each part of the script is designed to be readable and extendable.</p><h3>Adding New UI Frameworks</h3><p>You can define new installation blocks:</p><pre>install_custom_ui() {<br>    composer require vendor/package<br>    npm install package-name<br>}</pre><p>Then map it in the framework selector.<br>That’s it — your new UI framework becomes a first-class citizen.</p><h3>Enterprise Integrations</h3><p>For enterprise use, you can configure:</p><ul><li>Private package repositories</li><li>Custom .env templates</li><li>CI/CD hooks for automated deployments</li></ul><p>The scripts adapt easily to both solo projects and large development teams.</p><h3>Best Practices</h3><h3>When to Use</h3><p>These scripts are perfect for:</p><ul><li>Spinning up prototypes quickly</li><li>Onboarding new developers</li><li>Standardizing team environments</li><li>Testing UI kits across projects</li></ul><p>For production, use them as <strong>bootstrappers</strong> — then apply additional CI/CD hardening.</p><h3>Security Considerations</h3><p>The scripts never hardcode credentials.<br>All sensitive data is prompted or sourced from environment variables.<br>We keep setup fast, not reckless.</p><h3>Performance</h3><p>Each run caches dependencies, optimizes assets, and compiles Tailwind efficiently.<br>Subsequent setups are significantly faster — especially on Linux.</p><h3>Troubleshooting</h3><p>Even automation can meet friction — but every issue has a fix.</p><h3>Common Setup Errors</h3><p>If you see composer not found, make sure Composer is installed and accessible in $PATH.</p><p>For npm ERR!, clear cache:</p><pre>npm cache clean --force</pre><p>Then rerun the script.</p><h3>Database Connection Issues</h3><p>Check your .env values — especially DB_HOST and DB_SOCKET.<br>On Linux, you might need to run:</p><pre>sudo service mysql start</pre><h3>UI Conflicts</h3><p>If any UI framework assets overlap, clear compiled files:</p><pre>php artisan view:clear<br>php artisan optimize:clear<br>npm run build</pre><p>Everything resets cleanly.</p><h3>Real-World Results</h3><p>Let’s talk about outcomes.</p><h3>Time Saved</h3><p>Manual setup averages <strong>20–30 minutes</strong> per project.<br>Automated setup? <strong>5–10 minutes</strong> — with perfect consistency.</p><p>Across multiple projects, that’s hours — even days — saved.</p><h3>Consistency</h3><p>Every project now starts with the same dependencies, folder structure, and Tailwind configuration.<br>No “works on my machine” moments.</p><h3>Developer Experience</h3><p>We spend less time on setup, more time on creation.<br>And that’s the essence of good tooling — removing friction so creativity can flow.</p><h3>Comparison with Alternatives</h3><h3>Laravel Installer</h3><p>The default Laravel installer is great, but it stops at project scaffolding.<br>Our scripts continue the journey — installing UI frameworks, Spatie packages, and configurations automatically.</p><h3>Breeze &amp; Jetstream</h3><p>These are opinionated starters.<br>The deployment scripts, however, stay <strong>neutral</strong> — they let <em>you</em> choose your stack and customize freely.</p><h3>Manual Setup</h3><p>Still valuable for learning, but inefficient for daily work.<br>Once you understand the moving parts, automation becomes the natural next step.</p><h3>Future Roadmap</h3><p>We’re just getting started.</p><h3>Planned Updates</h3><ul><li>More UI frameworks</li><li>Docker-based environment setup</li><li>Advanced Spatie integrations</li><li>CI/CD templates for GitHub Actions</li></ul><h3>Community Contributions</h3><p>The repository is open-source:<br><a href="https://github.com/halimdirgantara/laravel-deployment-script"><strong><em>https://github.com/halimdirgantara/laravel-deployment-script</em></strong></a></p><p>Feature requests and pull requests are welcome.<br>Every contribution improves the developer experience for all of us.</p><h3>Conclusion</h3><p>Automation doesn’t remove creativity — it amplifies it.</p><p>By turning our repetitive setup routines into one unified process, we free time for what truly matters: building features, designing systems, and experimenting with ideas.</p><p>These scripts aren’t just about speed.<br> They’re about <strong>consistency, clarity, and control</strong>.<br> They bring structure where chaos used to live.</p><p>So next time you start a new Laravel project, don’t repeat the past — automate it.</p><p>Clone the repo, run the script, and watch your app take its first automated breath.</p><p>“From here, the project starts to feel alive.”</p><p><strong><em>Try it yourself:</em></strong><em> </em><a href="https://github.com/halimdirgantara/laravel-deployment-script"><em>github.com/halimdirgantara/laravel-deployment-script</em></a></p><p>Stay tuned — next, we’ll explore how to integrate Docker and CI/CD into this workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=102bc5495079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang + HTMX + Vibe Coding Tutorial Series — Part 5: Building the Repository Layer & Testing]]></title>
            <link>https://medium.com/@halimdirgantara/golang-htmx-vibe-coding-tutorial-series-part-5-building-the-repository-layer-testing-98a847ff07da?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/98a847ff07da</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 02:01:47 GMT</pubDate>
            <atom:updated>2025-10-17T02:01:47.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang + HTMX + Vibe Coding Tutorial Series — Part 5: Building the Repository Layer &amp; Testing</h3><blockquote>In the<a href="https://medium.com/@halimdirgantara/golang-htmx-vibe-coding-tutorial-series-part-4-exploring-the-code-structure-9ebd4a977842"> last part</a>, we explored the project structure that Claude Code generated — a complete scaffolding ready to evolve into a living system.<br> Now it’s time to go deeper.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*cugsz5XSLRFmKBqiG_tMjA.png" /></figure><p>In this part we complete Phase 1: run migrations, seed data, implement the repository layer, compile and test binaries, and prepare the project for Phase 2 (template engine &amp; admin dashboard).<br> We’ll do this the Vibe Coding way — commanding Claude Code from our terminal, reviewing what it generates, and running tests ourselves. Below is a step-by-step log you can follow and copy-paste as you work.</p><h4>Prepare the workspace and open Claude Code</h4><p>From your project root:</p><pre>cd ~/Programming/GitHub/golang-company-site<br>git status   # confirm branch and working tree</pre><p>Start the Claude Code CLI (we used Anthropic’s claude tool):</p><pre>claude</pre><p>Inside the Claude shell we switch to <strong>plan mode</strong> (on my setup: Shift+Tab to toggle plan mode). Plan mode instructs Claude to prepare a plan and ask for approvals before executing shell actions.</p><p><strong>CLI prompt to Claude (example):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*oTyAOYBaE7iZ40OLIvVppw.png" /></figure><p>When Claude asks for permission to run shell commands (it will show options), choose:</p><ul><li>For exploratory steps: <em>Yes, and manually approve edits</em> (option 2) — we want control.</li><li>For automated batch tasks later: <em>Yes, and auto-accept edits</em> (option 1) when we trust the plan.</li></ul><h4>Run database migrations</h4><p>We ran the migration command through Claude, but you can run locally too:</p><pre># run migrations (up)<br>go run cmd/migrate/main.go up<br># or to check status<br>go run cmd/migrate/main.go status</pre><p>Expected output: confirmations that each migration applied and eventually a summary showing all 25 tables created. If using Claude, it prints logs similar to:</p><pre>[0.584ms] [rows:-] SELECT DATABASE()<br>Migration 001_create_users_table.sql ... OK<br>...<br>All migrations applied. 25 tables created.</pre><p>If any migration fails, read the SQL file listed and fix the schema (reserved words like key require backticks in MySQL). After adjustment, re-run the up command.</p><h4>Seed the database</h4><p>Once migrations are complete, run the seed script:</p><pre>go run cmd/seed/main.go</pre><p>Expected seed tasks (examples from our seed contents):</p><ul><li>Create admin user: admin / admin123</li><li>Insert default settings</li><li>Insert sample categories, products, reports</li></ul><p>If the seed script finds duplicates, it typically warns but continues. A minor issue we saw earlier was a reserved word (key) in SQL — wrap such column names in backticks or rename the column.</p><p>After seeding, verify tables:</p><pre># from mysql client<br>USE company_site;<br>SELECT COUNT(*) FROM users;<br>SELECT COUNT(*) FROM posts;</pre><h4>Start server (background) and test auth</h4><p>Start server (background):</p><pre># start server in background (timeout used in some setups)<br>timeout 5 go run cmd/server/main.go &amp;</pre><p>Test authentication endpoint (curl):</p><pre>curl -X POST http://localhost:8080/api/auth/login \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;username&quot;:&quot;admin&quot;,&quot;password&quot;:&quot;admin123&quot;}&#39;</pre><p>Expected JSON response:</p><pre>{<br>  &quot;token&quot;: &quot;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...&quot;,<br>  &quot;user&quot;: {<br>    &quot;id&quot;: 1,<br>    &quot;username&quot;: &quot;admin&quot;,<br>    &quot;role&quot;: &quot;admin&quot;<br>  }<br>}</pre><p>If it returns a token, JWT generation is working and protected routes can be tested with Authorization: Bearer &lt;token&gt;.</p><h4>Implement missing repositories (what we asked Claude to generate)</h4><p>We asked Claude to create repository implementations following an interface-first approach. Example prompts we used inside Claude shell:</p><pre>Create PostRepository implementation using GORM. Use Preload for Author, Categories, Tags. Include:<br>- Create(*Post)<br>- GetByID(id uint)<br>- List(filters PostFilters)<br>- Update(*Post)<br>- Delete(id uint)<br>- IncrementViews(id uint) (atomic counter)</pre><p>And similarly for CategoryRepository:</p><pre>Create CategoryRepository with hierarchical functions:<br>- GetHierarchical()<br>- GetByID(id uint)<br>- Create, Update, Delete<br>- ListRootCategories()</pre><p>Claude produced internal/repository/*.go files. Typical repository implementation patterns:</p><pre>type postRepository struct { db *gorm.DB }</pre><pre>func (r *postRepository) GetByID(id uint) (*models.Post, error) {<br>  var post models.Post<br>  err := r.db.Preload(&quot;Author&quot;).<br>            Preload(&quot;Categories&quot;).<br>            Preload(&quot;Tags&quot;).<br>            First(&amp;post, id).Error<br>  if err != nil { return nil, err }<br>  return &amp;post, nil<br>}</pre><p>Protips we enforced:</p><ul><li>Use .Preload(...) to prevent N+1.</li><li>Return pointer types for optional data.</li><li>Use gorm.Expr(&quot;views + 1&quot;) for atomic counters.</li><li>Implement pagination and return total counts for List methods.</li></ul><h4>Create web directory structure</h4><p>We prepared the web/ folder for template integration:</p><pre>mkdir -p web/templates/layouts<br>mkdir -p web/templates/partials<br>mkdir -p web/templates/pages/admin<br>mkdir -p web/templates/pages/public<br>mkdir -p web/static/css web/static/js web/static/images</pre><p>Inside Claude we asked it to scaffold minimal base templates so the server can render without missing files. For example, create web/templates/layouts/base.html with a basic layout and include HTMX &amp; Alpine.js CDN links.</p><h3>Build binaries and verify compile</h3><p>We compiled everything to ensure the generated code is correct.</p><pre># compile all packages (quick check)<br>go build ./...</pre><pre># build binaries<br>go build -o bin/server cmd/server/main.go<br>go build -o bin/migrate cmd/migrate/main.go<br>go build -o bin/seed cmd/seed/main.go</pre><pre>ls -lh bin/<br># expect: server ~32M, migrate ~13M, seed ~13M (sizes vary)</pre><p>If go build fails, read the compiler errors, open the relevant files, and fix missing imports or type mismatches. We iterated with Claude for fixes (Claude suggested small code edits and we recompiled).</p><h4>Run project tests and integration checks</h4><p>At this point, Claude had already generated all the repositories and committed the previous changes.<br> Before moving forward, we wanted to make sure that everything actually compiles and runs correctly.</p><p>So we asked Claude to <strong>test the entire codebase</strong> and compile all packages — not just the server, but everything under the ./... path.</p><p>We wrote this in Claude Code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*jveBWY_J1j_qkpa9z3ylwQ.png" /></figure><p>We selected <strong>option 1: Yes</strong>, to let Claude continue building while keeping manual approval for the next steps.</p><p>After about a minute of compilation, the build finished successfully — no errors, no warnings.<br> Claude then verified the binary and reported that everything compiled cleanly, meaning all our repositories, services, and handlers were consistent.</p><p>This step was important because it’s the moment when all layers — from config, database, repositories, middleware, to handlers — are compiled together for the first time as one full system.</p><h4>Git: staging and commit</h4><p>After confirming that all binaries compiled and ran successfully, Claude took the next logical step — creating a proper Git commit.<br> Since we’d already asked it earlier to <em>“create a Git commit if the code works correctly”</em>, Claude remembered that instruction and handled it automatically.</p><p>It started by checking the current repository state:</p><pre>git status</pre><p>Claude confirmed our branch was clean and up to date with origin/main. Then it detected the newly added files — particularly the generated repositories and supporting Go files — and proposed to stage them:</p><pre>git add web/ internal/repository/*.go &amp;&amp; git status</pre><p>As usual, Claude asked for confirmation before executing:</p><pre>Bash command  <br>git add web/ internal/repository/*.go &amp;&amp; git status  <br>Add new files to git  </pre><pre>Do you want to proceed?  <br>❯ 1. Yes  <br>  2. Yes, and don’t ask again for git add commands in /home/halim/Programming/GitHub/golang-company-site  <br>  3. No, and tell Claude what to do differently (esc)</pre><p>We confirmed with <strong>option 1</strong>, letting Claude move forward.<br> Immediately after staging, Claude summarized what it had done and proceeded to commit with an auto-generated message describing the work it had just completed.</p><p>The commit message it created looked like this:</p><pre>git commit -m &quot;chore: build binaries, verify migrations, and seed data successfully&quot;</pre><p>That’s the beauty of the Claude Code workflow — it doesn’t just run commands; it understands context.<br> It knew that the tests passed, migrations succeeded, binaries compiled, and everything was validated — so the next natural step was to document that progress in Git.</p><p>This moment closed the loop for the entire development phase:</p><ul><li>We planned with development-todolist.md</li><li>We executed the steps using Claude Code</li><li>We verified migrations, seeding, and builds</li><li>And we committed the result, ready for the next iteration</li></ul><p>In a normal workflow, this process could take hours of setup and review.<br> But with Vibe Coding, it felt like working side by side with a teammate — one that remembers context, double-checks before acting, and never forgets a single step.</p><h4>What we asked Claude to do (exact commands/prompts we used)</h4><p>Use these exact prompts inside the claude shell. We ran them step-by-step, approved plans, then let Claude create files.</p><p><strong>Plan phase 1</strong></p><pre>Analyze @docs/plan/development-todolist.md and produce PHASE 1: Implementation Plan (detailed steps). Show plan and ask for approval.</pre><p><strong>Run migrations</strong></p><pre>Bash: go run cmd/migrate/main.go up</pre><p>(We approved after reviewing plan.)</p><p><strong>Check migration status</strong></p><pre>Bash: go run cmd/migrate/main.go status</pre><p><strong>Read seed file and run</strong></p><pre>Read: cmd/seed/main.go<br>Bash: go run cmd/seed/main.go</pre><p><strong>Build repo files</strong></p><pre>Generate repository implementations for:<br>@PostRepository<br>@CategoryRepository<br>@TagRepository<br>@PageRepository<br>@ProductRepository<br>@ProjectRepository<br>@ReportRepository<br>@SettingRepository</pre><pre>Use GORM, include Preload, pagination, filtering, and atomic counters. Place files in internal/repository/.</pre><p><strong>Scaffold web</strong></p><pre>Create web/templates/layouts/base.html and web/static includes for htmx, alpine, and tailwind (CDN). Create minimal admin and public page templates.</pre><p><strong>Compile and test</strong></p><pre>Bash: go build -o bin/server cmd/server/main.go<br>Bash: go build -o bin/migrate cmd/migrate/main.go<br>Bash: go build -o bin/seed cmd/seed/main.go</pre><p><strong>Commit</strong></p><pre>Bash: git add internal/repository/*.go web/ &amp;&amp; git commit -m &quot;feat: implement repository layer and web structure for Phase 1&quot; &amp;&amp; git push</pre><p>We approved each step in Claude’s interactive prompts, inspected generated code, ran go build, and iterated when necessary.</p><h4>Troubleshooting notes we encountered (and solutions)</h4><ul><li><strong>Reserved SQL word (</strong><strong>key)</strong> — wrap column name in backticks or rename field to setting_key. Fix migrations or seed SQL accordingly.</li><li><strong>N+1 queries</strong> — solved by using Preload(&quot;Relation&quot;) in repository Get/List functions.</li><li><strong>Failed builds after generation</strong> — usually minor missing imports; run go vet or read compiler error and ask Claude to add imports or fix types.</li><li><strong>Seeding duplicates</strong> — seed script should use INSERT IGNORE or check existence first. We adjusted seed logic to FirstOrCreate in GORM.</li></ul><h4>Ready for Phase 2</h4><p>Phase 1 is ~90% complete: migrations, seeds, models, authentication, and repository layer are implemented and tested. Next we must:</p><ol><li>Set up Go html/template engine and integrate Tailwind/HTMX/Alpine.</li><li>Build admin dashboard handlers &amp; templates.</li><li>Wire services to templates using HTMX endpoints for inline updates.</li></ol><p>We’ll start Phase 2 by scaffolding the admin dashboard routes and basic HTMX partials next.</p><h3>What’s Working Now</h3><p>At this stage, the foundation is no longer just code — it’s a running system.<br> We’ve gone through the setup, run migrations, seeded data, tested the authentication flow, and compiled everything into working binaries.<br> Here’s what’s now fully functional inside our app:</p><ul><li><strong>Database migrations</strong> are complete — all 25 tables have been created exactly as planned in the ERD.</li><li><strong>Seed scripts</strong> are working — we now have an admin account and default configuration data ready to use.</li><li><strong>Repository layer</strong> is in place — each core entity has its own repository for clean data access and logic separation.</li><li><strong>Web directory</strong> is scaffolded — templates and static folders are ready for the next stage (the HTMX frontend).</li><li><strong>All binaries</strong> compile successfully — server, migrate, and seed commands build and run without errors.</li><li><strong>Authentication flow</strong> works — login, JWT generation, and protected routes are already functioning in the test environment.</li><li><strong>Version control</strong> is clean — all changes committed with clear messages and synced to the main branch.</li></ul><p>It’s not just a structure anymore — it’s an application that breathes.<br> From this point on, every feature we add will sit on top of a stable, tested foundation.What’s Next</p><p>At this point, we’ve completed the first real development milestone.<br> We worked side by side with Claude Code — giving it commands, reviewing every response, testing each layer, and refining the workflow as we went.<br> This is what <em>Vibe Coding</em> truly looks like in practice: <strong>prompt → review → test → commit</strong>.</p><p>Our configuration, database, and authentication systems are all up and running — and the entire foundation is now stable.<br> From here, we can finally move toward the part that brings everything to life: the user interface.</p><p>In the next story, we’ll set up the <strong>template engine</strong> and start building the <strong>admin dashboard</strong>.<br> We’ll wire the repositories into real HTMX-driven pages, connect the backend logic, and create our first functional CRUD interfaces.</p><p>As always, we’ll include the exact Claude prompts and terminal commands we used — so you can follow along, line by line, and replicate the same workflow in your own environment.</p><p>👉 Stay tuned for <strong>Part 6: Template Engine Setup and the Admin Dashboard</strong> — where the backend meets the frontend, and the project starts to feel alive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98a847ff07da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang + HTMX + Vibe Coding Tutorial Series — Part 4: Exploring the Code Structure]]></title>
            <link>https://medium.com/@halimdirgantara/golang-htmx-vibe-coding-tutorial-series-part-4-exploring-the-code-structure-9ebd4a977842?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ebd4a977842</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 02:02:34 GMT</pubDate>
            <atom:updated>2025-10-14T02:02:34.077Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang + HTMX + Vibe Coding Tutorial Series — Part 4: Exploring the Code Structure</h3><blockquote>In the <a href="https://medium.com/@halimdirgantara/golang-project-setup-with-claude-code-and-vibe-coding-part-3-cab0f8d90844">last part</a>, we officially brought our project to life.<br> We set up the folder, initialized Git, installed Claude Code, and watched as the AI generated a complete scaffolding — directory by directory, file by file.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*fMzmJbRFW3QSz2F7pmpemw.png" /></figure><p>Now it’s time to open the box and look inside.<br> This is where we start seeing the shape of our Golang app — not just lines of code, but a full ecosystem built from the plan we made in <strong>Part 2</strong> and <strong>Part 3</strong>.</p><p>We’re not coding yet. We’re exploring, understanding the foundation. Before we dive into development, it’s essential to see <em>how</em> Claude Code translated our documentation into a working architecture — because structure determines how the app will grow.</p><h3>The First Look</h3><p>When I first ran tree inside the project, I honestly smiled.<br>Claude didn’t just dump files — it created a clean, layered structure that makes sense from both a developer and architect’s point of view.</p><p>Every folder had a clear purpose.<br>Every file followed a naming rule and logical order.<br>It felt like opening a well-maintained open-source project, except this one was created collaboratively between human intention and AI precision.</p><p>Here’s the core layout we’re working with:</p><pre>golang-company-site/<br>├── cmd/<br>├── internal/<br>├── web/<br>├── database/<br>├── uploads/<br>├── tests/<br>├── docs/<br>└── scripts/</pre><p>Each folder represents a major subsystem of the app — from where the program starts, to how the frontend pages are rendered.<br> Let’s walk through each one and see how the puzzle fits together.</p><h3>/cmd — Where Everything Starts</h3><p>In Go convention, the /cmd directory is home to application entry points.<br> Each subfolder represents a separate executable.<br> Claude generated three of them — each with its own purpose:</p><ul><li><strong>cmd/server/</strong> — runs the main web server</li><li><strong>cmd/migrate/</strong> — handles database migrations</li><li><strong>cmd/seed/</strong> — loads initial seed data</li></ul><p>This approach lets us run and maintain different executables independently.<br>When we execute go run cmd/server/main.go, the Gin-based web server spins up.<br>When we run go run cmd/migrate/main.go, it applies all SQL migrations.<br>Need to reload data? Just run go run cmd/seed/main.go.</p><p>That’s the magic of modular design — simple, flexible, and scalable as our system grows.<br>We can extend these tools later (e.g., add CLI commands for backup, testing, or deployment) without touching the main app logic.</p><h3>/internal — The Core of the Application</h3><p>If /cmd is the engine starter, /internal is the heart that keeps everything alive.<br>It contains all the business logic, database handling, middleware, and utility code that powers the entire app.</p><p>Let’s unpack it layer by layer.</p><h4>internal/config — Configuration Management</h4><p>This folder is our configuration brain.<br> Files like config.go and env.go load environment variables for the app — database credentials, JWT secrets, ports, caching options, and so on.</p><p>Instead of hard-coding anything, we make everything dynamic and environment-driven.<br> That means switching between development, staging, and production is as easy as editing a .env file.</p><h4>How It Works</h4><p>The main file internal/config/config.go defines a Config struct — a single place that holds all environment settings, grouped into 10 logical sections:</p><pre>type Config struct {<br>	App       AppConfig<br>	Database  DatabaseConfig<br>	JWT       JWTConfig<br>	Security  SecurityConfig<br>	Upload    UploadConfig<br>	SMTP      SMTPConfig<br>	Session   SessionConfig<br>	RateLimit RateLimitConfig<br>	Log       LogConfig<br>	Cache     CacheConfig<br>}</pre><p>Each section represents a subsystem:</p><ul><li>App — Application name, environment, and port</li><li>Database — MySQL connection and pooling</li><li>JWT — Token secret and expiration</li><li>Security — Bcrypt cost and login lockout settings</li><li>Upload — Allowed file types and maximum file sizes</li><li>SMTP — Email server configuration</li><li>Session — Cookie and session management settings</li><li>RateLimit — API request throttling rules</li><li>Log — Logging verbosity or level</li></ul><h4>Loading Configuration</h4><p>The LoadConfig() function does the heavy lifting.<br> It loads .env with <strong>godotenv</strong>, applies defaults if missing, validates critical values, and stops the app if something essential (like JWT_SECRET or DB_HOST) is missing.</p><p>If you haven’t yet, create a simple .env file in your root folder:</p><pre># Application Configuration<br>APP_ENV=development<br>APP_PORT=8080<br>APP_URL=http://localhost:8080<br>APP_NAME=Company Website<br><br># Database Configuration<br>DB_HOST=localhost<br>DB_PORT=3306<br>DB_NAME=company_website<br>DB_USER=root<br>DB_PASSWORD=password<br>DB_MAX_OPEN_CONNS=25<br>DB_MAX_IDLE_CONNS=5<br>DB_CONN_MAX_LIFETIME=5m<br><br># JWT Configuration<br>JWT_SECRET=change-this-to-a-secure-random-string-in-production<br>JWT_EXPIRY=24h<br>JWT_REFRESH_EXPIRY=168h<br><br># Security<br>BCRYPT_COST=12<br>MAX_LOGIN_ATTEMPTS=5<br>LOCKOUT_DURATION=15m<br><br># File Upload Configuration<br>MAX_UPLOAD_SIZE=10485760<br>UPLOAD_PATH=./uploads<br>ALLOWED_IMAGE_TYPES=image/jpeg,image/png,image/gif,image/webp<br>ALLOWED_DOCUMENT_TYPES=application/pdf<br><br># Email Configuration (SMTP)<br>SMTP_HOST=smtp.gmail.com<br>SMTP_PORT=587<br>SMTP_USER=your-email@gmail.com<br>SMTP_PASSWORD=your-app-password<br>SMTP_FROM_NAME=Company Website<br>SMTP_FROM_EMAIL=noreply@company.com<br><br># Session Configuration<br>SESSION_SECRET=change-this-to-a-secure-random-string<br>SESSION_MAX_AGE=86400<br><br># Rate Limiting<br>RATE_LIMIT_ENABLED=true<br>RATE_LIMIT_REQUESTS=100<br>RATE_LIMIT_DURATION=1m<br><br># Logging<br>LOG_LEVEL=debug<br>LOG_FORMAT=json<br><br># Pagination<br>DEFAULT_PAGE_SIZE=10<br>MAX_PAGE_SIZE=100<br><br># Cache<br>CACHE_ENABLED=false<br>CACHE_TTL=3600</pre><h4>Internal/database — Database Connection &amp; Pooling</h4><p>Once configuration is loaded, the next layer handles database connection and management.</p><p>Claude built this around <strong>GORM</strong>, the popular Go ORM for MySQL.</p><p>The main file internal/database/database.go provides three key functions:</p><ol><li><strong>InitDatabase()</strong> — sets up a GORM connection</li><li><strong>CloseDatabase()</strong> — closes the SQL connection gracefully</li><li><strong>GetDB()</strong> — gives shared access to the DB instance</li></ol><p>Connection pooling and retry logic are built-in.</p><p>Example snippet:</p><pre>// InitDatabase initializes database connection with GORM<br>func InitDatabase(cfg *config.Config) error {<br> dsn := fmt.Sprintf(&quot;%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&amp;parseTime=True&amp;loc=Local&quot;,<br>  cfg.Database.User,<br>  cfg.Database.Password,<br>  cfg.Database.Host,<br>  cfg.Database.Port,<br>  cfg.Database.Name,<br> )<br><br> // Configure GORM logger based on environment<br> var gormLogger logger.Interface<br> if cfg.App.Env == &quot;production&quot; {<br>  gormLogger = logger.Default.LogMode(logger.Error)<br> } else {<br>  gormLogger = logger.Default.LogMode(logger.Info)<br> }<br><br> // Open database connection<br> db, err := gorm.Open(mysql.Open(dsn), &amp;gorm.Config{<br>  Logger: gormLogger,<br>  NowFunc: func() time.Time {<br>   return time.Now().UTC()<br>  },<br> })<br><br> if err != nil {<br>  return fmt.Errorf(&quot;failed to connect to database: %w&quot;, err)<br> }<br><br> // Get underlying SQL database<br> sqlDB, err := db.DB()<br> if err != nil {<br>  return fmt.Errorf(&quot;failed to get database instance: %w&quot;, err)<br> }<br><br> // Set connection pool settings<br> sqlDB.SetMaxOpenConns(cfg.Database.MaxOpenConns)<br> sqlDB.SetMaxIdleConns(cfg.Database.MaxIdleConns)<br> sqlDB.SetConnMaxLifetime(cfg.Database.ConnMaxLifetime)<br><br> // Test connection<br> if err := sqlDB.Ping(); err != nil {<br>  return fmt.Errorf(&quot;failed to ping database: %w&quot;, err)<br> }<br><br> DB = db<br> log.Println(&quot;✓ Database connected successfully&quot;)<br> return nil<br>}</pre><h4>internal/models — Database Models</h4><p>This is where our data takes shape.<br> All 25 entities from our ERD are implemented here: user.go, post.go, product.go, page.go, and many more.</p><p>Each model has:</p><ul><li>GORM tags</li><li>Soft delete (deleted_at)</li><li>Auto timestamps (created_at, updated_at)</li><li>Relationships (belongs-to, has-many, self-referencing)</li></ul><p>Hierarchical tables like <strong>Pages</strong>, <strong>Categories</strong>, and <strong>OrganizationalStructure</strong> use self-referencing parent_id for nested data.</p><p>These models are our foundation — the structural DNA of the app.</p><h4>internal/repositories — Data Access Layer</h4><p>Repositories provide a clean separation between services and the database.</p><p>Each file handles one entity:</p><ul><li>user_repository.go</li><li>post_repository.go</li><li>category_repository.go</li><li>and so on.</li></ul><p>Instead of calling SQL directly, we route everything through repositories — making it easy to refactor or change the database engine later.</p><p>Example:</p><pre>// NewUserRepository creates a new instance of UserRepository using the provided GORM database connection.<br>func NewUserRepository(db *gorm.DB) UserRepository {<br> return &amp;userRepository{db: db}<br>}<br><br>// Create inserts a new user into the database.<br>// It returns an error if the insertion fails.<br>func (r *userRepository) Create(user *models.User) error {<br> return r.db.Create(user).Error<br>}<br><br>// GetByID retrieves a user from the database by their unique ID.<br>// It returns the user and a nil error if found.<br>// If the user is not found, it returns a &quot;user not found&quot; error.<br>// Any other database error is returned as-is.<br>func (r *userRepository) GetByID(id uint) (*models.User, error) {<br> var user models.User<br> err := r.db.First(&amp;user, id).Error<br> if err != nil {<br>  if errors.Is(err, gorm.ErrRecordNotFound) {<br>   return nil, errors.New(&quot;user not found&quot;)<br>  }<br>  return nil, err<br> }<br> return &amp;user, nil<br>}</pre><p>That’s clean, testable, and ready for scale.</p><h4>internal/services — Business Logic</h4><p>This is where decisions happen.<br> Services sit between repositories and handlers, managing workflows like login, password reset, or post publishing.</p><p>Let’s take auth_service.go as the best example.</p><p>It manages the full authentication process:</p><ol><li>Fetch user by email</li><li>Check lockout state</li><li>Verify password</li><li>Increment failed attempts</li><li>Lock after 5 failures</li><li>Generate JWT</li><li>Return token and sanitized user</li></ol><p>JWT generation:</p><pre>// GenerateToken creates a new JWT (JSON Web Token) for the given user.<br>// The token includes custom claims (user ID, username, email, and role) and standard JWT claims<br>// such as expiration time, issued at, and not before timestamps.<br>// It signs the token using the HS256 algorithm and the secret key from the service configuration.<br>// Returns the signed token string or an error if signing fails.<br>func (s *authService) GenerateToken(user *models.User) (string, error) {<br> claims := JWTClaims{<br>  UserID:   user.ID,<br>  Username: user.Username,<br>  Email:    user.Email,<br>  Role:     user.Role,<br>  RegisteredClaims: jwt.RegisteredClaims{<br>   ExpiresAt: jwt.NewNumericDate(time.Now().Add(s.config.JWT.Expiry)),<br>   IssuedAt:  jwt.NewNumericDate(time.Now()),<br>   NotBefore: jwt.NewNumericDate(time.Now()),<br>  },<br> }<br><br> token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)<br> tokenString, err := token.SignedString([]byte(s.config.JWT.Secret))<br> if err != nil {<br>  return &quot;&quot;, err<br> }<br><br> return tokenString, nil<br>}</pre><p>It’s a complete, secure system out of the box — and fully extensible.</p><h4>internal/middleware — Security Layer</h4><p>Middleware keeps everything secure and stable.</p><ul><li>auth_middleware.go verifies JWT tokens and attaches user data to the request context.</li><li>role_middleware.go checks if the user has permission to access a specific route.</li></ul><p>Together, they enforce both <strong>authentication</strong> and <strong>authorization</strong> seamlessly.</p><h4>internal/handlers — HTTP Controllers</h4><p>Handlers are the “public face” of the backend.<br> They connect incoming requests to services and send structured JSON responses.</p><p>Example: auth_handler.go</p><ul><li>POST /api/auth/login — logs in</li><li>POST /api/auth/logout — logs out</li><li>GET /api/profile — returns user info</li></ul><p>Try it:</p><pre>curl -X POST http://localhost:8080/api/auth/login \<br>-H &quot;Content-Type: application/json&quot; \<br>-d &#39;{&quot;email&quot;:&quot;admin@demo.com&quot;,&quot;password&quot;:&quot;password&quot;}&#39;</pre><p>If everything is working, you’ll get your first JWT token response.</p><h3>/web — Templates and Static Assets</h3><p>This is where backend meets frontend.<br> Claude built a structure similar to Blade or Django templates, powered by <strong>HTMX</strong> and <strong>Alpine.js</strong>.</p><pre>web/<br>├── templates/<br>│   ├── layouts/<br>│   ├── partials/<br>│   ├── admin/<br>│   └── public/<br>└── static/<br>    ├── css/<br>    ├── js/<br>    └── images/</pre><p>With <strong>TailwindCSS</strong> for styling and <strong>HTMX</strong> for dynamic HTML swapping, we get an interactive interface without a heavy frontend framework.</p><p>That’s modern simplicity — Go-powered backend, HTML-first UI.</p><h4>/database, /uploads, /tests, /docs, /scripts</h4><p>These supporting folders complete the picture:</p><ul><li>/database/ → migrations &amp; seeds</li><li>/uploads/ → media uploads</li><li>/tests/ → unit and integration tests</li><li>/docs/ → technical documentation</li><li>/scripts/ → deployment utilities</li></ul><p>They may look secondary, but they make the app maintainable long-term.</p><h3>How It All Connects</h3><p>The entire app follows a clear pattern:</p><pre>Handler → Service → Repository → Database</pre><p>Each layer does one job, and one job only.<br> It’s the same clean architecture used by large-scale Go systems — only here, it was generated in minutes, not weeks, through guided AI collaboration.</p><h3>What’s Working Now</h3><p>At this point, we already have a functional backend:</p><ul><li>Configuration management</li><li>Database connection</li><li>25 data models</li><li>JWT-based authentication</li><li>Middleware &amp; access control</li><li>Modular route handling</li><li>Graceful shutdown</li></ul><p>You can run the app right now:</p><pre>go run cmd/server/main.go</pre><p>and start hitting /api/auth/login and /api/profile endpoints.</p><h3>What’s Next</h3><p>Now that we’ve mapped out how everything connects — from configuration to authentication — the next step is bringing the <strong>admin panel</strong> to life.</p><p>In <strong>Part 5</strong>, we’ll connect backend logic to HTMX-powered templates, display dynamic data, and finally make this application feel alive.</p><blockquote>All supporting docs (SRS, ERD, CLAUDE.md, and project tree) will be shared progressively — so make sure you follow this series to stay updated.</blockquote><p>👉 <strong>Follow the series</strong> — we’re just getting started. The real coding begins next.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ebd4a977842" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang Project Setup with Claude Code and Vibe Coding (Part 3)]]></title>
            <link>https://medium.com/@halimdirgantara/golang-project-setup-with-claude-code-and-vibe-coding-part-3-cab0f8d90844?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cab0f8d90844</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 02:02:19 GMT</pubDate>
            <atom:updated>2025-10-09T21:57:09.357Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang + HTMX + Vibe Coding Tutorial Series — Part 3: Project Setup &amp; Architecture</h3><blockquote>In the <a href="https://medium.com/@halimdirgantara/golang-htmx-vibe-coding-tutorial-series-part-2-planning-the-company-website-cb2c48d21e3d">previous stories</a>, we already defined the <em>why</em> and the <em>plan.</em><br> We started this journey to build a real company website using <strong>Golang</strong>, <strong>HTMX</strong>, and <strong>TailwindCSS</strong>, powered by <strong>Vibe Coding</strong> — my way of combining human logic with AI assistance.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*Z8k449HMWYi3nUoYDOmMHw.png" /></figure><p>We also built the foundation:</p><ul><li>A complete <strong>SRS document</strong></li><li>A <strong>database design (ERD)</strong></li><li>And a <strong>development to-do list</strong> that maps our entire roadmap</li></ul><p>Now, we’ll start collaborating with AI to build our application — beginning with setting up the folder, initializing Git, and preparing <strong>Claude Code</strong>, the tool that will accompany us throughout this series.</p><h4>Step 1 — Creating the Base Project</h4><p>Open your terminal and create a new folder for the project:</p><pre>mkdir golang-company-site<br>cd golang-company-site<br>git init</pre><blockquote>This folder will be the root of our entire project — where all the documentation, code, and AI-generated scaffolding will live together.</blockquote><p>From day one, I always prefer to start with <strong>Git</strong>.<br> Not because it’s cool, but because it creates a timeline. Every commit is a small story — a snapshot of how the project evolves.</p><h4>Step 2 — Bringing in the Planning Documents</h4><p>Before writing a single line of Go code, I want the <strong>plan</strong> to live inside the same repository.</p><p>I Upload all docs we made earlier to this project folder and add everything to version control:</p><pre>git add .<br>git commit -m &quot;feat: specification and to do list&quot;</pre><blockquote>Anyone who clones this repo can immediately see the thought process behind every file we’re going to build.</blockquote><p>This step might look small, but it’s symbolic — it’s like placing the project’s blueprint right beside the toolbox.</p><h4>Step 3 — Installing Claude Code</h4><p>Now, it’s time to prepare <strong>Claude Code</strong>, the AI tool that will assist in our Vibe Coding workflow.</p><p>This is the same tool we’ve been using to generate planning documents, but now we’ll integrate it <em>directly into our development process.</em></p><p><strong>Prerequisites</strong></p><ul><li><a href="https://nodejs.org/en/download/">Node.js 18 or newer</a></li><li>A <a href="https://claude.ai/">Claude.ai</a> (recommended) or <a href="https://console.anthropic.com/">Claude Console</a> account</li></ul><p><strong>Installation</strong></p><pre># Install Claude Code<br>npm install -g @anthropic-ai/claude-code<br><br># Navigate to your project<br>cd golang-company-site<br><br># Start coding with Claude<br>claude<br># You&#39;ll be prompted to log in on first use</pre><p>You can find complete reference in this <a href="https://docs.claude.com/en/docs/claude-code/overview#install-and-authenticate">Claude Code Docs</a> .</p><p>The goal here is simple:<br> I want <strong>Claude</strong> to work from the terminal, just like git or go.<br> When I type claude, it should open an interactive shell where I can talk to AI directly inside my workspace.</p><p>This is where <strong>Vibe Coding</strong> truly begins — a workflow where I guide the AI with intent, and it responds with structured code.</p><h4>Step 4 — Creating the First README.md</h4><p>Once everything’s installed, I open the terminal and type:</p><pre>claude</pre><p>Inside Claude’s shell, I give this command:</p><pre>Create README.md based on company-website-plan.md, erd-documentation.md, srs-company-website.md, and development-todolist.md</pre><p>Claude then generates the very first document for the project — a clean, human-readable README.md.</p><p>It might look simple — a few files, a new folder, a blank README.<br>But this is where the project starts to feel alive.<br>From here on, every command we type and every AI-generated line of code becomes part of a shared story between human logic and machine assistance.</p><h4>Step 5 — Initializing with /init Command</h4><p>Next, I run this command /init to Initialize project with CLAUDE.md guide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*TGUsqoBr_QJ2zHoIl1Basg.png" /><figcaption>claude initialize project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*npAXO1IscMNiLYhbQf4t9w.png" /><figcaption>claude reading project folder</figcaption></figure><p>Claude reads the folder, analyzes the context, and asks permission to create CLAUDE.md.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*4EkB3rZzzT-RjSmIxWgk6g.png" /></figure><p>Usually, I choose:</p><blockquote><strong><em>Option 2: Yes, allow all edits during this session</em></strong></blockquote><p>After that, the message appears:<br> ✅ CLAUDE.md created</p><p>And just like that, the project now has its own living guide — a document that helps Claude remember the project’s purpose, stack, and conventions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*NmvYn9xyaoPF7X13I66fng.png" /><figcaption>CLAUDE.m created</figcaption></figure><p>And just like that, the project now has its own living guide — a document that helps Claude remember the project’s purpose, stack, and conventions.</p><h4>The Magic Moment — Letting Claude Build</h4><p>Now comes the fun part.<br>We’ll give Claude a command to start working based on our to-do list:</p><pre>Based on @development-todolist.md, run PHASE 1: PROJECT SETUP &amp; FOUNDATION</pre><p>Before running, switch to <strong>Plan Mode</strong> (Shift + Tab in Linux Mint; your shortcut may differ).</p><p>Claude may ask permission to run code. Example:</p><pre>Bash command:<br>go version 2&gt;&amp;1 || echo &quot;Go not installed&quot;<br>Do you want to proceed?<br>1. Yes<br>2. Yes, and don&#39;t ask again<br>3. No, and tell Claude what to do differently</pre><p>After confirming, Claude presents a detailed implementation plan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*Fd8N6R5Nmd-eUdSnug0pzQ.png" /><figcaption>Claude Plan’s</figcaption></figure><p>And It will ask to proceed the plan.</p><pre>Would you like to proceed?<br>1. Yes, and auto-accept edits<br>2. Yes, and manually approve edits<br>3. No, keep planning</pre><p>At this point, you can choose to <strong>keep planning</strong> if you want to adjust something — or just let Claude do its job automatically.</p><h4>Choosing the Framework</h4><p>In my case, Claude suggested using the <strong>Fiber</strong> framework.<br> But after a bit of research, I decided to use <strong>Gin</strong> instead.</p><p>So I replied:</p><pre>I want to use Gin for the framework because of its compatibility and community support. What do you think?</pre><p>Claude responded with a detailed comparison — and agreed Gin was the better fit.<br> That’s the essence of <strong>Vibe Coding</strong>: the AI suggests, you decide.</p><p>Finally, I approved:</p><blockquote><strong><em>Option 1: Yes, and auto-accept edits</em></strong></blockquote><p>And Claude began generating the project foundation:<br>Directory structure, Go modules, migrations, and boilerplate code.</p><p>And honestly, this is where <strong>Vibe Coding</strong> really shines.<br>We’re not typing every line manually — we’re orchestrating.<br>We act as the project architect, reviewing and guiding what the AI builds.</p><p>But remember: you still need programming skill.<br>Without a proper understanding of structure, logic, and syntax, AI alone won’t get you far.<br>It’s not about letting AI code <em>for</em> you — it’s about coding <em>with</em> AI.<br> You’re still the architect — AI just moves the bricks faster.</p><h4>Reviewing the Generated Code</h4><p>Now, we can test the code manually using Claude’s testing guide.<br> I start by exploring the project tree to understand how everything connects.</p><pre>golang-company-site/<br>│<br>├── cmd/                                    # Application entry points<br>│   ├── server/                            # Main web server<br>│   │   └── main.go                        # Server initialization and startup<br>│   ├── migrate/                           # Database migration tool<br>│   │   └── main.go                        # Migration command handler<br>│   └── seed/                              # Data seeding tool<br>│       └── main.go                        # Seed data loader<br>│<br>├── internal/                              # Private application code<br>│   ├── config/                            # Configuration management<br>│   │   ├── config.go                      # Config struct and loader<br>│   │   └── env.go                         # Environment variable parser<br>│   │<br>│   ├── database/                          # Database infrastructure<br>│   │   ├── connection.go                  # DB connection and pooling<br>│   │   └── migrate.go                     # Migration runner<br>│   │<br>│   ├── models/                            # GORM data models (25 tables)<br>│   │   ├── user.go                        # Users model<br>│   │   ├── post.go                        # Posts model<br>│   │   ├── page.go                        # Pages model (hierarchical)<br>│   │   ├── category.go                    # Categories model (hierarchical)<br>│   │   ├── tag.go                         # Tags model<br>│   │   ├── post_category.go               # PostCategories junction<br>│   │   ├── post_tag.go                    # PostTags junction<br>│   │   ├── post_revision.go               # PostRevisions version control<br>│   │   ├── page_revision.go               # PageRevisions version control<br>│   │   ├── product.go                     # Products model<br>│   │   ├── product_category.go            # ProductCategories (hierarchical)<br>│   │   ├── product_gallery.go             # ProductGallery images<br>│   │   ├── project.go                     # Projects model<br>│   │   ├── project_gallery.go             # ProjectGallery images<br>│   │   ├── report.go                      # Reports model<br>│   │   ├── report_category.go             # ReportCategories<br>│   │   ├── company_profile.go             # CompanyProfile (single row)<br>│   │   ├── company_contact.go             # CompanyContacts (dynamic)<br>│   │   ├── social_media_link.go           # SocialMediaLinks<br>│   │   ├── organizational_structure.go    # OrganizationalStructure (hierarchical)<br>│   │   ├── media_file.go                  # MediaFiles library<br>│   │   ├── contact.go                     # Contacts form submissions<br>│   │   ├── newsletter_subscription.go     # NewsletterSubscriptions<br>│   │   ├── setting.go                     # Settings key-value<br>│   │   └── activity_log.go                # ActivityLogs audit trail<br>│   │<br>│   ├── repositories/                      # Data access layer (repository pattern)<br>│   │   ├── user_repository.go<br>│   │   ├── post_repository.go<br>│   │   ├── page_repository.go<br>│   │   ├── category_repository.go<br>│   │   ├── tag_repository.go<br>│   │   ├── product_repository.go<br>│   │   ├── product_category_repository.go<br>│   │   ├── project_repository.go<br>│   │   ├── report_repository.go<br>│   │   ├── company_profile_repository.go<br>│   │   ├── company_contact_repository.go<br>│   │   ├── social_media_repository.go<br>│   │   ├── organizational_structure_repository.go<br>│   │   ├── media_file_repository.go<br>│   │   ├── contact_repository.go<br>│   │   ├── newsletter_repository.go<br>│   │   ├── setting_repository.go<br>│   │   └── activity_log_repository.go<br>│   │<br>│   ├── services/                          # Business logic layer<br>│   │   ├── auth_service.go                # Authentication &amp; JWT<br>│   │   ├── user_service.go<br>│   │   ├── post_service.go<br>│   │   ├── page_service.go<br>│   │   ├── category_service.go<br>│   │   ├── tag_service.go<br>│   │   ├── product_service.go<br>│   │   ├── project_service.go<br>│   │   ├── report_service.go<br>│   │   ├── company_service.go             # Company profile &amp; contacts<br>│   │   ├── media_service.go               # File upload &amp; management<br>│   │   ├── contact_service.go<br>│   │   ├── newsletter_service.go<br>│   │   ├── setting_service.go<br>│   │   └── activity_log_service.go<br>│   │<br>│   ├── handlers/                          # HTTP handlers (controllers)<br>│   │   ├── auth_handler.go                # Login, logout, register<br>│   │   ├── admin/                         # Admin panel handlers<br>│   │   │   ├── dashboard_handler.go<br>│   │   │   ├── user_handler.go<br>│   │   │   ├── post_handler.go<br>│   │   │   ├── page_handler.go<br>│   │   │   ├── category_handler.go<br>│   │   │   ├── tag_handler.go<br>│   │   │   ├── product_handler.go<br>│   │   │   ├── project_handler.go<br>│   │   │   ├── report_handler.go<br>│   │   │   ├── company_handler.go<br>│   │   │   ├── media_handler.go<br>│   │   │   ├── contact_handler.go<br>│   │   │   ├── newsletter_handler.go<br>│   │   │   ├── setting_handler.go<br>│   │   │   └── activity_log_handler.go<br>│   │   └── public/                        # Public frontend handlers<br>│   │       ├── home_handler.go<br>│   │       ├── about_handler.go<br>│   │       ├── news_handler.go<br>│   │       ├── product_handler.go<br>│   │       ├── project_handler.go<br>│   │       ├── report_handler.go<br>│   │       └── contact_handler.go<br>│   │<br>│   ├── middleware/                        # HTTP middleware<br>│   │   ├── auth.go                        # JWT authentication<br>│   │   ├── role.go                        # Role-based access control<br>│   │   ├── csrf.go                        # CSRF protection<br>│   │   ├── rate_limit.go                  # Rate limiting<br>│   │   ├── logger.go                      # Request logging<br>│   │   ├── cors.go                        # CORS headers<br>│   │   └── security.go                    # Security headers<br>│   │<br>│   ├── validators/                        # Input validation<br>│   │   ├── user_validator.go<br>│   │   ├── post_validator.go<br>│   │   ├── page_validator.go<br>│   │   ├── product_validator.go<br>│   │   ├── contact_validator.go<br>│   │   └── file_validator.go<br>│   │<br>│   └── utils/                             # Utility functions<br>│       ├── password.go                    # Bcrypt hashing<br>│       ├── jwt.go                         # JWT generation/validation<br>│       ├── slug.go                        # URL slug generation<br>│       ├── sanitize.go                    # HTML sanitization<br>│       ├── pagination.go                  # Pagination helper<br>│       ├── file.go                         # File upload utilities<br>│       └── response.go                     # HTTP response helpers<br>│<br>├── web/                                   # Frontend assets<br>│   ├── templates/<br>│   └── static/<br>│<br>├── uploads/                               # User uploaded files<br>├── database/                              # SQL migrations and seeds<br>├── tests/                                 # Unit, integration, and e2e tests<br>├── docs/                                  # Documentation<br>├── scripts/                               # Utility scripts<br>│<br>├── .env.example<br>├── .gitignore<br>├── go.mod<br>├── Dockerfile<br>├── Makefile<br>├── README.md<br>├── CLAUDE.md<br>└── tree-app.md</pre><blockquote>Looking at this structure, I can already see how well it scales — admin and public layers separated, clear business logic boundaries, and consistent naming.<br>It’s the kind of structure that makes future maintenance feel easier before a single feature is added.</blockquote><h4>Final Reflection</h4><p>At this point, the foundation feels real.<br> We’ve got a full structure, proper conventions, and a working base that’s clean enough to scale.</p><p>In the next part, we’ll explore <strong>main components and core logic</strong> — configuration, database connection, and authentication.<br> That’s when the pieces start clicking together.</p><p>All the project documents, plans, and generated code will also be shared throughout this series, so make sure to follow each part to stay in sync.<br> Stay tuned — the real coding begins soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cab0f8d90844" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang + HTMX + Vibe Coding Tutorial Series — Part 2: Planning the Company Website]]></title>
            <link>https://medium.com/@halimdirgantara/golang-htmx-vibe-coding-tutorial-series-part-2-planning-the-company-website-cb2c48d21e3d?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb2c48d21e3d</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Tue, 07 Oct 2025 02:01:53 GMT</pubDate>
            <atom:updated>2025-10-09T21:56:48.623Z</atom:updated>
            <content:encoded><![CDATA[<h3>Golang + HTMX + Vibe Coding Tutorial Series — Part 2: Planning the Company Website</h3><blockquote>“Every great app starts not with code, but with a plan. If you jump straight into coding, you’ll often regret it later.”</blockquote><p>In the <a href="https://medium.com/@halimdirgantara/building-a-company-website-with-golang-htmx-and-vibe-coding-kickoff-story-dccf7473fdd9">previous story</a>, I shared why I wanted to build a company website from scratch using <strong>Golang, HTMX, TailwindCSS</strong>, and <strong>Vibe Coding</strong> powered by AI tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*LfIXCcMy-OoiaKdnfoDrBw.png" /></figure><p>Now it’s time to take the next step. This article isn’t about migrations or commands yet. It’s about answering the right questions, setting boundaries, and defining what we want to build.</p><p>Once the plan is clear, we’ll bring in Claude Code (Sonnet 4.5) with Vibe Coding to generate the initial scaffolding.</p><h3>Why I’m Using Claude Code for Vibe Coding</h3><p>Before we go deeper, let me explain why I chose <strong>Claude Code Sonnet 4.5</strong> as part of this journey:</p><ul><li><strong>Latest model with strong context window</strong> → it can process large planning documents and generate structured code output.</li><li><strong>Vibe Coding efficiency</strong> → instead of writing repetitive boilerplate, I let Claude generate migrations, GORM models, and handlers. I still review and adjust the results.</li><li><strong>High-quality scaffolding</strong> → it produces cleaner, more consistent Golang code compared to many other tools.</li><li><strong>My role stays the same</strong> → I’m still the architect. AI just saves time on the typing part.</li></ul><p>This is why I say Vibe Coding isn’t just “AI writing code for you.” It’s <strong>pair programming with AI</strong> where the developer stays in control.</p><h4><strong>Before we go further, I should emphasize something:</strong></h4><blockquote>I’m a beginner with Golang. I don’t come into this project as a seasoned Go developer. But with years of programming experience in other stacks, I understand the logic, the flow, and the way systems need to be structured. That’s where AI becomes a huge advantage. Instead of struggling with every syntax detail, I can focus on architecture and design decisions, while letting Claude help me generate the boilerplate code. In other words, I’m <strong>learning Golang while building something real</strong> — and AI is the accelerator that makes it possible.</blockquote><h3>Defining Scope: 5 Key Questions for Our Golang Website</h3><p>When I asked Claude to help generate a design document, I first told it to give me <strong>five key questions</strong> to clarify the scope. These are the questions it gave me:</p><p><strong>1. Application Type and Purpose</strong></p><ul><li>What type of web application do you want to build? (e.g., internal management system, e-commerce, employee portal, CRM, analytics dashboard, etc.)</li><li>What is the primary objective and what business problems are you aiming to solve?</li></ul><p><strong>2. Features and Functionalities</strong></p><ul><li>What are the core features that must be included in the application.</li><li>Do you require multi-level authentication and authorization (admin, user, manager, etc.)?</li></ul><p><strong>3. Scale and Performance Requirements</strong></p><ul><li>What is the estimated number of users expected to use the application?</li><li>Should the app be designed for high traffic, or is medium-scale usage enough?</li></ul><p><strong>4. Integrations and Technology Stack</strong></p><ul><li>Do you need integration with external systems or services (APIs, payment gateways, email services)?</li><li>Which database do you prefer (PostgreSQL, MySQL, MongoDB)?</li></ul><p><strong>5. Deployment and Infrastructure</strong></p><ul><li>Where will the app be deployed (Cloud, on-premise, Docker/Kubernetes)?</li><li>Are there specific security or compliance requirements (ISO, GDPR, audit logs)?</li></ul><h3>Answering the Scope Questions</h3><p>Here’s how I replied:</p><ul><li><strong>Application type:</strong> A corporate main website, including company profile, organizational structure, vision and mission, programs, news, reports, and promotion of main products along with the latest updates.</li><li><strong>Features:</strong> Multi-level user roles → Admin, Editor, Operator, User.</li><li><strong>Scale:</strong> Medium → ~200–500 users is enough.</li><li><strong>Database:</strong> MySQL (no external integrations needed).</li><li><strong>Deployment:</strong> Flexible, with standard security (JWT, bcrypt, HTTPS).</li></ul><p>From this input, Claude generated what it calls a <strong>“Company Website Application Design Document.”</strong></p><p>And this is the outline from Claude:</p><p>✅ <strong>Planning &amp; Analysis</strong></p><ul><li>Executive summary</li><li>Functional and non-functional requirements analysis</li><li>Complete system architecture</li><li>Project timeline and cost estimation</li></ul><p>✅ <strong>Technical Design</strong></p><ul><li>Database ERD with 15+ tables</li><li>Golang project folder structure</li><li>Design patterns (MVC, Repository)</li><li>Complete API specifications</li></ul><p>✅ <strong>Implementation Guide</strong></p><ul><li>Sample code for all layers (Model, Repository, Service, Handler)</li><li>Middleware implementation (Authentication, CORS, Rate Limiting)</li><li>File upload handling, slug generator, pagination helpers</li><li>Frontend template examples</li></ul><p>✅ <strong>Security &amp; Performance</strong></p><ul><li>Security best practices and checklist</li><li>JWT authentication implementation</li><li>Rate limiting and CORS configuration</li><li>Performance optimization strategies</li></ul><p>✅ <strong>DevOps &amp; Deployment</strong></p><ul><li>Docker configuration</li><li>CI/CD pipeline (GitHub Actions)</li><li>Systemd service setup</li><li>Nginx reverse proxy configuration</li></ul><p>✅ <strong>Operations</strong></p><ul><li>Backup and recovery procedure</li><li>Monitoring and logging setup</li><li>Database maintenance scripts</li><li>Disaster recovery plan</li></ul><p>✅ <strong>Documentation</strong></p><ul><li>API documentation (Swagger)</li><li>User manuals</li><li>Troubleshooting guide</li><li>Training materials</li></ul><p>When I first read this, I realized something:<br> It’s far more detailed than what I initially expected from a single AI prompt. Claude didn’t just give me a table list — it produced an outline that feels like a <strong>mini software blueprint</strong>.</p><p>Of course, I don’t need all 40 sections right away. I won’t jump into CI/CD pipelines or disaster recovery on day one. But having this <strong>big picture map</strong> helps me see the path clearly. It means I can move step by step, choosing what to build now and what to postpone.</p><p>In other words: planning with AI doesn’t replace my judgment, but it gives me a head start.</p><h3>Starting with an SRS Document</h3><p>After defining the scope, I wanted something more formal. So I asked Claude to generate a <strong>Software Requirements Specification (SRS)</strong> document for the corporate website.</p><p>My prompt was simple:</p><blockquote><em>“Based on my requirements and the design document, generate a Software Requirements Specification (SRS) for a corporate website application, using HTMX and Alpine.js for the frontend, with dynamic posts that support categories and tags.”</em></blockquote><p>Here’s the high-level outline it produced, which reads more like a blueprint than a quick draft.</p><h3>SRS Document Summary</h3><p>The SRS contained <strong>15 main sections</strong>, structured like a real-world spec:</p><p>📋 <strong>Document Structure (15 Sections)</strong></p><ul><li><strong>Introduction</strong> → Purpose, scope, references</li><li><strong>Overall Description</strong> → Product perspective, constraints</li><li><strong>Functional Requirements</strong> → 20+ detailed functional points</li><li><strong>Non-Functional Requirements</strong> → Security, performance, reliability</li><li><strong>System Interfaces</strong> → UI/UX, API, external interfaces</li><li><strong>Data Requirements</strong> → Database schema, validation, retention</li><li><strong>Performance Requirements</strong> → Response times, capacity</li><li><strong>Security Requirements</strong> → Threats, mitigations, compliance</li><li><strong>User Requirements</strong> → Roles, permissions, workflows</li><li><strong>System Constraints</strong> → Technical and operational limits</li><li><strong>Assumptions &amp; Dependencies</strong> → What the system depends on</li><li><strong>Acceptance Criteria</strong> → What success looks like for public and admin modules</li><li><strong>Feature Prioritization</strong> → MoSCoW method (Must/Should/Could/Won’t have)</li><li><strong>Glossary</strong> → Definitions and acronyms</li><li><strong>Sign-off</strong> → Approval and version control</li></ul><p>This was more than I expected. Claude didn’t just create a list; it produced something that felt like a <strong>blueprint for stakeholders and devs</strong>.</p><h3>Asking for the Database Design</h3><p>The next step was clear: turn the SRS into something tangible.<br> I asked Claude:</p><blockquote><em>“Generate the database schema design based on this SRS so I can review it.”</em></blockquote><p>Claude produced an <strong>ERD-style design</strong> with around <strong>25 normalized tables</strong>.<br> Here are a few highlights:</p><pre>Users (<br>  id INT PRIMARY KEY,<br>  name VARCHAR(100),<br>  email VARCHAR(255) UNIQUE,<br>  password VARCHAR(255),<br>  role ENUM(&#39;admin&#39;,&#39;editor&#39;,&#39;operator&#39;,&#39;user&#39;),<br>  created_at TIMESTAMP<br>)</pre><p>Other tables included:</p><ul><li><strong>Posts</strong> → id, title, slug, content, published_at, author_id, category_id</li><li><strong>Pages</strong> → id, title, slug, content, parent_id</li><li><strong>Products</strong> → id, name, slug, description, price, created_at</li><li><strong>Projects</strong> → id, name, description, status, start_date, end_date</li><li><strong>Reports</strong> → id, title, file_path, year, published_at</li><li><strong>MediaFiles</strong> → id, file_name, file_path, mime_type, uploaded_by</li><li><strong>ActivityLogs</strong> → id, user_id, action, timestamp</li></ul><p>Indexes were suggested for slugs, published_at, and foreign keys.<br> This schema gave me the <strong>first real technical artifact</strong> I could actually review and refine.</p><h3>Turning Database Design into a Development Roadmap</h3><p>Finally, I wanted something practical: a roadmap.<br> So I asked Claude:</p><blockquote><em>“Generate a development to-do list from this database design and the SRS.”</em></blockquote><p>The output was exactly what I needed: a <strong>multi-week development plan</strong>.</p><p><strong>Phase Breakdown:</strong></p><ul><li><strong>Week 1</strong> → Environment setup, project structure, dependencies</li><li><strong>Week 2</strong> → Database migrations and authentication system</li><li><strong>Weeks 3–5</strong> → Core admin panel features (users, posts, pages, media)</li><li><strong>Weeks 6–7</strong> → Extended features (products, projects, reports, profile)</li><li><strong>Weeks 8–10</strong> → Public frontend with HTMX (homepage, posts, products, projects, contact)</li><li><strong>Weeks 11–12</strong> → Optimization (SEO, security, performance)</li><li><strong>Weeks 13–14</strong> → Deployment and launch</li></ul><p>This wasn’t just a checklist. It was like having a <strong>real project timeline</strong> that showed me what to prioritize.</p><h3>Reflection: MVP vs Nice-to-Haves</h3><p>Reading through the SRS, database schema, and to-do list, I realized something important: not all 40 sections need to be implemented right away.</p><blockquote>“If you’re following this series and building alongside me, here’s my advice: focus first on the MVP (auth, CRUD, public pages). Let advanced features like CI/CD and monitoring wait until later. Launch something usable fast, then iterate.”</blockquote><p>AI gives me the full map, but I’m still the one deciding which road to take first.</p><h3>Closing</h3><p>So far, here’s the journey:</p><ul><li>I asked Claude to create an <strong>SRS document</strong>.</li><li>From there, I asked it to generate the <strong>database design</strong>.</li><li>Finally, I had it generate a <strong>to-do list</strong> to guide the roadmap.</li></ul><p>This gives me a solid foundation: requirements, schema, and a clear set of tasks.</p><blockquote>All documentation and code will be shared and updated in the random part of this story series — so stay tuned.</blockquote><p>In the next part, we’ll finally dive into <strong>setting up the project in Golang</strong>, initialize the folder structure, and connect to MySQL with GORM.<br> That’s when Vibe Coding really starts — and we’ll see how AI scaffolding can save hours of setup work.</p><p>👉 If you’re following this series, make sure to <a href="https://medium.com/@halimdirgantara"><strong>follow me here on Medium</strong></a> so you don’t miss <strong>Part 3</strong>. That’s where the real coding begins.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb2c48d21e3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Company Website with Golang, HTMX, and Vibe Coding (Kickoff Story)]]></title>
            <link>https://medium.com/@halimdirgantara/building-a-company-website-with-golang-htmx-and-vibe-coding-kickoff-story-dccf7473fdd9?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dccf7473fdd9</guid>
            <category><![CDATA[htmx]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Thu, 02 Oct 2025 14:29:20 GMT</pubDate>
            <atom:updated>2025-10-09T21:56:15.830Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Every developer I know has at least once thought about building a <strong>company website from scratch</strong>. A site that isn’t just a landing page, but a complete hub: profile, products, projects, news, reports, and an admin panel to manage everything.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*lqFgmA24Omjg1zwY-ES-Kg.png" /></figure><p>That’s exactly what I’ll do in this series. I’ll walk you through the process of creating a <strong>scalable company website application</strong> with modern technologies: <strong>Golang, HTMX, Alpine.js, and TailwindCSS</strong>. But here’s the twist: I won’t do it alone. I’ll use <strong>AI coding assistants</strong> like <em>Vibe Code</em> and <em>Claude Code</em> to accelerate development.</p><p>Instead of writing boilerplate code manually, I’ll let AI generate migrations, models, and repetitive snippets. My role is to set the architecture, enforce structure, and optimize for security and SEO. This way, the project becomes both a <strong>practical Golang CMS tutorial</strong> and an exploration of how AI can improve developer workflow.</p><h3>Why Another Company Website Tutorial?</h3><p>You might ask: why not just use WordPress or any existing CMS? The short answer: <strong>performance, scalability, and control</strong>.</p><ul><li><strong>Fast and lightweight</strong>: Built with Go, server-side rendering, and HTMX for dynamic updates.</li><li><strong>SEO-optimized</strong>: Clean slugs, meta tags, and blazing-fast load times help content rank.</li><li><strong>Secure by design</strong>: JWT authentication, CSRF protection, and strict headers.</li><li><strong>Flexible</strong>: A normalized <strong>25-table MySQL schema</strong> makes content, products, and projects easy to manage.</li></ul><p>In short, this is a <strong>developer-first company website</strong> — not a bloated CMS, but a lean, secure, and maintainable application.</p><h3>How AI Fits into Development</h3><p>When I say I’ll use AI, I don’t mean handing over the whole project. Instead, I’ll use it like a coding partner:</p><ul><li><strong>For speed</strong>: generating boilerplate, migrations, and resource scaffolding.</li><li><strong>For ideas</strong>: quick suggestions, alternative patterns, and code improvements.</li><li><strong>For iteration</strong>: testing snippets, refactoring, and avoiding repetitive tasks.</li></ul><p>For example, when designing the database, I’ll outline the <strong>Users, Posts, Products, Projects, Reports</strong> tables, then let AI generate SQL migrations and GORM models. I’ll refine indexes, naming conventions, and constraints. The result: faster progress without sacrificing quality.</p><h3>The Roadmap for This Series</h3><p>This isn’t a single tutorial. It’s a complete learning path. Each article builds on the previous one, so by the end you’ll have a working, production-ready company website.</p><h3>Series Outline</h3><h4>Kickoff Story (this article)</h4><ul><li>Why we build this project</li><li>Why AI helps</li><li>What stack we’ll use</li></ul><h4>Project Setup &amp; Architecture</h4><ul><li>Initialize a Golang project (Gin/Fiber)</li><li>Set up folder structure with cmd/, internal/, and web/</li><li>Connect to MySQL with GORM</li></ul><h4>Database Design &amp; Migrations</h4><ul><li>Define 25+ MySQL tables for users, posts, products, projects, and reports</li><li>Write migrations and GORM models with AI support</li><li>Add indexing and constraints</li></ul><h4>Authentication &amp; Authorization</h4><ul><li>Implement JWT authentication in Golang</li><li>Role-based access (Admin, Editor, Operator, User)</li><li>Middleware for secure endpoints</li></ul><h4>Admin Panel Core</h4><ul><li>User and role management</li><li>Post management with categories and tags</li><li>Pages module for About, Mission, Vision, etc.</li><li>Media library with upload validation</li></ul><h4>Extended Features</h4><ul><li>Product and project catalog</li><li>Reports with PDF downloads</li><li>Company profile with dynamic contacts and social media links</li><li>Audit logs for transparency</li></ul><h4>Public Frontend with HTMX</h4><ul><li>Homepage with sliders and highlights</li><li>Posts list with search and pagination</li><li>Projects and product catalog</li><li>Contact form + newsletter subscription</li></ul><h4>Optimization, SEO, and Security</h4><ul><li>Performance tuning with caching and indexes</li><li>SEO optimization (slugs, meta tags, schema.org)</li><li>Accessibility improvements (WCAG 2.1 AA)</li><li>Security hardening</li></ul><h4>Deployment &amp; Launch</h4><ul><li>Nginx reverse proxy and SSL setup</li><li>Production configs with .env</li><li>Optional Docker deployment</li><li>Final checklist before launch</li></ul><p>By following this series, you’ll get hands-on experience to:</p><ul><li>Build a <strong>full-stack company website in Golang</strong> with HTMX + TailwindCSS.</li><li>Design and implement a <strong>production-ready database schema</strong>.</li><li>Use AI tools effectively for code generation and refactoring.</li><li>Optimize for <strong>performance, security, and SEO</strong>.</li><li>Deploy your app with Nginx and Docker.</li></ul><h3>Closing</h3><p>This kickoff story is the foundation. In the next part, we’ll set up the Golang project, configure the architecture, and prepare the base structure.</p><p>If you’ve ever wanted to learn <strong>how to build a CMS with AI</strong>, or if you’re curious about <strong>HTMX tutorials with Golang</strong>, this series is for you.</p><p>Stay tuned — the real coding starts next.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dccf7473fdd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Organizing Content with Categories and Telling Your Story on the About Page (Create Simple Blog…]]></title>
            <link>https://medium.com/@halimdirgantara/organizing-content-with-categories-and-telling-your-story-on-the-about-page-create-simple-blog-e4f5c0267dc0?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4f5c0267dc0</guid>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Mon, 20 Jan 2025 00:02:03 GMT</pubDate>
            <atom:updated>2025-01-20T00:02:03.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>Organizing Content with Categories and Telling Your Story on the About Page (Create Simple Blog Landing Page — Part 4)</h3><blockquote>Read Previous Article, Listing Posts and Viewing Single Post Details (Create Simple Blog Landing Page — Part 3), also this for <a href="https://medium.com/@halimdirgantara/list/filament-series-fdf8ad5ae252">Creating Simple Blog Admin Using Filament </a>before you read this!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*C8E4sKgPPCFiHD2TdHpaEg.png" /></figure><p>For the final part of our simple blog landing page, we’re creating the <strong>Category page</strong>, where all categories are displayed, and users can explore posts based on their selected category. This will help organize our content better and make navigation easier for readers.</p><p>No time to waste! Let’s jump straight into it by creating a new Livewire component for categories using the following command:</p><pre>php artisan make:livewire Category/Index</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*BihjJMhShdw_qM2R4zeGiw.png" /></figure><p>Fill up the Category/ Index.php file with the following code to fetch all categories from the database:</p><pre>use App\Models\Category;<br><br>class Index extends Component<br>{<br>    public $page = 1;<br><br>    public function setPage($page)<br>    {<br>        $this-&gt;page = $page;<br>    }<br><br>    public function previousPage()<br>    {<br>        $this-&gt;page--;<br>    }<br><br>    public function nextPage()<br>    {<br>        $this-&gt;page++;<br>    }<br><br>    public function render()<br>    {<br>        $categories = Category::orderBy(&#39;created_at&#39;, &#39;desc&#39;)-&gt;paginate(6, [&#39;*&#39;], &#39;page&#39;, $this-&gt;page);<br><br>        return view(&#39;livewire.category.index&#39;, [<br>            &#39;categories&#39; =&gt; $categories<br>        ])-&gt;extends(&#39;layouts.app&#39;);<br>    }<br>}</pre><p>We’re still sticking with the same technique we used for the posts list, keeping things consistent and simple. We’ll also use the same custom pagination component to maintain a unified look across the site.</p><p>Now, let’s move on and add the blade file for the category view. Here’s how you can do it:</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;div class=&quot;grid grid-cols-2 sm:grid-cols-3 gap-2&quot;&gt;<br>        @foreach ($categories as $category)<br>            &lt;div class=&quot;card group m-2 hover:shadow sm:max-w-sm flex flex-col h-full&quot;&gt;<br>                &lt;figure&gt;<br>                    &lt;img src=&quot;{{ asset(&#39;storage/&#39; . $category-&gt;image) }}&quot; alt=&quot;{{ $category-&gt;name }}&quot;<br>                        class=&quot;transition-transform duration-500 group-hover:scale-110&quot; /&gt;<br>                &lt;/figure&gt;<br>                &lt;div class=&quot;card-body flex flex-col flex-1&quot;&gt;<br>                    &lt;h5 class=&quot;card-title mb-2.5&quot;&gt;{{ $category-&gt;name }}&lt;/h5&gt;<br>                    &lt;p class=&quot;mb-6&quot;&gt;{{ Str::limit($category-&gt;description, 100) }}&lt;/p&gt;<br>                    &lt;div class=&quot;card-actions justify-between items-center&quot;&gt;<br>                        &lt;p class=&quot;mb-2&quot;&gt;Total Posts: {{ $category-&gt;posts-&gt;count() }}&lt;/p&gt;<br>                        &lt;a href=&quot;#&quot; class=&quot;btn btn-primary&quot;&gt;View All Posts&lt;/a&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        @endforeach<br>    &lt;/div&gt;<br>    &lt;div class=&quot;flex justify-between my-4&quot;&gt;<br>        &lt;x-pagination :page=&quot;$categories-&gt;currentPage()&quot; :totalPages=&quot;$categories-&gt;lastPage()&quot; /&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>In resources/views/livewire/category/index.blade.php, we’ll structure the layout to include the category list. This is the category page looks :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UefhfB70GC7qAihxQLhVg.png" /><figcaption>category page</figcaption></figure><p>Our next step is to display a list of posts based on the category selected by the user. To make this happen, we’ll create a category show component. Let’s start by running the following command:</p><pre>php artisan make:livewire Category/Show</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*kCIoTbP7LDwhti1E3jgbZA.png" /></figure><p>This will generate the necessary files for the Category/Show component. With this in place, we can focus on fetching and displaying posts tied to the selected category.</p><p>Don’t forget to update the web.php file to include routes for the category page. Add the following lines:</p><pre>use App\Livewire\Category\Index as CategoryIndex;<br>use App\Livewire\Category\Show as CategoryShow;<br><br>Route::get(&#39;/category&#39;, CategoryIndex::class)-&gt;name(&#39;category&#39;);<br>Route::get(&#39;/category/{slug}&#39;, CategoryShow::class)-&gt;name(&#39;category.show&#39;);</pre><p>With the routes in place, the application can navigate to the category listing or show posts under a specific category based on its slug.</p><p>Next, let’s fill up the Category/Show.php file with the logic needed to fetch and display posts tied to a selected category. This ensures a seamless user experience when exploring posts by category.</p><pre>use App\Models\Post;<br>use App\Models\Category;<br><br>class Show extends Component<br>{<br>    public $slug;<br><br>    public $category;<br><br>    public $page = 1;<br><br><br>    public function setPage($page)<br>    {<br>        $this-&gt;page = $page;<br>    }<br><br>    public function previousPage()<br>    {<br>        $this-&gt;page--;<br>    }<br><br>    public function nextPage()<br>    {<br>        $this-&gt;page++;<br>    }<br><br>    public function mount($slug)<br>    {<br>        $this-&gt;slug = $slug;<br>        $this-&gt;category = Category::where(&#39;slug&#39;, $slug)-&gt;firstOrFail();<br>    }<br><br>    public function render()<br>    {<br>        $posts = Post::whereHas(&#39;category&#39;, function ($query) {<br>            $query-&gt;where(&#39;slug&#39;, $this-&gt;slug);<br>        })-&gt;paginate(6, [&#39;*&#39;], &#39;page&#39;, $this-&gt;page);<br><br>        return view(&#39;livewire.category.show&#39;, [<br>            &#39;posts&#39; =&gt; $posts<br>        ])-&gt;extends(&#39;layouts.app&#39;);<br>    }<br>}</pre><p>Now, let’s move on and add the blade file for the category show posts list based on selected category :</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;h1 class=&quot;text-2xl font-bold mb-4&quot;&gt;Category : {{ Str::title($category-&gt;name) }}&lt;/h1&gt;<br>    &lt;div class=&quot;grid grid-cols-2 sm:grid-cols-3 gap-2&quot;&gt;<br>        @foreach ($posts as $post)<br>            &lt;div class=&quot;card group m-2 hover:shadow sm:max-w-sm flex flex-col h-full&quot;&gt;<br>                &lt;figure&gt;<br>                    &lt;img src=&quot;{{ asset(&#39;storage/&#39; . $post-&gt;feature_image) }}&quot; alt=&quot;{{ $post-&gt;title }}&quot;<br>                        class=&quot;transition-transform duration-500 group-hover:scale-110&quot; /&gt;<br>                &lt;/figure&gt;<br>                &lt;div class=&quot;card-body flex flex-col flex-1&quot;&gt;<br>                    &lt;h5 class=&quot;card-title mb-2.5&quot;&gt;{{ $post-&gt;title }}&lt;/h5&gt;<br>                    &lt;p class=&quot;mb-6&quot;&gt;{{ Str::limit($post-&gt;body, 100) }}&lt;/p&gt;<br>                    &lt;div class=&quot;card-actions mt-auto&quot;&gt;<br>                        &lt;a href=&quot;{{ route(&#39;post.show&#39;, $post-&gt;slug) }}&quot; class=&quot;btn btn-primary&quot;&gt;Read More&lt;/a&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        @endforeach<br>    &lt;/div&gt;<br>    &lt;div class=&quot;flex justify-between my-4&quot;&gt;<br>        &lt;x-pagination :page=&quot;$posts-&gt;currentPage()&quot; :totalPages=&quot;$posts-&gt;lastPage()&quot; /&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>And final looks for posts list based on selected category is like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RGKPoD27vLatfuJZxH-FGQ.png" /><figcaption>posts list based on selected category</figcaption></figure><p>And last but not least, let’s create the <strong>About</strong> page. This is where we’ll share the story behind this simple blog — what it’s all about, why it exists, and what we aim to achieve with it.</p><p>To keep things consistent, we’ll use a Livewire component for this page. Run the following command to generate the component:</p><pre>php artisan make:livewire About</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*IA8QXky9BbVgE7U8Ewa72w.png" /></figure><p>We’ll keep the content simple yet engaging, focusing on introducing the blog to visitors. For example:</p><p>In About.php, update the render method to point to the correct layout:</p><pre>public function render()  <br>{  <br>    return view(&#39;livewire.about&#39;)-&gt;layout(&#39;layouts.app&#39;);  <br>}</pre><p>And for about.blade.php, you can add content like this:</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;h1 class=&quot;text-4xl font-bold mb-4&quot;&gt;About Our Blog&lt;/h1&gt;<br>    &lt;img class=&quot;mb-4 rounded-lg&quot; src=&quot;{{ asset(&#39;images/about-page.png&#39;) }}&quot; alt=&quot;Blog Logo&quot;&gt;<br>    &lt;p class=&quot;mt-4 text-lg leading-relaxed&quot;&gt;<br>        Welcome to our simple blog! Here, we share our thoughts, ideas, and updates on various topics.<br>        Whether you&#39;re here for inspiration, learning, or just browsing, we&#39;re glad you stopped by.<br>    &lt;/p&gt;<br>    &lt;p class=&quot;mt-4 text-lg leading-relaxed&quot;&gt;<br>        This blog is built with simplicity and usability in mind, powered by Filament, Tailwind CSS, and Livewire.<br>        It’s a passion project and a space to grow, learn, and connect. Thanks for being part of our journey!<br>    &lt;/p&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpW0bapiQUI5XWoYAJfxlQ.png" /><figcaption>about page</figcaption></figure><p>And just like that, the About page is ready! A perfect way to wrap up our simple blog project and give it a touch of personality.</p><p>Before we wrap things up, let’s add one final touch to enhance the user experience: breadcrumbs. Breadcrumbs make navigation seamless and help users keep track of where they are on the blog. It’s a small detail that adds a big boost to usability.</p><p>We’ll implement breadcrumbs as a reusable component so we can easily include it across different pages. Start by creating the breadcrumb component in the resources/views/components/ directory.</p><p>Create a file named breadcrumb.blade.php and add the following structure:</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;div class=&quot;breadcrumbs&quot;&gt;<br>        &lt;ul&gt;<br>            &lt;li&gt;<br>                &lt;a href=&quot;{{ route(&#39;home&#39;) }}&quot; class=&quot;text-primary hover:text-primary-hover&quot;&gt;<br>                    &lt;span class=&quot;icon-[tabler--home] size-4&quot;&gt;&lt;/span&gt;<br>                    &lt;span&gt;Home&lt;/span&gt;<br>                &lt;/a&gt;<br>            &lt;/li&gt;<br>            &lt;li class=&quot;breadcrumbs-separator rtl:rotate-180&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--chevron-right] size-4&quot;&gt;&lt;/span&gt;<br>            &lt;/li&gt;<br>            @foreach ($breadcrumbs as $breadcrumb)<br>                &lt;li&gt;<br>                    @if ($breadcrumb[&#39;url&#39;])<br>                        &lt;a href=&quot;{{ $breadcrumb[&#39;url&#39;] }}&quot; class=&quot;text-primary hover:text-primary-hover&quot;&gt;<br>                            {{ $breadcrumb[&#39;label&#39;] }}<br>                        &lt;/a&gt;<br>                    @else<br>                        &lt;span class=&quot;text-gray-600&quot;&gt;{{ $breadcrumb[&#39;label&#39;] }}&lt;/span&gt;<br>                    @endif<br>                &lt;/li&gt;<br>                @unless ($loop-&gt;last)<br>                    &lt;li class=&quot;breadcrumbs-separator rtl:rotate-180&quot;&gt;<br>                        &lt;span class=&quot;icon-[tabler--chevron-right] size-4&quot;&gt;&lt;/span&gt;<br>                    &lt;/li&gt;<br>                @endunless<br>            @endforeach<br>        &lt;/ul&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>This component accepts a $breadcrumbs variable containing an array of breadcrumb links with url and label. For example, to use it in your livewire component, you can pass the data like this:</p><pre>public $breadcrumbs;<br><br>public function mount()<br>{<br>  $this-&gt;breadcrumbs = [<br>    [&#39;label&#39; =&gt; &#39;About&#39;, &#39;url&#39; =&gt; null]<br>  ];<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*Z9FfmOSNyIJTzOr_cLoh6g.png" /><figcaption>breadcrumb in above page</figcaption></figure><p>Now that breadcrumbs are in place, navigation is more intuitive, and users can easily explore your blog without feeling lost. It’s these small finishing touches that truly complete the project and create a polished experience for your audience!</p><p>Finally, our <a href="https://medium.com/@halimdirgantara/list/simple-blog-landingpage-series-00b723c04144"><strong>Simple Blog Landing Page</strong></a> for the <a href="https://medium.com/@halimdirgantara/list/filament-series-fdf8ad5ae252">Blog Admin using Filament</a> is officially done! 🎉 This project is a great foundation, but it doesn’t stop here. You can expand the blog further with exciting features like a comment section for user engagement, post likes to show popularity, or even a contact form for readers to reach out directly.</p><p>The possibilities are endless, and with the tools and structure we’ve built, adding new features will feel seamless and fun.</p><p>This wraps up our <strong>Simple Blog Landing Page</strong> series, but it’s not the end. Stay tuned for other series where we dive deeper into creating even more dynamic and advanced features for your projects. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4f5c0267dc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Listing Posts and Viewing Single Post Details (Create Simple Blog Landing Page — Part 3)]]></title>
            <link>https://medium.com/@halimdirgantara/listing-posts-and-viewing-single-post-details-create-simple-blog-landing-page-part-3-057510f4f942?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/057510f4f942</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 01:02:01 GMT</pubDate>
            <atom:updated>2025-01-19T01:02:01.817Z</atom:updated>
            <content:encoded><![CDATA[<h3>Listing Posts and Viewing Single Post Details (Create Simple Blog Landing Page — Part 3)</h3><blockquote>Read Previous Article, <a href="https://medium.com/@halimdirgantara/setting-up-dependencies-and-crafting-home-page-for-simple-blog-landing-page-create-simple-blog-54d98810961c">Setting Up Dependencies and Crafting Home Page for Simple Blog Landing Page (Create Simple Blog Landing Page — Part 2)</a>, also this for <a href="https://medium.com/@halimdirgantara/list/filament-series-fdf8ad5ae252">Creating Simple Blog Admin Using Filament </a>before you read this!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*C8E4sKgPPCFiHD2TdHpaEg.png" /></figure><p>Now that our home page is complete, it’s time to dive into the next step: creating the post listing page along with single post detail functionality. These pages are essential for showcasing all blog posts and allowing users to view the full content of individual posts. Let’s break it down step by step.</p><p>We’ll start by generating a Livewire component for the post listing page. Use the following command:</p><pre>php artisan make:livewire Post/Index</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*8PUfJHBHCjY2I5Qfp5RsrA.png" /></figure><p>Update the Post/ Index.php file with the following code to fetch all posts from the database:</p><pre>use App\Models\Post;<br><br>class Index extends Component<br>{<br>    public $page = 1;<br><br>    public function setPage($page)<br>    {<br>        $this-&gt;page = $page;<br>    }<br><br>    public function previousPage()<br>    {<br>        $this-&gt;page--;<br>    }<br><br>    public function nextPage()<br>    {<br>        $this-&gt;page++;<br>    }<br><br>    public function render()<br>    {<br>        $posts = Post::orderBy(&#39;created_at&#39;, &#39;desc&#39;)-&gt;paginate(6, [&#39;*&#39;], &#39;page&#39;, $this-&gt;page);<br><br>        return view(&#39;livewire.post.index&#39;, [<br>            &#39;posts&#39; =&gt; $posts<br>        ])-&gt;extends(&#39;layouts.app&#39;);<br>    }<br>}</pre><p>Because we are using a custom pagination component instead of the default one, we need to create a pagination component in resources/ view/ components/ pagination.blade.php</p><pre>&lt;div class=&quot;flex flex-row justify-between items-center&quot;&gt;<br>    &lt;div class=&quot;text-sm text-base-content/50 mr-4&quot;&gt;<br>        Page {{ $page }} of {{ $totalPages }}<br>    &lt;/div&gt;<br>    &lt;nav class=&quot;flex justify-end items-center gap-x-1&quot;&gt;<br>        &lt;button {{ $page == 1 ? &#39;disabled&#39; : &#39;&#39; }} wire:click=&quot;previousPage&quot; type=&quot;button&quot;<br>            class=&quot;btn btn-soft&quot;&gt;Previous&lt;/button&gt;<br>        &lt;div class=&quot;flex items-center gap-x-1&quot;&gt;<br>            @for ($i = 1; $i &lt;= $totalPages; $i++)<br>                &lt;button type=&quot;button&quot;<br>                    class=&quot;btn btn-soft btn-square {{ $page == $i ? &#39;aria-[current=page]:text-bg-soft-primary&#39; : &#39;&#39; }}&quot;<br>                    {{ $page == $i ? &#39;aria-current=page&#39; : &#39;&#39; }}<br>                    wire:click=&quot;setPage({{ $i }})&quot;&gt;{{ $i }}&lt;/button&gt;<br>            @endfor<br>        &lt;/div&gt;<br>        &lt;button {{ $page == $totalPages ? &#39;disabled&#39; : &#39;&#39; }} wire:click=&quot;nextPage&quot; type=&quot;button&quot;<br>            class=&quot;btn btn-soft&quot;&gt;Next&lt;/button&gt;<br>    &lt;/nav&gt;<br>&lt;/div&gt;</pre><p>Next, we create the view for the blog post list in resources/ views/ livewire/ post/ index.blade.php</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;div class=&quot;grid grid-cols-2 sm:grid-cols-3 gap-2&quot;&gt;<br>        @foreach ($posts as $post)<br>            &lt;div class=&quot;card group m-2 hover:shadow sm:max-w-sm flex flex-col h-full&quot;&gt;<br>                &lt;figure&gt;<br>                    &lt;img src=&quot;{{ asset(&#39;storage/&#39; . $post-&gt;feature_image) }}&quot; alt=&quot;{{ $post-&gt;title }}&quot;<br>                        class=&quot;transition-transform duration-500 group-hover:scale-110&quot; /&gt;<br>                &lt;/figure&gt;<br>                &lt;div class=&quot;card-body flex flex-col flex-1&quot;&gt;<br>                    &lt;h5 class=&quot;card-title mb-2.5&quot;&gt;{{ $post-&gt;title }}&lt;/h5&gt;<br>                    &lt;p class=&quot;mb-6&quot;&gt;{{ Str::limit($post-&gt;body, 100) }}&lt;/p&gt;<br>                    &lt;div class=&quot;card-actions mt-auto&quot;&gt;<br>                        &lt;a href=&quot;#&quot; class=&quot;btn btn-primary&quot;&gt;Read More&lt;/a&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        @endforeach<br>    &lt;/div&gt;<br>    &lt;div class=&quot;flex justify-between my-4&quot;&gt;<br>        &lt;x-pagination :page=&quot;$posts-&gt;currentPage()&quot; :totalPages=&quot;$posts-&gt;lastPage()&quot; /&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Add this line in routes/ web.php to accomodate route blog page :</p><pre>use App\Livewire\Post\Index as PostIndex;<br><br>Route::get(&#39;/post&#39;, PostIndex::class)-&gt;name(&#39;post&#39;);</pre><p>This is how the blog post index looks after displaying the post list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3efVEU_2sVNEGHOrkSBcjQ.png" /></figure><p>We haven’t added a route for single blog posts yet, so our next step is to create a single post component using Livewire. To do this, run the following command:</p><pre>php artisan make:livewire Post/Show</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*sXcCR93g8byUj65-pccztg.png" /></figure><p>First, update the Show.php file to fetch a single post based on its slug. Here’s the basic structure for the Show.php file:</p><pre>use App\Models\Post;<br><br>class Show extends Component<br>{<br>    public $post;<br><br>    public function mount($slug)<br>    {<br>        $this-&gt;post = Post::where(&#39;slug&#39;, $slug)-&gt;firstOrFail();<br>    }<br><br>    public function render()<br>    {<br>        return view(&#39;livewire.post.show&#39;, [<br>            &#39;post&#39; =&gt; $this-&gt;post<br>        ])-&gt;extends(&#39;layouts.app&#39;);<br>    }<br>}</pre><p>Next, in the show.blade.php file, we will display the details of the selected post. This is the code :</p><pre>&lt;div class=&quot;max-w-screen-lg mx-auto mt-6&quot;&gt;<br>    &lt;div class=&quot;card bg-base-100&quot;&gt;<br>        &lt;!-- Feature Image --&gt;<br>        &lt;figure class=&quot;h-96&quot;&gt;<br>            &lt;img src=&quot;{{ asset(&#39;storage/&#39; . $post-&gt;feature_image) }}&quot; <br>                 alt=&quot;{{ $post-&gt;title }}&quot; <br>                 class=&quot;w-full h-full object-cover&quot;&gt;<br>        &lt;/figure&gt;<br><br>        &lt;div class=&quot;card-body&quot;&gt;<br>            &lt;!-- Category Badge --&gt;<br>            &lt;div class=&quot;mb-4&quot;&gt;<br>                &lt;span class=&quot;badge badge-primary&quot;&gt;{{ $post-&gt;category-&gt;name }}&lt;/span&gt;<br>            &lt;/div&gt;<br><br>            &lt;!-- Title --&gt;<br>            &lt;h1 class=&quot;card-title text-4xl mb-4&quot;&gt;{{ $post-&gt;title }}&lt;/h1&gt;<br><br>            &lt;!-- Author and Date Info --&gt;<br>            &lt;div class=&quot;flex items-center gap-4 mb-6 text-base-content/60&quot;&gt;<br>                &lt;div class=&quot;flex items-center gap-2&quot;&gt;<br>                    &lt;span class=&quot;icon-[tabler--user] size-5&quot;&gt;&lt;/span&gt;<br>                    &lt;span&gt;{{ $post-&gt;creator-&gt;name }}&lt;/span&gt;<br>                &lt;/div&gt;<br>                &lt;div class=&quot;flex items-center gap-2&quot;&gt;<br>                    &lt;span class=&quot;icon-[tabler--calendar] size-5&quot;&gt;&lt;/span&gt;<br>                    &lt;span&gt;{{ $post-&gt;created_at-&gt;format(&#39;M d, Y&#39;) }}&lt;/span&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br><br>            &lt;!-- Content --&gt;<br>            &lt;div class=&quot;prose max-w-none&quot;&gt;<br>                {!! $post-&gt;body !!}<br>            &lt;/div&gt;<br><br>            &lt;!-- Tags --&gt;<br>            @if($post-&gt;tags-&gt;count() &gt; 0)<br>                &lt;div class=&quot;flex gap-2 mt-8&quot;&gt;<br>                    @foreach($post-&gt;tags as $tag)<br>                        &lt;a href=&quot;#&quot;&gt;<br>                            &lt;span class=&quot;badge badge-outline&quot;&gt;{{ $tag-&gt;name }}&lt;/span&gt;<br>                        &lt;/a&gt;<br>                    @endforeach<br>                &lt;/div&gt;<br>            @endif<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;!-- Share Buttons --&gt;<br>    &lt;div class=&quot;card bg-base-100 mt-6 p-6&quot;&gt;<br>        &lt;h3 class=&quot;text-lg font-semibold mb-4&quot;&gt;Share this post&lt;/h3&gt;<br>        &lt;div class=&quot;flex gap-4&quot;&gt;<br>            &lt;a href=&quot;https://twitter.com/intent/tweet?url={{ url()-&gt;current() }}&quot; <br>               target=&quot;_blank&quot; <br>               class=&quot;btn btn-outline btn-square&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--brand-twitter] size-5&quot;&gt;&lt;/span&gt;<br>            &lt;/a&gt;<br>            &lt;a href=&quot;https://www.facebook.com/sharer/sharer.php?u={{ url()-&gt;current() }}&quot; <br>               target=&quot;_blank&quot; <br>               class=&quot;btn btn-outline btn-square&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--brand-facebook] size-5&quot;&gt;&lt;/span&gt;<br>            &lt;/a&gt;<br>            &lt;a href=&quot;https://www.linkedin.com/shareArticle?url={{ url()-&gt;current() }}&quot; <br>               target=&quot;_blank&quot; <br>               class=&quot;btn btn-outline btn-square&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--brand-linkedin] size-5&quot;&gt;&lt;/span&gt;<br>            &lt;/a&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>Finally, we need to add a route in web.php to connect this component:</p><pre>use App\Http\Livewire\Post\Show as PostShow;<br><br>Route::get(&#39;/post/{slug}&#39;, PostShow::class)-&gt;name(&#39;post.show&#39;);</pre><p>With the route in place, you can now navigate to a single blog post by visiting /post/{slug}. Up next, we’ll style the single post view and enhance it with additional features like related posts and social sharing buttons!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HA11SZjUHb-u73FtlEEEsQ.png" /></figure><p>Now that we’ve successfully set up the single post page, our blog can display individual posts with all their details dynamically. Each post now has its own dedicated page, accessible by its slug, giving our simple blog a more complete and polished look.</p><p>And don’t forget to update our home page with single post route in latest post and carousel,</p><pre>// carousel.blade.php<br>&lt;a href=&quot;{{ route(&#39;post.show&#39;, $post-&gt;slug) }}&quot; class=&quot;z-10 absolute bottom-4 left-0 right-0 text-center pt-4&quot;&gt;<br>  &lt;span class=&quot;text-2xl sm:text-4xl&quot;&gt;{{ $post-&gt;title }}&lt;/span&gt;<br>&lt;/a&gt;<br><br>// latest-post.blade.php<br><br>&lt;a class=&quot;link-animated&quot; href=&quot;{{ route(&#39;post.show&#39;, $post-&gt;slug) }}&quot;&gt;<br>  &lt;h5 class=&quot;card-title mb-2.5&quot;&gt;{{ $post-&gt;title }}&lt;/h5&gt;<br>&lt;/a&gt;</pre><p>With the single post functionality in place, we’re ready to move on to the next exciting part of our journey. In the next chapter, we’ll enhance our blog further by adding a <strong>category page</strong> to organize posts and an <strong>about page</strong> to share more about the blog and its purpose. Stay tuned — there’s more to come!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=057510f4f942" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Dependencies and Crafting Home Page for Simple Blog Landing Page (Create Simple Blog…]]></title>
            <link>https://medium.com/@halimdirgantara/setting-up-dependencies-and-crafting-home-page-for-simple-blog-landing-page-create-simple-blog-54d98810961c?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/54d98810961c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Sat, 18 Jan 2025 12:54:26 GMT</pubDate>
            <atom:updated>2025-01-18T12:54:26.675Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting Up Dependencies and Crafting Home Page for Simple Blog Landing Page (Create Simple Blog Landing Page — Part 2)</h3><blockquote>Read Previous Article, <a href="https://medium.com/@halimdirgantara/create-blog-landing-page-based-on-filament-series-simple-blog-admin-part-1-51cfbafcd2b2">Create Blog Landing Page Based On Filament Series Simple Blog Admin (Part 1)</a> , also this for <a href="https://medium.com/@halimdirgantara/list/filament-series-fdf8ad5ae252">Creating Simple Blog Admin Using Filament </a>before you read this!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*C8E4sKgPPCFiHD2TdHpaEg.png" /></figure><p>Now that our mock-up data is complete, it’s time to move on to the next step: creating a simple yet functional blog landing page. Before jumping into the design, we need to address some essential dependencies and setup tasks to ensure everything runs seamlessly. Here are the requirements for our pages:</p><ul><li><a href="https://tailwindcss.com/"><strong>Tailwind CSS</strong></a> → For styling and creating a responsive layout for our landing page.</li><li><a href="https://flyonui.com/"><strong>FlyonUI</strong></a> → For Tailwind CSS components, FlyonUI brings together the beauty of semantic classes and the interactive headless JavaScript plugins, offering you a powerful toolkit to build stunning, interactive user interfaces with ease.</li><li><a href="https://livewire.laravel.com/"><strong>Livewire</strong></a> → To add dynamic interactions and seamlessly connect with the data models.</li><li><a href="https://vite.dev/"><strong>Vite</strong></a> → To handle asset bundling and optimize performance.</li></ul><p>All of these requirements are already in place from when we created the blog admin using Filament. This gives us a solid foundation to build on and ensures we don’t need to start from scratch. With Tailwind CSS, Livewire, and other tools already integrated, we’re ready to focus on crafting a visually appealing and dynamic blog landing page without worrying about setting up the basics.</p><p>To make the process even smoother, we’ll install <strong>FlyonUI</strong>, a Tailwind CSS component library, to speed up development and ensure a polished look for our page. FlyonUI will help us seamlessly incorporate pre-built components and maintain consistency in design while reducing the effort needed for custom styling. Let’s get started with setting up FlyonUI and dive into the next steps of building our landing page!</p><p><strong>Step 1: Install FlyonUI</strong><br>First, we need to add FlyonUI to our project. Run the following command to install it as a dependency:</p><pre>npm install flyonui</pre><p>This will install FlyonUI and make its components available for use, giving us access to a wide range of pre-built Tailwind CSS elements.</p><p><strong>Step 2: Configure Tailwind CSS</strong><br> Next, we’ll configure Tailwind CSS to integrate with FlyonUI. Open your tailwind.config.js file and add FlyonUI as a plugin:</p><pre>module.exports = { <br>  content: [&quot;./node_modules/flyonui/dist/js/*.js&quot;], // Include FlyonUI JS components if needed</pre><pre>plugins: [<br>    require(&quot;flyonui&quot;),<br>    require(&quot;flyonui/plugin&quot;) // Add if you&#39;re using FlyonUI JS components<br>  ]<br>}</pre><p>Now, our tailwind.config.js file is like this :</p><pre>import preset from &#39;./vendor/filament/support/tailwind.config.preset&#39;<br><br>export default {<br>    presets: [preset],<br>    content: [<br>        &#39;./app/Filament/**/*.php&#39;,<br>        &#39;./resources/views/filament/**/*.blade.php&#39;,<br>        &#39;./vendor/filament/**/*.blade.php&#39;,<br>        &#39;./app/Http/Livewire/**/*.php&#39;,<br>        &#39;./resources/views/livewire/**/*.blade.php&#39;,<br>        &quot;./resources/**/*.blade.php&quot;,<br>        &quot;./resources/**/*.js&quot;,<br>        &quot;./node_modules/flyonui/dist/js/*.js&quot;,<br>    ],<br>    plugins: [<br>        require(&quot;flyonui&quot;),<br>        require(&quot;flyonui/plugin&quot;) // Require only if you want to use FlyonUI JS component<br>    ]<br>}</pre><p>Don’t forget to add import ‘flyonui/flyonui’; into app.js file at resources/ js/ to make sure all javascripts we need for FlyonUI works.</p><p>By integrating FlyonUI into our setup, we’re not just saving time but also ensuring a consistent and modern design across our blog landing page. Now, let’s dive into the next steps to bring this all to life!</p><p>First, we need to create the base layout for our landing page. This will serve as the foundation for all the pages we’ll build. To do this, we’ll create two files in resources/views/layouts/:</p><ol><li><strong>base.blade.php</strong> → This file will define the overall HTML structure, including the &lt;html&gt; and &lt;head&gt; tags, as well as the basic layout shared across all pages.</li><li><strong>app.blade.php</strong> → This file will extend base.blade.php and provide a more specific layout for our application, like including navigation bars, footers, and other reusable components.</li></ol><p>By separating the layouts this way, we can keep our code clean and maintainable. It also allows us to easily update the structure or styles of the site without making changes to every single page.</p><p>This is code for base.blade.php :</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;{{ str_replace(&#39;_&#39;, &#39;-&#39;, app()-&gt;getLocale()) }}&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>    &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;<br><br>    &lt;title&gt;{{ config(&#39;app.name&#39;, &#39;Laravel&#39;) }} - @yield(&#39;title&#39;, &#39;&#39;)&lt;/title&gt;<br><br>    &lt;!-- Fonts --&gt;<br>    &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.bunny.net&quot;&gt;<br>    &lt;link href=&quot;https://fonts.bunny.net/css?family=figtree:400,500,600&amp;display=swap&quot; rel=&quot;stylesheet&quot; /&gt;<br><br>    &lt;!-- Scripts and Styles --&gt;<br>    @vite([&#39;resources/css/app.css&#39;, &#39;resources/js/app.js&#39;])<br><br>    &lt;!-- Livewire Styles --&gt;<br>    @livewireStyles<br>&lt;/head&gt;<br>&lt;body class=&quot;min-h-screen bg-gray-100 font-sans antialiased&quot;&gt;<br><br>    &lt;!-- This is a comment added to the base layout --&gt;<br>    @yield(&#39;body&#39;)<br><br>    &lt;!-- Livewire Scripts --&gt;<br>    @livewireScripts<br><br>    &lt;!-- Stack for Additional Scripts --&gt;<br>    @stack(&#39;scripts&#39;)<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>And this is for app.blade.php :</p><pre>@extends(&#39;layouts.base&#39;)<br><br>@section(&#39;body&#39;)<br><br>    @yield(&#39;content&#39;)<br><br>    @isset($slot)<br>        {{ $slot }}<br>    @endisset<br><br>@endsection</pre><p>The next step is to create a navigation menu component located in resources/components/navbar.blade.php. This component will be consistent across all pages, providing a unified navigation experience for the blog. To include this component in our layout, we’ll add the following line to app.blade.php:</p><pre>@include(&#39;components.navbar&#39;)</pre><p>However, before diving into the creation of the navbar component, we first need to set up a Livewire component for the home page. This will allow us to preview and test all the changes we’ve made so far in a functional environment. The Livewire home page component will act as the entry point, ensuring everything from the layout to the navigation works seamlessly.</p><p>We create livewire component using this command:</p><pre>php artisan make:livewire Home</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*ZswGLMsTvxU_nDONfFMi5Q.png" /><figcaption>livewire component creation</figcaption></figure><p>The command creates two files: app/Livewire/Home.php for handling the logic and behavior of the home page, and resources/views/livewire/home.blade.php for defining the visual structure and layout of the home page.</p><p>The Home.php file will contain the Livewire component class where we can manage data, define methods, and handle user interactions. Meanwhile, the home.blade.php file serves as the template for displaying the home page content, which we’ll use to design a dynamic and visually appealing interface.</p><p>By separating logic and presentation in this way, we maintain a clean and modular structure that’s easy to work with and scale as the project grows.</p><p>First, we need to modify the Home.php file to extend the layout by using this syntax:</p><pre>public function render()<br>    {<br>        return view(&#39;livewire.home&#39;)-&gt;layout(&#39;layouts.app&#39;);<br>    }</pre><p>Before diving into designing the home page, let’s fill the page with a simple title in the Blade template for now:</p><pre>&lt;div&gt;<br>    &lt;h1&gt;Home&lt;/h1&gt;<br>&lt;/div&gt;</pre><p>Don’t forget to modify the web.php routes file to redirect the root URL to the Home class. This way, visiting http://localhost will display our home page:</p><pre>use App\Livewire\Home;<br><br>Route::get(&#39;/&#39;, Home::class)-&gt;name(&#39;home&#39;);<br><br>Route::get(&#39;/blog&#39;, function () {<br>    return &#39;Blog&#39;;<br>})-&gt;name(&#39;blog&#39;);<br><br>Route::get(&#39;/category&#39;, function () {<br>    return &#39;Category&#39;;<br>})-&gt;name(&#39;category&#39;);<br><br>Route::get(&#39;/about&#39;, function () {<br>    return &#39;About&#39;;<br>})-&gt;name(&#39;about&#39;);</pre><p>We’ll also create additional routes as examples, ensuring there are no errors when these routes are implemented in the navbar. This step helps us test the functionality and ensures smooth navigation.</p><p>Once this setup is complete, we’re ready to move on to the next exciting step: crafting the navbar component for our navigation menu.</p><p>We need at least four menus: a home page, a blog page, a category page, and an about page. We’re using Tailwind CSS to create a responsive navigation menu. The code looks like this:</p><pre>&lt;nav class=&quot;navbar rounded-box shadow&quot;&gt;<br>    &lt;div class=&quot;w-full md:flex md:items-center md:gap-2&quot;&gt;<br>        &lt;div class=&quot;flex items-center justify-between&quot;&gt;<br>            &lt;div class=&quot;navbar-start items-center justify-between max-md:w-full&quot;&gt;<br>                &lt;a class=&quot;link text-base-content link-neutral text-xl font-semibold no-underline&quot; href=&quot;#&quot;&gt;FlyonUI&lt;/a&gt;<br>                &lt;div class=&quot;md:hidden&quot;&gt;<br>                    &lt;button type=&quot;button&quot; class=&quot;collapse-toggle btn btn-outline btn-secondary btn-sm btn-square&quot;<br>                        data-collapse=&quot;#default-navbar-collapse&quot; aria-controls=&quot;default-navbar-collapse&quot;<br>                        aria-label=&quot;Toggle navigation&quot;&gt;<br>                        &lt;span class=&quot;icon-[tabler--menu-2] collapse-open:hidden size-4&quot;&gt;&lt;/span&gt;<br>                        &lt;span class=&quot;icon-[tabler--x] collapse-open:block hidden size-4&quot;&gt;&lt;/span&gt;<br>                    &lt;/button&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;div id=&quot;default-navbar-collapse&quot;<br>            class=&quot;md:navbar-end collapse hidden grow basis-full overflow-hidden transition-[height] duration-300 max-md:w-full&quot;&gt;<br>            &lt;ul class=&quot;menu md:menu-horizontal gap-2 p-0 text-base max-md:mt-2&quot;&gt;<br>                &lt;li&gt;&lt;a href=&quot;{{ route(&#39;home&#39;) }}&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;<br>                &lt;li&gt;&lt;a href=&quot;{{ route(&#39;blog&#39;) }}&quot;&gt;Blog&lt;/a&gt;&lt;/li&gt;<br>                &lt;li&gt;&lt;a href=&quot;{{ route(&#39;category&#39;) }}&quot;&gt;Category&lt;/a&gt;&lt;/li&gt;<br>                &lt;li&gt;&lt;a href=&quot;{{ route(&#39;about&#39;) }}&quot;&gt;About&lt;/a&gt;&lt;/li&gt;                <br>            &lt;/ul&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/nav&gt;</pre><p>And the interface looks as follows :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBhMlqsqLgQ74N2IY_KFVA.png" /><figcaption>navigation menu on navbar</figcaption></figure><p>Now that the navigation menu is complete, we’re moving on to the next step: creating the home page for our blog. We’ll start by adding a banner, showcasing the latest blog posts, and including a few other elements to make our simple blog visually appealing and engaging.</p><p>We’ll create a carousel to showcase the random blog post feature image using a Livewire component. To do this, run the following command:</p><pre>php artisan make:livewire Home/Carousel</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*EXjS6DakQ4oK5TYTta5pAQ.png" /></figure><p>By grouping it under the Home folder, we can keep all components for the home page neatly organized. Next, we’ll populate the Livewire component in Livewire/ Home/ Carousel.php with the following code:</p><pre>&lt;?php<br><br>namespace App\Livewire\Home;<br><br>use App\Models\Post;<br>use Livewire\Component;<br><br>class Carousel extends Component<br>{<br>    public $posts;<br><br>    public function mount()<br>    {<br>        $this-&gt;posts = Post::inRandomOrder()-&gt;take(3)-&gt;get();<br>    }<br><br>    public function render()<br>    {<br>        return view(&#39;livewire.home.carousel&#39;);<br>    }<br>}</pre><p>And for resources/ views/ livewire/ home/carousel.blade.php :</p><pre>&lt;div class=&quot;w-full p-4&quot;&gt;<br>    &lt;div id=&quot;infinite-loop&quot; data-carousel=&#39;{ &quot;loadingClasses&quot;: &quot;opacity-0&quot;, &quot;isInfiniteLoop&quot;: true }&#39;<br>        class=&quot;relative w-full&quot;&gt;<br>        &lt;div class=&quot;carousel h-80&quot;&gt;<br>            &lt;div class=&quot;carousel-body h-full opacity-0&quot;&gt;<br>                @foreach ($posts as $key =&gt; $post)<br>                    &lt;!-- Slide 1 --&gt;<br>                    &lt;div class=&quot;carousel-slide&quot;&gt;<br>                        &lt;div class=&quot;bg-base-300/60 flex h-full flex-col relative&quot;&gt;<br>                            &lt;img src=&quot;{{ asset(&#39;storage/&#39; . $post-&gt;feature_image) }}&quot;<br>                                class=&quot;object-cover absolute inset-0 w-full h-full&quot; alt=&quot;{{ $post-&gt;title }}&quot;&gt;<br>                            &lt;a href=&quot;#&quot; class=&quot;z-10 absolute bottom-4 left-0 right-0 text-center pt-4&quot;&gt;<br>                                &lt;span class=&quot;text-2xl sm:text-4xl&quot;&gt;{{ $post-&gt;title }}&lt;/span&gt;<br>                            &lt;/a&gt;<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                @endforeach<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>        &lt;!-- Previous Slide --&gt;<br>        &lt;button type=&quot;button&quot; class=&quot;carousel-prev&quot;&gt;<br>            &lt;span class=&quot;size-9.5 bg-base-100 flex items-center justify-center rounded-full shadow&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--chevron-left] size-5 cursor-pointer rtl:rotate-180&quot;&gt;&lt;/span&gt;<br>            &lt;/span&gt;<br>            &lt;span class=&quot;sr-only&quot;&gt;Previous&lt;/span&gt;<br>        &lt;/button&gt;<br>        &lt;!-- Next Slide --&gt;<br>        &lt;button type=&quot;button&quot; class=&quot;carousel-next&quot;&gt;<br>            &lt;span class=&quot;sr-only&quot;&gt;Next&lt;/span&gt;<br>            &lt;span class=&quot;size-9.5 bg-base-100 flex items-center justify-center rounded-full shadow&quot;&gt;<br>                &lt;span class=&quot;icon-[tabler--chevron-right] size-5 cursor-pointer rtl:rotate-180&quot;&gt;&lt;/span&gt;<br>            &lt;/span&gt;<br>        &lt;/button&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpbfFJ0B1W4cY8hBwBcm7g.png" /><figcaption>carousel component in the home page</figcaption></figure><p>Next, we’ll create a section to display the latest posts, which will appear just below the carousel. To achieve this, we’ll use Livewire to create a dedicated component for the latest posts. Run the following command:</p><pre>php artisan make:livewire Home/LatestPost</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*EXjS6DakQ4oK5TYTta5pAQ.png" /></figure><p>As with the carousel component, we’re grouping this under the Home folder to maintain an organized structure for all home page-related components. Once the component is generated, we’ll populate Home/LatestPost.php with the following code to ensure it dynamically fetches and displays the latest blog posts.</p><p>This will help us keep the home page dynamic and engaging, ensuring visitors always see fresh and relevant content. Let’s get started by adding the code:</p><pre>&lt;?php<br><br>namespace App\Livewire\Home;<br><br>use App\Models\Post;<br>use Livewire\Component;<br><br>class LatestPost extends Component<br>{<br>    public $posts;<br><br>    public function mount()<br>    {<br>        $this-&gt;posts = Post::latest()-&gt;take(3)-&gt;get();<br>    }<br><br>    public function render()<br>    {<br>        return view(&#39;livewire.home.latest-post&#39;);<br>    }<br>}</pre><p>And for resources/ views/ livewire/ home/latest-post.blade.php :</p><pre>&lt;div class=&quot;container mx-auto px-6 lg:px-16 py-8&quot;&gt;<br>    &lt;h2 class=&quot;text-2xl font-bold mb-4 text-center&quot;&gt;Latest Posts&lt;/h2&gt;<br>    &lt;div class=&quot;grid grid-cols-3 card-group gap-2 max-w-sm sm:max-w-full&quot;&gt;<br>    @foreach ($posts as $post)<br>        &lt;div class=&quot;card&quot;&gt;<br>            &lt;div class=&quot;absolute top-0 left-0 bg-opacity-75 text-white bg-primary m-2 p-2 rounded-lg&quot;&gt;<br>                {{ $post-&gt;category-&gt;name }}<br>            &lt;/div&gt;<br>            &lt;figure&gt;&lt;img src=&quot;{{ asset(&#39;storage/&#39; . $post-&gt;feature_image) }}&quot; alt=&quot;{{ $post-&gt;title }}&quot; /&gt;&lt;/figure&gt;<br>            &lt;div class=&quot;card-body&quot;&gt;<br>                &lt;a class=&quot;link-animated&quot; href=&quot;#&quot;&gt;<br>                    &lt;h5 class=&quot;card-title mb-2.5&quot;&gt;{{ $post-&gt;title }}&lt;/h5&gt;<br>                &lt;/a&gt;<br>                &lt;p&gt;{{ $post-&gt;body }}&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;card-footer&quot;&gt;<br>                &lt;div class=&quot;flex justify-between items-center&quot;&gt;<br>                    &lt;p class=&quot;text-base-content/50 text-sm&quot;&gt;<br>                        &lt;span class=&quot;icon-[tabler--user] size-5&quot;&gt;&lt;/span&gt;<br>                        {{ $post-&gt;creator-&gt;name }}<br>                    &lt;/p&gt;<br>                    &lt;p class=&quot;text-base-content/50 text-sm&quot;&gt;{{ $post-&gt;created_at-&gt;diffForHumans() }}&lt;/p&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    @endforeach<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*jc2pszcbqZNTrzNmXWepCg.png" /><figcaption>latest posts component in the home page</figcaption></figure><p>The final component for the home page is the <strong>Subscribe Call-to-Action</strong> section for our simple blog. This component encourages visitors to subscribe and stay updated with our latest posts. We’ll create a Livewire component for this using the following command:</p><pre>php artisan make:livewire Home/Subscribe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*MIjAjnUB2QQ1UgXFVxJjJA.png" /></figure><p>Once created, we’ll fill the Home/Subscribe.php and its corresponding Blade file with a simple and engaging subscription form to complete the home page. This will make the blog more interactive and user-friendly.</p><p>Before creating the <strong>Subscribe</strong> component, we need to set up the subscribers table and its corresponding model. This will store the data for users who subscribe to our blog. Let&#39;s start by generating the model and migration using the following command:</p><pre>php artisan make:model Subscriber -m</pre><p>This command creates a Subscriber model and a migration file. Next, we need to define the schema for the subscribers table in the migration file. Open the generated migration file and update it as follows:</p><pre>Schema::create(&#39;subscribers&#39;, function (Blueprint $table) {<br>    $table-&gt;id();<br>    $table-&gt;string(&#39;email&#39;)-&gt;unique();<br>    $table-&gt;timestamps();<br>});</pre><p>Now, run the migration to create the table in the database:</p><pre>php artisan migrate</pre><p>After the migration, we can define the Subscriber model. Open the Subscriber.php file and update it like this:</p><pre>Class Subscriber extends Model<br>{<br>    use HasFactory;</pre><pre>    protected $fillable = [&#39;email&#39;];<br>}</pre><p>With the table and model ready, we can now proceed to create the <strong>Subscribe Call-to-Action</strong> component and seamlessly integrate it with our database to store subscribers’ emails. This step ensures we’re fully prepared to enhance the user engagement of our blog!</p><pre>&lt;?php<br><br>namespace App\Livewire\Home;<br><br>use App\Models\Post;<br>use Livewire\Component;<br>use App\Models\Subscriber;<br><br>class Subscribe extends Component<br>{<br>    public $email;<br>    public $randomImage;<br>    public $successAlert;<br>    protected $rules = [<br>        &#39;email&#39; =&gt; &#39;required|email:rfc,dns|unique:subscribers,email&#39;,<br>    ];<br><br>    public function mount()<br>    {<br>        $this-&gt;email = &#39;&#39;;<br>        $this-&gt;randomImage = Post::inRandomOrder()-&gt;first()-&gt;feature_image;<br>    }<br><br>    public function render()<br>    {<br>        return view(&#39;livewire.home.subscribe&#39;);<br>    }<br><br>    public function subscribe()<br>    {<br>        $this-&gt;validate();        <br><br>        $subscribe = Subscriber::create([<br>            &#39;email&#39; =&gt; $this-&gt;email,<br>        ]);<br><br>        if ($subscribe) {<br>            $this-&gt;email = &#39;&#39;;<br>            $this-&gt;successAlert = true;<br>            session()-&gt;flash(&#39;success&#39;, &#39;Thank you for subscribing to our newsletter!&#39;);<br>        }<br>    }<br><br>    public function closeAlert()<br>    {<br>        $this-&gt;successAlert = false;<br>    }<br>}</pre><pre>&lt;div class=&quot;container mx-auto px-6 lg:px-16 py-8&quot;&gt;<br>    &lt;div class=&quot;card glass text-white w-full h-80&quot;&gt;<br>        &lt;figure&gt;&lt;img src=&quot;{{ asset(&#39;storage/&#39; . $randomImage) }}&quot; alt=&quot;iphones&quot; /&gt;&lt;/figure&gt;<br>        &lt;div class=&quot;card-body&quot;&gt;<br>            &lt;h2 class=&quot;card-title mb-2.5 text-white&quot;&gt;Subscribe to our newsletter&lt;/h2&gt;<br>            &lt;p class=&quot;mb-4&quot;&gt;Subscribe to our newsletter to get the latest posts and updates.&lt;/p&gt;<br>            &lt;div class=&quot;card-actions&quot;&gt;<br>                &lt;div class=&quot;join max-w-sm&quot;&gt;<br>                    &lt;input type=&quot;email&quot; wire:model=&quot;email&quot;<br>                        class=&quot;join-item input {{ session()-&gt;has(&#39;success&#39;) ? &#39;is-valid&#39; : &#39;&#39; }} {{ $errors-&gt;has(&#39;email&#39;) ? &#39;is-invalid&#39; : &#39;&#39; }}&quot;<br>                        placeholder=&quot;Email&quot;&gt;<br>                    &lt;button wire:click=&quot;subscribe&quot; class=&quot;join-item btn btn-primary&quot;&gt;Subscribe&lt;/button&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br>            @error(&#39;email&#39;)<br>                &lt;span class=&quot;label&quot;&gt;<br>                    &lt;span class=&quot;label-text-alt text-error&quot;&gt;{{ $message }}&lt;/span&gt;<br>                &lt;/span&gt;<br>            @enderror<br>            @if (session()-&gt;has(&#39;success&#39;) &amp;&amp; $successAlert)<br>                &lt;div class=&quot;alert alert-soft alert-success max-w-sm mt-2&quot; role=&quot;alert&quot; id=&quot;dismiss-alert&quot;&gt;<br>                    {{ session(&#39;success&#39;) }}<br>                    &lt;button class=&quot;ms-auto leading-none&quot; wire:click=&quot;closeAlert&quot; aria-label=&quot;Close Button&quot;&gt;<br>                        &lt;span class=&quot;icon-[tabler--x] size-5&quot;&gt;&lt;/span&gt;<br>                    &lt;/button&gt;<br>                &lt;/div&gt;<br>            @endif<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*FfJH7Z03oN1LntjOCLV0aQ.png" /><figcaption>subscribe component in the home page</figcaption></figure><p>And for the final component, we have the <strong>footer</strong>. Similar to the <strong>navbar</strong>, the footer will be displayed across all pages, so we’ll use a simple Blade component instead of a Livewire component. This approach ensures reusability and keeps our layout clean.</p><p>To create the footer, add a new file in the resources/views/components/ directory called footer.blade.php. Inside this file, we&#39;ll define the footer layout:</p><pre>&lt;footer class=&quot;footer bg-base-200/60 px-6 py-4&quot;&gt;<br>    &lt;div class=&quot;flex w-full items-center justify-between&quot;&gt;<br>    &lt;aside class=&quot;grid-flow-col items-center&quot;&gt;<br>      &lt;p&gt;©2024 &lt;a class=&quot;link link-hover font-medium&quot; href=&quot;#&quot;&gt;FlyonUI&lt;/a&gt;&lt;/p&gt;<br>    &lt;/aside&gt;<br>      &lt;div class=&quot;flex gap-4 h-5&quot;&gt;<br>        &lt;a href=&quot;#&quot; class=&quot;link&quot; aria-label=&quot;Github Link&quot;&gt;<br>          &lt;span class=&quot;icon-[tabler--brand-github] size-5&quot;&gt;&lt;/span&gt;<br>        &lt;/a&gt;<br>        &lt;a href=&quot;#&quot; class=&quot;link&quot; aria-label=&quot;Facebook Link&quot;&gt;<br>          &lt;span class=&quot;icon-[tabler--brand-facebook] size-5&quot;&gt;&lt;/span&gt;<br>        &lt;/a&gt;<br>        &lt;a href=&quot;#&quot; class=&quot;link&quot; aria-label=&quot;X Link&quot;&gt;<br>          &lt;span class=&quot;icon-[tabler--brand-x] size-5&quot;&gt;&lt;/span&gt;<br>        &lt;/a&gt;<br>        &lt;a href=&quot;#&quot; class=&quot;link&quot; aria-label=&quot;Google Link&quot;&gt;<br>          &lt;span class=&quot;icon-[tabler--brand-google] size-5&quot;&gt;&lt;/span&gt;<br>        &lt;/a&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/footer&gt;</pre><p>And for the layouts/app.blade.php file now like this :</p><pre>@extends(&#39;layouts.base&#39;)<br><br>@section(&#39;body&#39;)<br>    @include(&#39;components.navbar&#39;)<br><br>    @yield(&#39;content&#39;)<br><br>    @isset($slot)<br>        {{ $slot }}<br>    @endisset<br><br>    @include(&#39;components.footer&#39;)<br>@endsection</pre><p>And final home.blade.php after all components created is :</p><pre>&lt;div&gt;<br>    &lt;!-- Carousel --&gt;<br>    &lt;livewire:home.carousel /&gt;<br><br>    &lt;div class=&quot;max-w-screen-lg mx-auto&quot;&gt;<br>        &lt;!-- Latest Posts --&gt;<br>        &lt;livewire:home.latest-post /&gt;<br><br>        &lt;!-- Subscribe Blog --&gt;<br>        &lt;livewire:home.subscribe /&gt;<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><p>And here’s the final look after all components are created: a sleek, functional, and visually appealing blog landing page. With the <strong>navbar</strong>, <strong>carousel</strong>, <strong>latest posts</strong>, <strong>subscribe section</strong>, and <strong>footer</strong> in place, the page now feels complete and polished.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kc-eqZcopyMGF0sib9oksA.png" /></figure><p>With the landing page complete, we’ve set the stage for the next part of our journey. In the upcoming story, we’ll dive into creating the <strong>blog page</strong>, where posts will be listed and displayed in detail. This is where our blog truly comes to life, showcasing the content we’ve been working toward.</p><p>Stay tuned for the next chapter as we continue to build our simple blog step by step!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54d98810961c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Blog Landing Page Based On Filament Series Simple Blog Admin (Part 1)]]></title>
            <link>https://medium.com/@halimdirgantara/create-blog-landing-page-based-on-filament-series-simple-blog-admin-part-1-51cfbafcd2b2?source=rss-9071d164c88a------2</link>
            <guid isPermaLink="false">https://medium.com/p/51cfbafcd2b2</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[muhammadhalimdirgantara]]></dc:creator>
            <pubDate>Tue, 14 Jan 2025 22:48:12 GMT</pubDate>
            <atom:updated>2025-01-15T11:40:47.465Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Read filament series, <a href="https://medium.com/@halimdirgantara/list/filament-series-fdf8ad5ae252">Creating Simple Blog Admin Using Filament </a>before you read this!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*C8E4sKgPPCFiHD2TdHpaEg.png" /></figure><p>After creating our simple blog admin, we’re now moving to the next step: building a visually appealing and responsive landing page for our blog. We’ll use Blade Template with Livewire and Tailwind CSS to design a modern and user-friendly interface that enhances the overall blog experience.</p><p>Before we dive into creating the user interface, we first need to populate categories, tags and posts as mock data for our blog, so the page isn’t empty. We’ll use a factory to populate posts using the following syntax php artisan make:factory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*6L9ozQOTCFzqIH-4baaEIw.png" /><figcaption>create fake data</figcaption></figure><p>So now, we have 3 factories, CategoryFactory.php , TagFactory.phpand finally PostFactory.php . The code inside each factory is as follows, in order:</p><pre>use Illuminate\Support\Str;<br>use Illuminate\Support\Facades\Storage;<br><br>class CategoryFactory extends Factory<br>{<br>    public function definition(): array<br>    {<br>        $name = fake()-&gt;word();<br>        <br>        // Generate random image and save to storage<br>        $imageUrl = &#39;https://picsum.photos/640/480&#39;;<br>        $imageContents = file_get_contents($imageUrl);<br>        $imageName = &#39;category_image/&#39; . $name . &#39;.jpg&#39;;<br>        <br>        // Store the image<br>        Storage::disk(&#39;public&#39;)-&gt;put($imageName, $imageContents);<br><br>        return [<br>            &#39;name&#39; =&gt; $name,<br>            &#39;slug&#39; =&gt; Str::slug($name),<br>            &#39;description&#39; =&gt; fake()-&gt;sentence(),<br>            &#39;image&#39; =&gt; $imageName, // Save the path instead of URL<br>        ];<br>    }<br>}</pre><pre>use Illuminate\Support\Str;<br><br>class TagFactory extends Factory<br>{<br>    public function definition(): array<br>    {<br>        $name = fake()-&gt;word();<br>        return [<br>            &#39;name&#39; =&gt; $name,<br>            &#39;slug&#39; =&gt; Str::slug($name),<br>        ];<br>    }<br>}</pre><pre>use App\Models\User;<br>use App\Models\Category;<br>use Illuminate\Support\Str;<br>use Illuminate\Support\Facades\Storage;<br><br>class PostFactory extends Factory<br>{<br>    public function definition(): array<br>    {<br>        $title = fake()-&gt;sentence();<br><br>        // Generate random image and save to storage<br>        $imageUrl = &#39;https://picsum.photos/640/480&#39;;<br>        $imageContents = file_get_contents($imageUrl);<br>        $imageName = &#39;feature_image/&#39; . $title . &#39;.jpg&#39;;<br>        <br>        // Store the image<br>        Storage::disk(&#39;public&#39;)-&gt;put($imageName, $imageContents);<br><br>        return [<br>            &#39;title&#39; =&gt; $title,<br>            &#39;slug&#39; =&gt; Str::slug($title),<br>            &#39;body&#39; =&gt; fake()-&gt;paragraph(),<br>            &#39;feature_image&#39; =&gt; $imageName,<br>            &#39;status&#39; =&gt; &#39;published&#39;,<br>            &#39;category_id&#39; =&gt; Category::factory(),<br>            &#39;created_by&#39; =&gt; User::factory(),<br>        ];<br>    }<br>}</pre><p>We also need UserFactory.php tto assign each post to a user who created it. Here’s the code for that:</p><pre>use Illuminate\Support\Facades\Hash;<br>use Illuminate\Support\Str;<br><br>class UserFactory extends Factory<br>{<br>    protected static ?string $password;<br><br>    public function definition(): array<br>    {<br>        return [<br>            &#39;name&#39; =&gt; fake()-&gt;name(),<br>            &#39;email&#39; =&gt; fake()-&gt;unique()-&gt;safeEmail(),<br>            &#39;email_verified_at&#39; =&gt; now(),<br>            &#39;password&#39; =&gt; static::$password ??= Hash::make(&#39;password&#39;),<br>            &#39;remember_token&#39; =&gt; Str::random(10),<br>        ];<br>    }<br>}</pre><p>Now, to run all the factories mentioned above, we need to modify DatabaseSeeder.php accommodate the code and assign some tables to others. ut before that, we also need a RoleSeeder to create roles for our users. We can create the seeder using this command: php artisan make:seeder RoleSeeder Then, we fill it up using the following code:</p><pre>use Spatie\Permission\Models\Role;<br><br>class RoleSeeder extends Seeder<br>{<br>    public function run(): void<br>    {<br>        if (!Role::where(&#39;name&#39;, &#39;Super Admin&#39;)-&gt;exists()) {<br>            Role::create([<br>                &#39;name&#39; =&gt; &#39;Super Admin&#39;,<br>                &#39;guard_name&#39; =&gt; &#39;web&#39;,<br>            ]);<br>        }<br><br>        Role::create([<br>            &#39;name&#39; =&gt; &#39;Editor&#39;,<br>            &#39;guard_name&#39; =&gt; &#39;web&#39;,<br>        ]);<br><br>        Role::create([<br>            &#39;name&#39; =&gt; &#39;Author&#39;,<br>            &#39;guard_name&#39; =&gt; &#39;web&#39;,<br>        ]);<br>    }<br>}</pre><p>It looks like our setup for mock posts is complete! Now, we can proceed to write the DatabaseSeeder to bring everything together. The DatabaseSeeder will seed the database with categories, tags, users, and posts, linking them appropriately to create a fully functional mock setup for our blog. Here&#39;s the code you can use:</p><pre>use App\Models\Tag;<br>use App\Models\Post;<br>use App\Models\User;<br>use App\Models\Category;<br>use Illuminate\Database\Seeder;<br>use Spatie\Permission\Models\Role;<br><br>class DatabaseSeeder extends Seeder<br>{<br>    public function run(): void<br>    {<br>        $this-&gt;call([<br>            RoleSeeder::class,<br>        ]);<br><br>        $users = User::factory(20)-&gt;create();<br><br>        $users-&gt;each(function ($user) {<br>            $user-&gt;assignRole(Role::inRandomOrder()-&gt;first()-&gt;name);<br>        });<br><br>        Category::factory(20)-&gt;create();<br>        Tag::factory(20)-&gt;create();<br><br>        $posts =    Post::factory(20)-&gt;create();<br>        $posts-&gt;each(function ($post) {<br>            $post-&gt;tags()-&gt;attach(Tag::inRandomOrder()-&gt;first()-&gt;id);<br>        });<br>    }<br>}</pre><p>That wraps up this part of setting up our mock data for the blog. With all the factories and seeders in place, we can now run the following command to seed the database, php artisan db:seed</p><p>Once that’s done, we’re ready to move on to the exciting part. In the next section, we’ll dive into designing the landing page and bringing our blog to life. Stay tuned for Part 2!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51cfbafcd2b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>