Skip to content

πŸš€ AI-friendly fullstack framework for the GenAI era | Go + TypeScript | Vibe-Coding-Friendly DDD | Domain-First architecture that makes code truly understandable by AI

License

Notifications You must be signed in to change notification settings

erweixin/Go-GenAI-Stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Go-GenAI-Stack

A Full-Stack Development Framework Designed for the AI Era

AI-friendly code structure that turns ideas directly into code

English | δΈ­ζ–‡

Go Version TypeScript License PRs Welcome

Quick Start β€’ Core Features β€’ Architecture β€’ Documentation β€’ Contributing


⚠️ Project Status

🚧 This project is currently in very early development stage. Code structure may change at any time, but the goal is to be a production-ready starter for large commercial projects
🎯 This is an experimental attempt at AI-friendly software architecture
πŸ’‘ Exploring how to make code structure more understandable and generatable by AI

Welcome to discuss and contribute, let's explore best practices for software development in the AI era together!


πŸ“– Core Philosophy

The core ideas and implementation approach of this project come from:
γ€ŠDiscussion on Possible Changes in Software Architecture and Collaboration Relationships in the AI Era》 ⭐


πŸ’‘ Why Choose Go-GenAI-Stack?

In the era of AI programming, traditional project architectures face challenges:

  • ❌ Business rules scattered across code, AI needs to read massive amounts of code to understand intent
  • ❌ Horizontal layered architecture makes it difficult for AI to locate functional boundaries
  • ❌ Implicit domain knowledge requires repeated manual explanations
  • ❌ Test-unfriendly design, automated tests are costly and flaky

Go-GenAI-Stack rethinks how code is organized:

Traditional Architecture Go-GenAI-Stack (Vibe-Coding-Friendly)
Business rules hidden in code Explicit knowledge files (rules.md, glossary.md)
Layered by tech stack Vertically split by business domain
Describe flow with code Declare use cases with YAML (usecases.yaml)
AI needs to read thousands of lines AI reads a few structured files to understand
Manual frontend-backend type sync Go β†’ TypeScript automatic sync
Flaky tests and unstable selectors Playwright-friendly design + data-test-id convention + Docker E2E env

πŸ’‘ Vibe Coding: Express your ideas, AI understands business logic, directly generates code that follows rules.

This project makes AI a true programming partner, not just a code completion tool.


🎯 Project Positioning

This is a production-ready full-stack Starter with a complete Task domain as a best practice example:

  • βœ… Ready to use: If you need task management functionality
  • βœ… Use as template: Map to your business (Product, Order, Article...)
  • βœ… Learn from it: Understand how to build AI-friendly architecture

🌟 Standing on the Shoulders of Giants

  • Backend Architecture inspired by Coze Studio:

    • Domain-Driven Design centered on LLM orchestration
    • Plugin-first and extensibility priority
    • Declarative workflows (usecases.yaml)
  • Mobile Architecture inspired by Bluesky Social App:

    • React Native best practices
    • Native-level performance optimization
    • Cross-platform component design

πŸ“ Project Structure

Go-GenAI-Stack/
β”œβ”€β”€ backend/              # Backend (Go + Hertz + DDD)
β”‚   β”œβ”€β”€ cmd/              # Application entry
β”‚   β”‚   └── server/       # HTTP Server entry
β”‚   β”œβ”€β”€ domains/          # Domain layer (Domain-First)
β”‚   β”‚   β”œβ”€β”€ task/         # Task domain (example implementation) β˜…
β”‚   β”‚   β”‚   β”œβ”€β”€ handlers/ # HTTP adapter layer
β”‚   β”‚   β”‚   β”œβ”€β”€ service/  # Business logic layer
β”‚   β”‚   β”‚   β”œβ”€β”€ model/    # Domain model
β”‚   β”‚   β”‚   └── ...       # Other components
β”‚   β”‚   └── shared/       # Shared components
β”‚   β”œβ”€β”€ infrastructure/   # Infrastructure layer
β”‚   β”‚   β”œβ”€β”€ bootstrap/    # Bootstrap
β”‚   β”‚   β”œβ”€β”€ persistence/  # Persistence (Postgres, Redis)
β”‚   β”‚   β”œβ”€β”€ middleware/   # Middleware
β”‚   β”‚   β”œβ”€β”€ config/       # Configuration management
β”‚   β”‚   └── database/     # Database Schema
β”‚   β”œβ”€β”€ pkg/              # Reusable packages
β”‚   β”‚   └── validator/    # Validator
β”‚   β”œβ”€β”€ migrations/       # Database migrations
β”‚   β”‚   β”œβ”€β”€ atlas/        # Atlas migration files & config
β”‚   β”‚   └── seed/         # Seed data
β”‚   β”œβ”€β”€ shared/           # Shared code
β”‚   β”‚   └── errors/       # Error definitions
β”‚   └── scripts/          # Development scripts
β”œβ”€β”€ frontend/             # Frontend Monorepo
β”‚   β”œβ”€β”€ web/              # React Web application
β”‚   β”œβ”€β”€ mobile/           # React Native mobile application
β”‚   └── shared/           # Frontend shared code
β”‚       β”œβ”€β”€ types/        # TypeScript type definitions
β”‚       β”œβ”€β”€ utils/        # Utility functions
β”‚       └── constants/    # Constants
β”œβ”€β”€ docs/                 # Project documentation
β”œβ”€β”€ docker/               # Docker configuration
└── scripts/              # Project-level scripts

Core Features

🎯 Vibe-Coding-Friendly DDD (Core Highlight)

πŸ“š Explicit Knowledge Files (AI can directly understand)

Each domain requires 6 structured files:

domains/task/
β”œβ”€β”€ πŸ“„ README.md          # Domain overview
β”œβ”€β”€ πŸ“„ glossary.md        # Glossary
β”œβ”€β”€ πŸ“„ rules.md           # Business rules
β”œβ”€β”€ πŸ“„ events.md          # Domain events
β”œβ”€β”€ πŸ“„ usecases.yaml      # Use case declarations ⭐
└── πŸ“„ ai-metadata.json   # AI metadata

AI only needs to read these 6 files to understand complete business logic!

🎭 Declarative Use Cases (Generate code with one sentence)

# usecases.yaml
CreateTask:
  description: "Create new task"
  steps:
    - ValidateInput
    - GenerateTaskID
    - SaveTask
    - PublishEvent
  errors:
    - TASK_TITLE_EMPTY
    - TASK_ALREADY_EXISTS

AI reads YAML β†’ Automatically generates Handler + Tests

βœ… Vibe-Coding-Friendly Advantages

Feature Traditional DDD Vibe-Coding-Friendly DDD Improvement
AI Understanding Speed Need to read thousands of lines Only read 6 structured files 10x ⚑
Onboarding Time 2-3 days 30 minutes (starting from README) 5x πŸš€
Maintenance Cost Search across multiple directories Self-contained (one directory) -70% πŸ’°
Use Case Changes Manually change code + tests Change YAML β†’ AI auto-generates 3x ⚑
Type Safety Manual frontend-backend sync Go β†’ TS automatic sync 100% βœ…

πŸ§ͺ Test-Friendly by Design (Playwright / Vitest Ready)

In AI-assisted development, testability determines how fast AI-generated code can be verified. This project is optimized for automation:

  • Frontend Playwright-friendly: Mandatory data-test-id on all interactive elements; stable routes/state to reduce flakiness; selectors never rely on styling classes.
  • Isolated E2E environment: Docker spins dedicated Postgres (:5433) + Backend (:8081) so dev and E2E can run in parallel; pnpm e2e:all = setup β†’ test β†’ teardown.
  • Stable fixtures: Seed data and fixed test accounts; shared Playwright fixtures/helpers to avoid magic strings.
  • Fast unit feedback: Vitest + happy-dom + thread pool; pnpm test:watch for second-level feedback, pnpm test:coverage for reports.
  • Directory as contract: Feature-local __tests__ beside hooks/stores/api/components so humans/AI can locate behaviors quickly.
  • CI friendly: E2E triple caching (pnpm store / Playwright browsers / Docker layers); backend ./backend/scripts/test_all.sh supports coverage output, reducing pipeline time.

Goal: close the loop of β€œAI generates β†’ automation validates β†’ quick fix” with minimal human regression effort.


Architecture Highlights

1️⃣ Domain-First

βœ… domains/task/        # Organized by business domain
   β”œβ”€β”€ model/           # Domain model
   β”œβ”€β”€ service/         # Business logic
   β”œβ”€β”€ repository/      # Data access
   β”œβ”€β”€ handlers/        # HTTP adapter layer
   └── tests/           # Tests

❌ Traditional layering (hard to locate functionality):
   β”œβ”€β”€ controllers/     # All domains mixed together
   β”œβ”€β”€ services/        # All services mixed together
   └── repositories/    # All repositories mixed together

2️⃣ Self-Contained

Each domain is independent:

  • βœ… Can be understood, modified, and tested separately
  • βœ… Reduces cognitive load (focus on one domain)
  • βœ… Easy parallel development (different teams for different domains)

3️⃣ Three-Layer Architecture (Clear Layering)

// Handler layer (thin): Only HTTP adaptation
func CreateTaskHandler(c *app.RequestContext) {
    var req dto.CreateTaskRequest
    c.BindAndValidate(&req)
    
    // Call Service layer
    output, err := taskService.CreateTask(ctx, input)
    
    c.JSON(200, response)
}

// Service layer (thick): Business logic ⭐
func (s *TaskService) CreateTask(input CreateTaskInput) {
    // 1. Validate business rules
    // 2. Create domain object
    // 3. Persist
    // 4. Publish event
}

// Repository layer: Data access (database/sql, no ORM)
func (r *TaskRepo) Create(task *Task) error {
    query := `INSERT INTO tasks (...) VALUES (...)`
    _, err := r.db.ExecContext(ctx, query, ...)
    return err
}

πŸ€– AI-Assisted Development Workflow

# 1️⃣ You: Add new use case in usecases.yaml
vim backend/domains/task/usecases.yaml

# 2️⃣ AI: Reads explicit knowledge files
# - README.md (understand domain boundaries)
# - glossary.md (understand terminology)
# - rules.md (understand business rules)
# - usecases.yaml (understand use case flow)

# 3️⃣ AI: Auto-generates code
# βœ… handlers/new_usecase.handler.go
# βœ… service/task_service.go (new method)
# βœ… http/dto/new_usecase.go
# βœ… tests/new_usecase.test.go

# 4️⃣ You: Run tests and commit
./backend/scripts/test_all.sh
git commit -m "feat(task): add new usecase"

True Vibe Coding: You only need to express intent, AI completes the implementation!


πŸ› οΈ Complete Development Toolchain

Tool Purpose Command
Atlas Database Schema management cd backend/database && make diff/apply
Type Sync Go β†’ TypeScript type sync ./scripts/sync_types.sh all
Testing Unit + Integration + E2E ./backend/scripts/test_all.sh / pnpm test / pnpm e2e:all
Linting Code quality check ./backend/scripts/lint.sh --fix
Docker One-click full environment ./scripts/quickstart.sh

πŸ“Š Production-Grade Observability

Complete three pillars observability solution (with toggle control):

πŸ” Structured Logging

  • uber-go/zap
  • JSON/Console format
  • Log rotation
  • Request tracing

πŸ“ˆ Prometheus Metrics

  • QPS, latency, error rate
  • Business metrics
  • System metrics
  • /metrics endpoint

πŸ”— Distributed Tracing

  • OpenTelemetry
  • Jaeger / Tempo
  • Cross-service tracing
  • Performance profiling
// One-click toggle (via config file)
observability:
  logging:
    enabled: true      # Logging
  metrics:
    enabled: true      # Metrics
  tracing:
    enabled: true      # Tracing

Access:

  • Health check: http://localhost:8080/health
  • Prometheus: http://localhost:8080/metrics
  • Grafana: http://localhost:3000 (full monitoring)

πŸ“– Detailed docs: Observability Guide


πŸš€ Quick Start

⚑ One-Click Start (Recommended)

The easiest way to get started:

# 1️⃣ Clone the project
git clone https://github.com/erweixin/Go-GenAI-Stack.git
cd Go-GenAI-Stack

# 2️⃣ One-click start (Backend + Database)
./scripts/quickstart.sh

This script will:

  • βœ… Check dependencies (Go, Docker)
  • βœ… Setup environment variables (copy from .env.example if needed)
  • βœ… Start PostgreSQL and Redis (Docker)
  • βœ… Run database migrations (Atlas)
  • βœ… Load seed data
  • βœ… Start backend server

Access services:

  • πŸ”— Backend API: http://localhost:8080/api
  • ❀️ Health check: http://localhost:8080/health
  • πŸ“Š Prometheus Metrics: http://localhost:8080/metrics

🌐 Start Full Stack (Backend + Frontend)

For full-stack development:

# 1. Start backend (in one terminal)
./scripts/quickstart.sh

# 2. Start frontend (in another terminal)
cd frontend
pnpm install
cd web
pnpm dev

Access:

  • 🌐 Frontend Web: http://localhost:5173
  • πŸ”— Backend API: http://localhost:8080/api

🐳 Docker Production Mode

Start complete production environment with monitoring:

# Start all services (Backend + Monitoring)
./scripts/start-all.sh

Access services:

  • πŸ”— Backend API: http://localhost:8080
  • πŸ“Š Grafana: http://localhost:3000 (admin/admin)
  • πŸ” Jaeger: http://localhost:16686
  • πŸ“ˆ Prometheus: http://localhost:9090
  • πŸ› Sentry: http://localhost:9000

Note: Frontend needs to be built and deployed separately. See Frontend README for build instructions.


πŸ› οΈ Local Development Mode (Manual Setup)

Click to expand detailed steps

Prerequisites

  • Go 1.23+
  • Node.js 22.0+
  • pnpm 8.0+
  • Docker & Docker Compose (for databases)
  • Atlas (Schema management)
# Install Atlas
curl -sSf https://atlasgo.sh | sh

Step 1: Start Databases

# Start PostgreSQL and Redis
cd docker
docker-compose up -d postgres redis

# Wait for databases to be ready
docker-compose ps

Step 2: Setup Backend

cd backend

# Install dependencies
go mod download

# Apply database migrations
cd database
make apply

# Load seed data (optional)
make seed

# Start backend server
cd ..
go run cmd/server/main.go

Backend will start at http://localhost:8080

Step 3: Setup Frontend

cd frontend

# Install dependencies
pnpm install

# Start Web application
cd web
pnpm dev         # http://localhost:5173

# Or start Mobile application (optional)
cd ../mobile
pnpm start

Step 4: Verify

# Check backend health
curl http://localhost:8080/health

# Check frontend
open http://localhost:5173

πŸ“– More startup options: Docker Deployment Guide


πŸ“š Development Guide

🎯 Common Development Tasks

βž• Add New Use Case

# 1. Declare use case
vim backend/domains/task/usecases.yaml

# 2. AI generates code (or write manually)
# - handlers/new_usecase.handler.go
# - service/task_service.go
# - http/dto/new_usecase.go
# - tests/new_usecase.test.go

# 3. Run tests
./backend/scripts/test_all.sh

Detailed guide: Quick Reference

πŸ—„οΈ Database Schema Management

cd backend/database

# Generate migration
make diff NAME=add_field

# Apply migration
make apply

# Check status
make status

Detailed guide: Database Management

πŸ”„ Frontend-Backend Type Sync

# Sync single domain
./scripts/sync_types.sh task

# Sync all domains
./scripts/sync_types.sh all

Generated types: frontend/shared/types/domains/

Detailed guide: Type Sync

βœ… Before Committing Code

# 1. Format + check
./backend/scripts/lint.sh --fix

# 2. Run tests
./backend/scripts/test_all.sh --coverage

# 3. Commit
git commit -m "feat(task): add feature"

Follow Conventional Commits specification


Documentation

🎯 Core Concepts

πŸ› οΈ Development Guides

πŸ“Š Observability

πŸ”Œ Extension Guides

πŸ“š Complete documentation index: docs/INDEX.md


πŸ—οΈ Tech Stack

πŸ”§ Backend

Language & Framework

Data Storage

  • PostgreSQL 16+ (using database/sql, no ORM)
  • Redis 7+ (cache + message queue)

Observability

Toolchain

  • Atlas - Schema management
  • staticcheck - Code analysis

🎨 Frontend

Web Application

  • React React 18+
  • TypeScript TypeScript 5.0+
  • Vite - Modern build tool
  • TanStack Query - Data fetching

Mobile Application

  • React Native (Expo)
  • Inspired by Bluesky Social App architecture
  • Native-level performance optimization

Monorepo

  • pnpm workspace
  • Shared types/utils/constants
  • Go β†’ TypeScript automatic type sync

πŸš€ DevOps

Containerization

  • Docker Docker
  • Docker Compose
  • Multi-environment config (dev/prod)

Monitoring & Observability

  • Prometheus - Metrics collection
  • Grafana - Visualization
  • Jaeger - Distributed tracing (optional)

Database Management

  • Atlas - Declarative Schema
  • Automatic migration generation
  • Version control

Development Tools

  • Air - Hot reload
  • golangci-lint - Code checking
  • Playwright - E2E testing

πŸ“‹ Project Status & Roadmap

βœ… v0.1 - Starter (Completed)

πŸ—οΈ Core Architecture

  • βœ… Vibe-Coding-Friendly DDD architecture
  • βœ… Complete Task domain implementation (example)
  • βœ… Three-layer architecture (Handler + Service + Repository)
  • βœ… 6 explicit knowledge files complete

πŸ”§ Infrastructure

  • βœ… Hertz HTTP framework integration
  • βœ… PostgreSQL + Redis (using database/sql, no ORM)
  • βœ… Complete middleware (auth, CORS, rate limiting, recovery, etc.)
  • βœ… Configuration management (zero third-party dependencies)

πŸ“Š Observability

  • βœ… Structured logging (uber-go/zap)
  • βœ… Prometheus Metrics
  • βœ… OpenTelemetry Tracing
  • βœ… Health check

πŸ› οΈ Development Tools

  • βœ… Atlas Schema management
  • βœ… Go β†’ TypeScript type sync
  • βœ… Frontend Monorepo (Web + Mobile)
  • βœ… Docker one-click start
  • βœ… Complete development scripts
  • βœ… Playwright-friendly frontend (data-test-id convention, Docker E2E env)
  • βœ… Vitest + happy-dom unit test setup (thread pool, fast feedback)

🎯 Usage Guide

This project uses the Task domain as an example. You can:

πŸ“¦ Use Directly

If you need task management functionality

Deploy immediately

πŸ“š Learn from It

Understand Vibe-Coding-Friendly DDD

Master best practices

πŸ”„ Map to Your Business

Replace with your domain

Product, Order, Customer...


πŸ”Œ Extension Points

Locations marked with Extension point in code can be extended:

Extension Point Description Status
Application Layer Cross-domain orchestration (needed for multi-domain collaboration) πŸ“– Guide
LLM Integration Integrate OpenAI, Claude, etc. πŸ”Œ Interface reserved
Event Bus Switch from in-memory to Redis/Kafka πŸ”Œ Interface reserved
JWT Authentication Complete token validation and refresh πŸ”Œ Interface reserved
Distributed Tracing OpenTelemetry Tracing βœ… Completed
Monitoring & Alerting Prometheus + Grafana βœ… Completed

πŸ—ΊοΈ Future Roadmap

πŸ”œ v0.2 - Enhancement (Planned)

  • Real LLM integration example (Eino)
  • Event Sourcing
  • CQRS pattern support
  • Complete E2E tests
  • Performance benchmarks

πŸš€ v0.3 - Production (Planned)

  • Kubernetes deployment config
  • CI/CD pipeline
  • Security hardening (JWT, RBAC)
  • Multi-tenancy support
  • API versioning

Welcome to share your ideas in Discussions!


Contributing

We welcome all forms of contributions! ⭐ Star this project to show support.

πŸ’‘ How to Contribute

πŸ› Found an issue?

  • Submit an Issue
  • Describe the problem and reproduction steps
  • Include environment information

πŸ’¬ Have an idea?

  • Discuss in Discussions
  • Share your use cases
  • Propose feature suggestions

πŸ”§ Want to contribute code?

# 1. Fork and clone
git clone https://github.com/erweixin/Go-GenAI-Stack.git

# 2. Create branch
git checkout -b feat/amazing-feature

# 3. Commit (follow Conventional Commits)
git commit -m 'feat(task): add amazing feature'

# 4. Push and create PR
git push origin feat/amazing-feature

πŸ“ Commit Convention

Use Conventional Commits:

feat(domain):     New feature
fix(domain):      Bug fix
docs:             Documentation update
refactor(domain): Refactoring
test(domain):     Test
chore:            Build/toolchain

πŸ“Š Project Metrics

πŸ§ͺ Test Readiness

Playwright-friendly

data-test-id + isolated Docker E2E env

βœ… Code Quality

100%

go vet + staticcheck

πŸ“š Structure Completeness

1/6

Required files complete

πŸ€– AI Friendliness

β‰₯ 10%

usecases.yaml coverage

🌟 Star History

If this project helps you, please give it a ⭐ Star!

Star History Chart


πŸ’¬ Community & Support

πŸ“– Documentation

Complete documentation

View Docs

πŸ’‘ Discussions

Share ideas and questions

Join Discussion

πŸ› Issues

Report bugs and feature requests

Submit Issue


πŸ”— References & Resources

Inspiration

Technical Documentation


πŸ“„ License

This project is licensed under the MIT License.


If this project helps you, please give it a ⭐ Star!

Made with ❀️ by Go-GenAI-Stack Team

⬆ Back to Top


Version: v0.1.0 | Status: πŸš€ Active Development | Last Updated: 2025-12-02

About

πŸš€ AI-friendly fullstack framework for the GenAI era | Go + TypeScript | Vibe-Coding-Friendly DDD | Domain-First architecture that makes code truly understandable by AI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published