Directory Structure
Krewire establishes predictable, standardized project structures designed to scale gracefully from single-file prototypes into enterprise modular monoliths.
1. Standard Project Anatomy
Below is the standard, unified file layout of a comprehensive Krewire project:
my-project/
โโโ krewire.yaml # Devtool & build pipeline configuration
โโโ go.mod # Go module definition
โโโ go.sum # Dependency checksums
โ
โโโ pages/ # File-based routes (.kiw component files)
โ โโโ index.kiw # Serves "/"
โ โโโ about.kiw # Serves "/about"
โ โโโ 404.html # Custom error page
โ
โโโ layouts/ # Shared page wrappers (.kiw)
โ โโโ Base.kiw # Default HTML document layout
โ โโโ Landing.kiw # Full-bleed landing page layout
โ
โโโ components/ # Reusable scoped UI components (.kiw)
โ โโโ Header.kiw # Navigation bar
โ โโโ Footer.kiw # Footer section
โ โโโ CodeBlock.kiw # Syntax highlighter component
โ
โโโ content/ # Documentation manuscripts & books (mdbind)
โ โโโ 01-overview/ # Chapter 1 directory
โ โ โโโ index.md # Chapter landing page
โ โ โโโ 01-arch.md # Subchapter 1.1
โ โโโ 02-guides/ # Chapter 2 directory
โ
โโโ public/ # Raw static assets served directly
โ โโโ favicon.svg # Browser favicon
โ โโโ robots.txt # Web crawler configuration
โ โโโ sitemap.xml # Search engine index
โ โโโ assets/ # Client scripts, stylesheets, and images
โ
โโโ cmd/ # Executable Go entry points
โ โโโ my-service/
โ โโโ main.go # Service entry point
โ
โโโ internal/ # Private application logic (enforced by Go compiler)
โ โโโ domain/ # Core business entities & models
โ โโโ handler/ # HTTP & RPC request handlers
โ โโโ service/ # Domain services & business rules
โ
โโโ .krewire/ # Toolchain state & build artifacts (git-ignored)
โโโ build/ # Default compilation output
โโโ .kiw-build-manifest
2. Directory Roles & Responsibilities
pages/ (File-Based Routing)
Files in pages/ map directly to public URL routes:
pages/index.kiwโhttps://example.com/pages/pricing.kiwโhttps://example.com/pricingpages/blog/first-post.kiwโhttps://example.com/blog/first-post
Each .kiw page file encapsulates its YAML frontmatter, HTML template markup, and scoped <style> block.
layouts/ (Document Shells)
Layouts provide the outer HTML shell (<!doctype html>, <head>, <nav>, <footer>) wrapping page content via {{.Content}}. Pages declare their desired layout in frontmatter:
---
title: "Dashboard"
layout: AppLayout
---
components/ (Reusable Scoped Blocks)
Components are standalone .kiw files composed with either the JSX-like <ComponentName /> syntax or the compatible {{component "Name" .}} template helper. Styles inside components are scoped automatically at compile time with zero CSS collisions.
content/ (Manuscript Engine)
Stores Markdown documentation manuscripts compiled by mdbind. Numeric prefixes (01-, 02-) dictate chapter and subchapter reading order in the generated navigation sidebar.
public/ (Uncompiled Static Assets)
Files inside public/ are served verbatim without preprocessing:
public/favicon.svgis served at/favicon.svg.public/robots.txtis served at/robots.txt.public/assets/contains client scripts and CSS stylesheets. Files ending in.cssor.jsare linked into every page automatically โ no<link>or<script>tag in the layout is required.
cmd/ & internal/ (Go Application Core)
cmd/<name>/main.go: Main entry points for fullstack monoliths (app), CLI utilities (cli), or background workers (worker).internal/: Go compiler-enforced private packages. Code insideinternal/cannot be imported by external modules, preserving clean architectural encapsulation (KWF-5ZHQV).
.krewire/ (Build Artifacts)
Created automatically by kiw dev and kiw build:
.krewire/build/: Houses the compiled production output ready for static hosting or Docker image packaging.- This directory is managed by
kiwand should always be added to your.gitignore.
3. Workload-Specific Layouts
When scaffolding a new project via kiw new <project> [flags], kiw equips the directory structure tailored to that workload:
1. Static Site (kiw new my-site --site)
my-site/
โโโ krewire.yaml
โโโ go.mod
โโโ pages/
โ โโโ index.kiw
โโโ layouts/
โ โโโ Base.kiw
โโโ components/
โโโ public/
2. Documentation Book (kiw new my-docs --book)
my-docs/
โโโ krewire.yaml
โโโ go.mod
โโโ content/
โโโ index.md
โโโ 01-getting-started.md
3. Fullstack Monolith (kiw new my-app --app)
my-app/
โโโ krewire.yaml
โโโ go.mod
โโโ cmd/
โ โโโ my-app/
โ โโโ main.go
โโโ web/
โ โโโ router.go
โ โโโ handlers/
โโโ internal/
โ โโโ domain/
โโโ public/
4. Terminal CLI (kiw new my-cli --cli)
my-cli/
โโโ krewire.yaml
โโโ go.mod
โโโ cmd/
โ โโโ my-cli/
โ โโโ main.go
โโโ internal/
โโโ commands/
4. Customizing Directory Locations
If you are incorporating Krewire into an established repository with non-standard folder conventions, override them in krewire.yaml:
project:
name: "custom-app"
kind: "app"
dirs:
web: "src/web"
public: "static"
internal: "pkg"
cmd: "entrypoints"
The kiw compiler resolves all paths against these mappings automatically.
Summary
With the installation, configuration, and directory layout understood, you are equipped to build robust applications across any Krewire workload.
Proceed to 2.4 Agentic Development โ to equip your projects with autonomous AI coding agents.