init - build foundation #1

Closed
opened 2026-07-29 18:45:42 +02:00 by nico · 1 comment
Owner

Project Bootstrap Prompt

Create a production-ready Go web application that follows the architectural philosophy of Miniflux v2.

Core Philosophy

  • Use Go 1.25+.
  • Build a modular monolith.
  • One executable.
  • One PostgreSQL database.
  • No microservices.
  • No frontend framework.
  • No Node.js.
  • No npm.
  • No Vite.
  • No React/Vue/Svelte.
  • Prefer the Go standard library over external frameworks.
  • Keep dependencies minimal.
  • Favor explicit code over magic.

Web Stack

Backend:

  • net/http
  • html/template
  • database/sql
  • pgx PostgreSQL driver
  • Go embed for static assets

Frontend:

  • Server-side rendered HTML templates
  • Plain CSS
  • Vanilla JavaScript only where necessary
  • Progressive enhancement
  • Responsive layout
  • Accessible HTML

Authentication

Implement session-based authentication.

Features:

  • Login
  • Logout
  • Password hashing with bcrypt or Argon2id
  • Secure HTTP-only cookies
  • CSRF protection
  • Remember-me option (optional)
  • Middleware for authentication
  • Middleware for authorization

User roles:

  • Anonymous
  • User
  • Admin

Permissions:

Anonymous

  • View welcome page
  • Login

User

  • Dashboard
  • Profile
  • Change password

Admin

  • User management
  • System settings
  • Admin dashboard

Do not hardcode permissions.
Design a reusable authorization layer.

API

Expose a versioned REST API.

Base path:

/api/v1

Authentication:

  • Session authentication
  • API tokens (design should allow adding them later)

Return JSON.

Create endpoints:

GET /health

GET /me

POST /login

POST /logout

GET /users
(admin)

GET /users/{id}
(admin)

POST /users
(admin)

PUT /users/{id}
(admin)

DELETE /users/{id}
(admin)

Separate API handlers from HTML handlers.

Business logic should be shared.

Pages

Initially only create:

/

A welcome page.

Content:

  • Application title
  • Short description
  • Login button
  • Footer

Authenticated users visiting "/" should be redirected to "/dashboard".

Dashboard can initially display:

Welcome, {{username}}

Templates

Use html/template.

Structure:

templates/

layout.html

header.html

footer.html

welcome.html

login.html

dashboard.html

admin/

users.html

Use template inheritance or composition.

Static Assets

/assets

/css

/app.css

/js

/app.js

/images

Embed all assets into the Go binary.

Database

Use PostgreSQL.

Use plain SQL.

No ORM.

Provide SQL migrations.

Suggested tables:

users

sessions

schema_migrations

Users:

id

email

username

password_hash

role

created_at

updated_at

Sessions:

id

user_id

token

expires_at

created_at

Project Structure

cmd/

server/

internal/

auth/

config/

database/

handlers/

middleware/

models/

services/

storage/

templates/

api/

ui/

assets/

migrations/

Keep packages small and cohesive.

Architecture Rules

HTTP handlers should never contain business logic.

Business logic belongs in services.

Database access belongs in repositories/storage.

Templates should only render data.

Middleware handles:

  • authentication
  • authorization
  • logging
  • request IDs
  • panic recovery

Configuration

Support:

environment variables

.env file

development

production

Logging

Structured logging.

Request logging.

Error logging.

No println debugging.

Error Handling

Central error renderer.

HTML requests return HTML errors.

API requests return JSON errors.

Security

CSRF protection.

Content Security Policy.

Secure cookies.

Password hashing.

Input validation.

Parameterized SQL.

Rate limiting hooks.

Testing

Include:

unit tests for services

repository tests

handler tests

Future Extensibility

The architecture should make it easy to later add:

  • email verification
  • password reset
  • OAuth
  • TOTP/MFA
  • audit log
  • notifications
  • background jobs
  • RSS ingestion
  • WebSocket support

without requiring a rewrite.

Code Style

Prefer explicit code over abstraction.

Avoid unnecessary interfaces.

Avoid dependency injection frameworks.

Keep functions small.

Write readable SQL.

Favor composition over inheritance.

Generate complete working code with explanatory comments where appropriate.

# Project Bootstrap Prompt Create a production-ready Go web application that follows the architectural philosophy of Miniflux v2. ## Core Philosophy * Use Go 1.25+. * Build a modular monolith. * One executable. * One PostgreSQL database. * No microservices. * No frontend framework. * No Node.js. * No npm. * No Vite. * No React/Vue/Svelte. * Prefer the Go standard library over external frameworks. * Keep dependencies minimal. * Favor explicit code over magic. ## Web Stack Backend: * net/http * html/template * database/sql * pgx PostgreSQL driver * Go embed for static assets Frontend: * Server-side rendered HTML templates * Plain CSS * Vanilla JavaScript only where necessary * Progressive enhancement * Responsive layout * Accessible HTML ## Authentication Implement session-based authentication. Features: * Login * Logout * Password hashing with bcrypt or Argon2id * Secure HTTP-only cookies * CSRF protection * Remember-me option (optional) * Middleware for authentication * Middleware for authorization User roles: * Anonymous * User * Admin Permissions: Anonymous * View welcome page * Login User * Dashboard * Profile * Change password Admin * User management * System settings * Admin dashboard Do not hardcode permissions. Design a reusable authorization layer. ## API Expose a versioned REST API. Base path: /api/v1 Authentication: * Session authentication * API tokens (design should allow adding them later) Return JSON. Create endpoints: GET /health GET /me POST /login POST /logout GET /users (admin) GET /users/{id} (admin) POST /users (admin) PUT /users/{id} (admin) DELETE /users/{id} (admin) Separate API handlers from HTML handlers. Business logic should be shared. ## Pages Initially only create: / A welcome page. Content: * Application title * Short description * Login button * Footer Authenticated users visiting "/" should be redirected to "/dashboard". Dashboard can initially display: Welcome, {{username}} ## Templates Use html/template. Structure: templates/ layout.html header.html footer.html welcome.html login.html dashboard.html admin/ users.html Use template inheritance or composition. ## Static Assets /assets /css /app.css /js /app.js /images Embed all assets into the Go binary. ## Database Use PostgreSQL. Use plain SQL. No ORM. Provide SQL migrations. Suggested tables: users sessions schema_migrations Users: id email username password_hash role created_at updated_at Sessions: id user_id token expires_at created_at ## Project Structure cmd/ server/ internal/ auth/ config/ database/ handlers/ middleware/ models/ services/ storage/ templates/ api/ ui/ assets/ migrations/ Keep packages small and cohesive. ## Architecture Rules HTTP handlers should never contain business logic. Business logic belongs in services. Database access belongs in repositories/storage. Templates should only render data. Middleware handles: * authentication * authorization * logging * request IDs * panic recovery ## Configuration Support: environment variables .env file development production ## Logging Structured logging. Request logging. Error logging. No println debugging. ## Error Handling Central error renderer. HTML requests return HTML errors. API requests return JSON errors. ## Security CSRF protection. Content Security Policy. Secure cookies. Password hashing. Input validation. Parameterized SQL. Rate limiting hooks. ## Testing Include: unit tests for services repository tests handler tests ## Future Extensibility The architecture should make it easy to later add: * email verification * password reset * OAuth * TOTP/MFA * audit log * notifications * background jobs * RSS ingestion * WebSocket support without requiring a rewrite. ## Code Style Prefer explicit code over abstraction. Avoid unnecessary interfaces. Avoid dependency injection frameworks. Keep functions small. Write readable SQL. Favor composition over inheritance. Generate complete working code with explanatory comments where appropriate.
nico self-assigned this 2026-07-29 18:45:42 +02:00
nico added this to the (deleted) project 2026-07-29 18:45:42 +02:00
Author
Owner

very fist / setup:

Bootstrap an AI-First Go Project

Initialize this repository for long-term AI-assisted development.

The goal is to create a codebase that remains simple, maintainable, and enjoyable to work on for years—not just one that works today.

The project philosophy is heavily inspired by:

  • Miniflux
  • SQLite
  • Go standard library projects
  • Basecamp's "Shape Up" mindset
  • YAGNI
  • KISS
  • Test-Driven Development
  • The Ponytail Rule

The repository should optimize for clarity over cleverness.


Generate the following files

README.md
AGENT.md
SPEC.md
TASKS.md
CONTRIBUTING.md
DECISIONS.md
.editorconfig
.env.example
.gitignore
.golangci.yml
Makefile

docs/
    architecture.md

adr/
    0001-simple-stack.md

AGENT.md

Create a comprehensive guide describing how AI agents should work inside this repository.

Include the following sections.


Mission

Build software that is:

  • simple
  • maintainable
  • testable
  • explicit
  • boring in a good way

Optimize for the next developer reading the code.


Engineering Values

Always prefer:

  • simplicity
  • readability
  • explicit code
  • deterministic behavior
  • small changes
  • maintainability

Never optimize for novelty.


Core Principles

Follow these principles in order.

  1. Correctness
  2. Simplicity
  3. Readability
  4. Testability
  5. Performance

Performance only matters after measurement.


YAGNI

Do not implement future features.

Do not create extension points without actual consumers.

Do not build configuration systems before they are needed.


Ponytail Rule

Every abstraction must have at least two real use cases.

Never introduce:

  • interfaces
  • factories
  • builders
  • generic helpers
  • middleware
  • service layers
  • repositories

unless there are at least two concrete implementations or consumers.

Duplication is acceptable until patterns emerge.


KISS

Prefer:

small packages

small files

small functions

small structs

small commits


TDD

Every feature should follow:

Red

Green

Refactor

Write the failing test first.

Implement only enough code to pass.

Refactor only after all tests pass.

Tests should explain behavior.


Architecture

Use a modular monolith.

One binary.

One PostgreSQL database.

One deployable artifact.

One codebase.


Tech Stack

Language

  • Go

Backend

  • net/http
  • html/template
  • database/sql
  • pgx

Frontend

  • HTML templates
  • CSS
  • Vanilla JavaScript

Database

  • PostgreSQL

Assets

  • Go embed

No:

  • React
  • Vue
  • Angular
  • Svelte
  • Node.js
  • npm
  • Vite
  • ORM
  • dependency injection framework

Layering

Handlers

Application Services

Storage

PostgreSQL

Business logic must never exist in handlers.

Templates should never contain business logic.


Dependency Policy

Before adding a dependency ask:

Can the Go standard library solve this?

Can existing code solve this?

Does this dependency remove more code than it adds?

If not, don't add it.


Coding Style

Prefer:

early returns

descriptive names

small functions

explicit errors

clear SQL

simple templates

Avoid:

magic

reflection

hidden state

global mutable variables

over-abstraction

premature optimization


Error Handling

Return errors.

Wrap errors with context.

Never panic in business logic.

Render friendly HTML errors.

Return structured JSON API errors.


Logging

Use structured logging.

No debug print statements.

Log meaningful events only.


Security

Always:

validate input

hash passwords

parameterize SQL

protect against CSRF

use secure cookies

use Content Security Policy


Definition of Done

A task is complete only when:

  • tests pass
  • code is formatted
  • documentation is updated
  • dead code is removed
  • no unnecessary abstraction exists

AI Workflow

Before writing code:

Understand existing code.

Search before creating.

Reuse before rewriting.

Prefer editing existing files over creating new ones.

Never rename large parts of the project unless explicitly requested.

Avoid large rewrites.

Explain trade-offs.

Keep commits focused.


README.md

Create a concise README containing:

Purpose

Technology

Architecture

Getting Started

Development

Testing

Project Structure

Philosophy


SPEC.md

Describe the application.

Include:

Purpose

Target users

Core features

Authentication

Authorization

REST API

Pages

Future roadmap

Explicit non-goals

Keep this document short and easy to update.


TASKS.md

Maintain a living backlog.

Sections:

Now

Next

Later

Ideas

Done

Tasks should be small enough to finish within one focused session.


CONTRIBUTING.md

Document:

Development setup

Running locally

Database migrations

Testing

Linting

Formatting

Commit message conventions

Pull request expectations

Definition of Done


DECISIONS.md

Maintain a chronological engineering decision log.

Each entry should include:

Date

Decision

Reasoning

Alternatives considered

Consequences

Use this for lightweight architectural history.


docs/architecture.md

Describe:

System overview

HTTP request lifecycle

Package organization

Layer responsibilities

Authentication flow

API design

Template rendering

Database access

Keep diagrams ASCII only.


adr/0001-simple-stack.md

Document why the project intentionally avoids:

Frontend frameworks

ORMs

Microservices

Dependency injection

Enterprise architecture

Discuss the trade-offs honestly.


Makefile

Create developer commands:

fmt

test

lint

check

run

build

clean


.golangci.yml

Configure sensible linting.

Avoid extremely opinionated rules.

Prioritize correctness and readability.


Repository Standards

The repository should encourage:

small commits

small pull requests

frequent testing

explicit code

minimal dependencies

simple architecture

long-lived maintainability


General Rules

Whenever implementing code:

  • Prefer deleting code over adding code.
  • Prefer simple solutions over generic ones.
  • Prefer duplication over premature abstraction.
  • Every abstraction must justify its existence.
  • Every dependency must justify its existence.
  • Every file should have a single responsibility.
  • If a solution feels "clever," rewrite it until it feels obvious.
  • Optimize for the developer reading the code six months from now.

If multiple valid implementations exist, choose the one with the fewest concepts, the fewest moving parts, and the smallest maintenance burden.

very fist / setup: # Bootstrap an AI-First Go Project Initialize this repository for long-term AI-assisted development. The goal is to create a codebase that remains simple, maintainable, and enjoyable to work on for years—not just one that works today. The project philosophy is heavily inspired by: * Miniflux * SQLite * Go standard library projects * Basecamp's "Shape Up" mindset * YAGNI * KISS * Test-Driven Development * The Ponytail Rule The repository should optimize for **clarity over cleverness**. --- # Generate the following files ``` README.md AGENT.md SPEC.md TASKS.md CONTRIBUTING.md DECISIONS.md .editorconfig .env.example .gitignore .golangci.yml Makefile docs/ architecture.md adr/ 0001-simple-stack.md ``` --- # AGENT.md Create a comprehensive guide describing how AI agents should work inside this repository. Include the following sections. --- ## Mission Build software that is: * simple * maintainable * testable * explicit * boring in a good way Optimize for the next developer reading the code. --- ## Engineering Values Always prefer: * simplicity * readability * explicit code * deterministic behavior * small changes * maintainability Never optimize for novelty. --- ## Core Principles Follow these principles in order. 1. Correctness 2. Simplicity 3. Readability 4. Testability 5. Performance Performance only matters after measurement. --- ## YAGNI Do not implement future features. Do not create extension points without actual consumers. Do not build configuration systems before they are needed. --- ## Ponytail Rule Every abstraction must have at least two real use cases. Never introduce: * interfaces * factories * builders * generic helpers * middleware * service layers * repositories unless there are at least two concrete implementations or consumers. Duplication is acceptable until patterns emerge. --- ## KISS Prefer: small packages small files small functions small structs small commits --- ## TDD Every feature should follow: Red Green Refactor Write the failing test first. Implement only enough code to pass. Refactor only after all tests pass. Tests should explain behavior. --- ## Architecture Use a modular monolith. One binary. One PostgreSQL database. One deployable artifact. One codebase. --- ## Tech Stack Language * Go Backend * net/http * html/template * database/sql * pgx Frontend * HTML templates * CSS * Vanilla JavaScript Database * PostgreSQL Assets * Go embed No: * React * Vue * Angular * Svelte * Node.js * npm * Vite * ORM * dependency injection framework --- ## Layering Handlers ↓ Application Services ↓ Storage ↓ PostgreSQL Business logic must never exist in handlers. Templates should never contain business logic. --- ## Dependency Policy Before adding a dependency ask: Can the Go standard library solve this? Can existing code solve this? Does this dependency remove more code than it adds? If not, don't add it. --- ## Coding Style Prefer: early returns descriptive names small functions explicit errors clear SQL simple templates Avoid: magic reflection hidden state global mutable variables over-abstraction premature optimization --- ## Error Handling Return errors. Wrap errors with context. Never panic in business logic. Render friendly HTML errors. Return structured JSON API errors. --- ## Logging Use structured logging. No debug print statements. Log meaningful events only. --- ## Security Always: validate input hash passwords parameterize SQL protect against CSRF use secure cookies use Content Security Policy --- ## Definition of Done A task is complete only when: * tests pass * code is formatted * documentation is updated * dead code is removed * no unnecessary abstraction exists --- ## AI Workflow Before writing code: Understand existing code. Search before creating. Reuse before rewriting. Prefer editing existing files over creating new ones. Never rename large parts of the project unless explicitly requested. Avoid large rewrites. Explain trade-offs. Keep commits focused. --- # README.md Create a concise README containing: Purpose Technology Architecture Getting Started Development Testing Project Structure Philosophy --- # SPEC.md Describe the application. Include: Purpose Target users Core features Authentication Authorization REST API Pages Future roadmap Explicit non-goals Keep this document short and easy to update. --- # TASKS.md Maintain a living backlog. Sections: Now Next Later Ideas Done Tasks should be small enough to finish within one focused session. --- # CONTRIBUTING.md Document: Development setup Running locally Database migrations Testing Linting Formatting Commit message conventions Pull request expectations Definition of Done --- # DECISIONS.md Maintain a chronological engineering decision log. Each entry should include: Date Decision Reasoning Alternatives considered Consequences Use this for lightweight architectural history. --- # docs/architecture.md Describe: System overview HTTP request lifecycle Package organization Layer responsibilities Authentication flow API design Template rendering Database access Keep diagrams ASCII only. --- # adr/0001-simple-stack.md Document why the project intentionally avoids: Frontend frameworks ORMs Microservices Dependency injection Enterprise architecture Discuss the trade-offs honestly. --- # Makefile Create developer commands: fmt test lint check run build clean --- # .golangci.yml Configure sensible linting. Avoid extremely opinionated rules. Prioritize correctness and readability. --- # Repository Standards The repository should encourage: small commits small pull requests frequent testing explicit code minimal dependencies simple architecture long-lived maintainability --- # General Rules Whenever implementing code: * Prefer deleting code over adding code. * Prefer simple solutions over generic ones. * Prefer duplication over premature abstraction. * Every abstraction must justify its existence. * Every dependency must justify its existence. * Every file should have a single responsibility. * If a solution feels "clever," rewrite it until it feels obvious. * Optimize for the developer reading the code six months from now. If multiple valid implementations exist, choose the one with the fewest concepts, the fewest moving parts, and the smallest maintenance burden.
nico closed this issue 2026-07-29 19:34:05 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nico/secondbrain#1
No description provided.