gophex

command module
v0.0.0-...-c6b82f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README ยถ

๐Ÿš€ Gophex - Go Project Generator

A powerful, cross-platform CLI tool that generates production-ready Go projects with comprehensive database support, intelligent change detection, automated workflows, and clean architecture principles.

โœจ Key Features

๐ŸŒ Universal Cross-Platform Support
  • Windows, macOS, Linux - Full feature parity across all platforms
  • Platform-Specific Scripts - Generates .bat files for Windows, .sh for Unix
  • Smart Tool Detection - Auto-installs required tools (golang-migrate, etc.)
  • Native Integration - Uses platform-specific commands and file managers
๐Ÿ—๏ธ Intelligent Project Generation
  • Clean Architecture - Domain-driven design with proper separation of concerns
  • Interactive Database Configuration - PostgreSQL, MySQL, and MongoDB support
  • Multiple Database Configurations - Single instance, read-write split, and cluster setups
  • Custom Environment Generation - Automatic .env and .env.example creation with real values
  • Database-Specific Migrations - SQL migrations for PostgreSQL/MySQL, initialization scripts for MongoDB
๐Ÿš€ Post-Generation Workflow Automation
  • Interactive Menu System - Continue working after generation without exiting
  • Quick Start - One-click setup: dependencies โ†’ database โ†’ start application
  • Development Workflow - Full automated setup with testing and validation
  • Tool Auto-Installation - Automatically installs golang-migrate when needed
  • Multi-Project Sessions - Generate and manage multiple projects in one session
๐Ÿ” Production-Ready Security
  • JWT Authentication - Complete auth system with secure middleware
  • Security Middleware - CORS, rate limiting, request logging, input validation
  • Password Security - bcrypt hashing with proper salting
  • Environment Security - Secure credential management and configuration
๐Ÿ—„๏ธ Universal Database Support
  • PostgreSQL - Full support with connection pooling, SSL, clustering
  • MySQL - Complete integration with TLS, read-write splits
  • MongoDB - Document database with replica sets, authentication, sharding
  • Flexible Configurations - Single, read-write split, and cluster setups
  • Migration Management - Database-specific migration tools with auto-installation
๐Ÿ“‹ Smart Project Management & Metadata
  • Dynamic Project Metadata - Automatically generated gophex.md files with project hierarchy and progress tracking
  • Activity Tracking - Monitors completion status of project activities (dependencies, migrations, tests, etc.)
  • "Re-" Prefix System - Intelligent prefixes for repeated actions (e.g., "re-Install dependencies")
  • Project Loading - Load existing Gophex projects by specifying directory path
  • Smart Validation - Checks for gophex.md file existence and provides helpful feedback
  • Secure Metadata - Tracks database configuration without storing sensitive credentials
๐Ÿ›ก๏ธ Intelligent Change Detection & Safety
  • Manual Change Detection - Automatically detects user modifications
  • Step-by-Step Updates - Break large changes into confirmable steps
  • Backup & Rollback - Safe update process with rollback capabilities
  • Code Protection - Never overwrites custom business logic without confirmation
  • Git Integration - Tracks changes through Git history analysis
๐ŸŽฏ Enhanced Developer Experience
  • Fully Interactive CLI - All functionality through user-friendly MCQ prompts
  • No Command-Line Arguments - Simple, consistent interface without complex flags
  • Project Continuity - Seamlessly continue working on existing projects
  • Single Binary - Templates embedded using Go's embed filesystem
  • Comprehensive Documentation - Auto-generated README and migration guides
  • Real-Time Feedback - Progress indicators and status updates
  • Error Recovery - Graceful error handling with helpful suggestions

๐Ÿ› ๏ธ Installation

๐ŸŒ Cross-Platform Support

Gophex works on Windows, macOS, and Linux with full feature parity.

Install from GitHub
go install github.com/buildwithhp/gophex@latest
Build from Source
git clone https://github.com/buildwithhp/gophex.git
cd gophex
go build -o gophex main.go
Platform-Specific Installation

Windows:

# Requires Go 1.19+
go install github.com/buildwithhp/gophex@latest

macOS:

# Using Homebrew (if Go not installed)
brew install go
go install github.com/buildwithhp/gophex@latest

Linux:

# Ubuntu/Debian
sudo apt install golang-go
go install github.com/buildwithhp/gophex@latest

๐ŸŽฏ Usage

๐ŸŽฎ Interactive MCQ Interface

Gophex uses a fully interactive Multiple Choice Question (MCQ) interface - no command-line arguments needed! Simply run gophex and navigate through user-friendly menus.

Why MCQ-only?

  • โœ… Beginner Friendly - No need to memorize complex command flags
  • โœ… Consistent Experience - Same interface across all platforms
  • โœ… Error Prevention - Guided choices prevent invalid configurations
  • โœ… Discovery - Easily explore all available options
  • โœ… Accessibility - Works great with screen readers and assistive tools
๐Ÿš€ Quick Start
# Install Gophex
go install github.com/buildwithhp/gophex@latest

# Start interactive mode
gophex
๐Ÿ“‹ Interactive Workflow

Step 1: Start Gophex

gophex
# Choose from:
# - Generate a new project
# - Load existing project  โ† NEW!
# - Show version
# - Show help
# - Quit

Step 2: Interactive Configuration

  1. Project Type Selection - Choose from API, webapp, microservice, or CLI
  2. Project Name - Enter your project name
  3. Database Configuration (for API projects):
    • Database type: PostgreSQL, MySQL, or MongoDB
    • Configuration type: Single instance, read-write split, or cluster
    • Connection details: Host, port, credentials, SSL settings
  4. Path Confirmation - Confirm or change the generation directory

Step 3: Post-Generation Menu

โœ… Project 'myapi' is ready at /path/to/myapi
๐ŸŒ API project with database integration

๐Ÿš€ What would you like to do next?

โšก Quick start (install deps + start app)
๐Ÿ”„ Development workflow (full auto-setup)
๐Ÿ“ Open project directory
๐Ÿ—„๏ธ Run database migrations/initialization
๐Ÿ“ฆ Install dependencies (go mod tidy)
๐Ÿš€ Start the application
๐Ÿงช Run tests
๐Ÿ“– View project documentation
๐Ÿ” Run change detection
๐Ÿ†• Generate another project
โŒ Exit
๐Ÿ“‚ Loading Existing Projects

NEW! Gophex can now load and continue working on existing projects:

gophex
# Select: Load existing project

๐Ÿ“ Load Existing Gophex Project
๐Ÿ’ก Enter the path to a directory containing a 'gophex.md' file

? Enter the path to a Gophex project directory: ./myapi

๐Ÿ“‚ Loading project: myapi (api)
๐Ÿ“ Location: ./myapi
๐Ÿ•’ Last updated: 2 hours ago

๐Ÿš€ What would you like to do next?

โšก Quick start (install deps + start app)
๐Ÿ”„ Development workflow (full auto-setup)
๐Ÿ“ Open project directory
๐Ÿ—„๏ธ re-Run database migrations/initialization  โ† "re-" prefix for completed activities
๐Ÿ“ฆ re-Install dependencies (go mod tidy)       โ† Shows what's been done before
๐Ÿš€ Start the application
๐Ÿงช Run tests
๐Ÿ“– View project documentation
๐Ÿ” Run change detection
๐Ÿ†• Generate another project
โŒ Exit

If no gophex.md file is found:

? Enter the path to a Gophex project directory: ./some-directory

โŒ No Gophex metadata file (gophex.md) found in: /path/to/some-directory

? Would you like to create a new project? (Y/n)

Key Features:

  • Manual Path Input - Simple, direct path specification without system-wide searching
  • Smart Validation - Checks for gophex.md file existence and validity
  • Smart Activity Tracking - Shows "re-" prefix for activities that have been completed before
  • Time-Aware Display - Shows when projects were last updated
  • Fallback to Generation - Option to create new project if no metadata found
  • Seamless Integration - Loaded projects work exactly like newly generated ones
๐Ÿ’ป Interactive Interface
# Start Gophex interactive mode
gophex

# Main menu options:
# - Generate a new project
# - Show version
# - Show help  
# - Quit

๐Ÿ“‹ Project Types

๐ŸŒ REST API (Production-Ready)

Generates a comprehensive REST API with clean architecture, database integration, and your choice of web framework:

๐Ÿš€ Framework Options
  • Gin - High-performance HTTP web framework with JSON validation
  • Echo - Minimalist web framework with middleware support
  • Gorilla - Powerful toolkit with flexible routing and middleware
gophex
# Select: Generate a new project
# Select: api - REST API with clean architecture
# Enter project name: myapi
# Choose framework: Gin/Echo/Gorilla
# Choose database: PostgreSQL/MySQL/MongoDB
# Configure database setup: Single/Read-Write/Cluster
# Enter connection details

Generated Structure:

myapi/
โ”œโ”€โ”€ cmd/api/                    # Application entry point
โ”‚   โ””โ”€โ”€ main.go                 # Graceful shutdown, DB connections
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ api/                    # HTTP layer
โ”‚   โ”‚   โ”œโ”€โ”€ handlers/           # Request handlers
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.go         # JWT authentication
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ users.go        # User CRUD operations
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ posts.go        # Post management
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ health.go       # Health checks
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/         # HTTP middleware
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth.go         # JWT validation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cors.go         # CORS handling
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ logging.go      # Request logging
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ratelimit.go    # Rate limiting
โ”‚   โ”‚   โ”œโ”€โ”€ routes/             # Route definitions
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ routes.go       # API routing setup
โ”‚   โ”‚   โ””โ”€โ”€ responses/          # Response formatting
โ”‚   โ”‚       โ”œโ”€โ”€ error.go        # Error responses
โ”‚   โ”‚       โ””โ”€โ”€ success.go      # Success responses
โ”‚   โ”œโ”€โ”€ database/               # Universal database layer
โ”‚   โ”‚   โ”œโ”€โ”€ database.go         # Database interface & implementations
โ”‚   โ”‚   โ”œโ”€โ”€ config.go           # Database configuration
โ”‚   โ”‚   โ””โ”€โ”€ factory.go          # Database factory
โ”‚   โ”œโ”€โ”€ domain/                 # Business logic
โ”‚   โ”‚   โ”œโ”€โ”€ user/               # User domain
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ model.go        # User entity
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ repository.go   # Repository interface
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ service.go      # Business logic
โ”‚   โ”‚   โ””โ”€โ”€ post/               # Post domain
โ”‚   โ”‚       โ”œโ”€โ”€ model.go        # Post entity
โ”‚   โ”‚       โ”œโ”€โ”€ repository.go   # Repository interface
โ”‚   โ”‚       โ””โ”€โ”€ service.go      # Business logic
โ”‚   โ”œโ”€โ”€ infrastructure/         # External dependencies
โ”‚   โ”‚   โ”œโ”€โ”€ database/           # Database implementations
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ postgres/       # PostgreSQL repositories
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ redis/          # Redis caching
โ”‚   โ”‚   โ””โ”€โ”€ auth/               # Authentication
โ”‚   โ”‚       โ”œโ”€โ”€ jwt.go          # JWT implementation
โ”‚   โ”‚       โ””โ”€โ”€ password.go     # Password hashing
โ”‚   โ”œโ”€โ”€ config/                 # Configuration management
โ”‚   โ”‚   โ””โ”€โ”€ config.go           # App configuration
โ”‚   โ””โ”€โ”€ pkg/                    # Shared utilities
โ”‚       โ”œโ”€โ”€ validator/          # Input validation
โ”‚       โ”œโ”€โ”€ logger/             # Structured logging
โ”‚       โ””โ”€โ”€ errors/             # Custom error types
โ”œโ”€โ”€ migrations/                 # Database migrations
โ”‚   โ”œโ”€โ”€ 000001_create_users_table.up.sql    # User table migration
โ”‚   โ”œโ”€โ”€ 000001_create_users_table.down.sql  # Rollback migration
โ”‚   โ”œโ”€โ”€ 000002_create_posts_table.up.sql    # Post table migration
โ”‚   โ”œโ”€โ”€ 000002_create_posts_table.down.sql  # Rollback migration
โ”‚   โ”œโ”€โ”€ mongodb_init.js         # MongoDB initialization (if MongoDB)
โ”‚   โ””โ”€โ”€ README.md               # Migration documentation
โ”œโ”€โ”€ scripts/                    # Utility scripts
โ”‚   โ”œโ”€โ”€ migrate.sh              # Database migration script
โ”‚   โ””โ”€โ”€ detect-changes.sh       # Change detection script
โ”œโ”€โ”€ .env                        # Environment variables (with real values)
โ”œโ”€โ”€ .env.example                # Environment template
โ”œโ”€โ”€ .gophex-generated           # Generation metadata
โ”œโ”€โ”€ gophex.md                   # Project metadata and activity tracking (NEW!)
โ”œโ”€โ”€ go.mod                      # Go modules
โ””โ”€โ”€ README.md                   # Project documentation
๐ŸŽฏ Framework-Specific Features

Gin Framework:

  • High-performance HTTP routing with radix tree
  • Built-in JSON validation and binding
  • Middleware chaining with context passing
  • Automatic content negotiation

Echo Framework:

  • Minimalist design with powerful middleware
  • Built-in request/response binding
  • Automatic TLS support
  • Extensible middleware system

Gorilla Framework:

  • Flexible routing with URL patterns
  • Powerful middleware toolkit
  • WebSocket support ready
  • Session management capabilities

Features Included:

  • โœ… Universal Database Support - PostgreSQL, MySQL, MongoDB with all configuration types
  • โœ… Cross-Platform Scripts - Windows .bat and Unix .sh files generated automatically
  • โœ… Auto-Tool Installation - golang-migrate and other tools installed automatically
  • โœ… Post-Generation Workflow - Interactive menu for immediate development
  • โœ… Smart Project Metadata - Dynamic gophex.md with project hierarchy and activity tracking
  • โœ… Project Loading - Load and continue working on existing Gophex projects
  • โœ… Activity Awareness - "Re-" prefix system for repeated actions
  • โœ… JWT Authentication System - Complete auth with secure middleware
  • โœ… User Management - Full CRUD operations with validation
  • โœ… Post Management System - Content management with author relationships
  • โœ… Security Middleware - CORS, rate limiting, request logging, input validation
  • โœ… Database Migrations - SQL migrations and MongoDB initialization scripts
  • โœ… Environment Configuration - Custom .env generation with real database credentials
  • โœ… Change Detection - Automatic detection of manual code modifications
  • โœ… Health Check Endpoints - Application and database health monitoring
  • โœ… Clean Architecture Pattern - Domain-driven design with proper separation
  • โœ… Repository Pattern - Abstract data access layer
  • โœ… Dependency Injection - Loose coupling between components
  • โœ… Graceful Shutdown - Proper resource cleanup and signal handling
  • โœ… Development Automation - One-click setup from generation to running app
๐ŸŒ Web Application
gophex
# Select: Generate a new project
# Select: webapp - Web application with templates

Generates a web application with HTML templates and static file serving.

๐Ÿ”ง Microservice
gophex
# Select: Generate a new project
# Select: microservice - Microservice with gRPC support

Creates a lightweight microservice with health checks and service endpoints.

๐Ÿ’ป CLI Tool
gophex
# Select: Generate a new project
# Select: cli - Command-line tool

Generates a CLI application using Cobra framework.

๐Ÿ—๏ธ Architecture Principles

Clean Architecture
  • Domain Layer: Business logic and entities
  • Infrastructure Layer: External dependencies (database, APIs)
  • API Layer: HTTP handlers and middleware
  • Dependency Inversion: Interfaces define contracts
Best Practices
  • โœ… Separation of Concerns - Each layer has a single responsibility
  • โœ… Dependency Injection - Loose coupling between components
  • โœ… Repository Pattern - Abstract data access
  • โœ… Service Layer - Business logic encapsulation
  • โœ… Middleware Pattern - Cross-cutting concerns
  • โœ… Error Handling - Consistent error responses
  • โœ… Configuration Management - Environment-based config
  • โœ… Structured Logging - Observability and debugging
  • โœ… Input Validation - Data integrity and security
  • โœ… Testing Structure - Unit and integration tests

๐Ÿ”ง Technology Stack & Automation

๐Ÿค– Automated Tool Management

Auto-Installation Features:

  • golang-migrate: Automatically installed when needed for database migrations
  • Platform Detection: Installs appropriate tools for your operating system
  • Version Verification: Ensures tools are properly installed and accessible
  • Error Recovery: Provides helpful guidance if installation fails

Tool Installation Process:

# When you run database setup, Gophex automatically:
โš ๏ธ  golang-migrate tool is not installed
   This tool is required for postgresql database migrations

? Would you like Gophex to install golang-migrate for you? Yes

๐Ÿ“ฆ Installing golang-migrate tool...
   Running: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
โœ… golang-migrate installed successfully!
   ๐Ÿ“‹ Version: v4.16.2
   ๐ŸŽฏ Ready for postgresql database migrations
๐Ÿ—„๏ธ Database Support
  • PostgreSQL: Full support with connection pooling, SSL, read-write splits, clustering
  • MySQL: Complete integration with TLS, connection pooling, cluster support
  • MongoDB: Document database with replica sets, authentication, cluster configurations
  • Redis: Caching layer (optional)
  • Migrations: golang-migrate for SQL databases (auto-installed), custom scripts for MongoDB
๐Ÿ—๏ธ Core Dependencies
  • HTTP Router: Gorilla Mux
  • Database Drivers:
    • PostgreSQL: lib/pq
    • MySQL: go-sql-driver/mysql
    • MongoDB: go.mongodb.org/mongo-driver
  • Authentication: JWT with secure token handling
  • Password Hashing: bcrypt with proper salting
  • Configuration: Environment-based configuration
  • Logging: Structured logging with levels
  • Validation: Custom validation package
๐Ÿ› ๏ธ Development Automation
  • Workflow Automation: One-click setup from generation to running application
  • Change Detection: Automatic detection of manual modifications via Git analysis
  • Migration Management: Database-specific migration tools with auto-installation
  • Testing Integration: Automated test running and validation
  • Documentation Generation: Auto-generated README and migration guides
  • Safety Features: Backup, rollback, and change protection capabilities
๐ŸŒ Cross-Platform Tools
  • Windows: Batch files (.bat), CMD integration, Explorer opening
  • macOS: Shell scripts (.sh), Terminal integration, Finder opening
  • Linux: Shell scripts (.sh), Terminal integration, file manager opening
  • Universal: HTTP client for health checks, Go tools for all operations

๐Ÿš€ Getting Started with Generated Projects

  1. Generate and Auto-Setup:

    gophex
    # Select: Generate a new project
    # Follow interactive prompts
    # Select "โšก Quick start" from post-generation menu
    

    This automatically:

    • Installs dependencies
    • Sets up database (installs golang-migrate if needed)
    • Starts the application
    • Tests health endpoint
  2. Start Developing:

    # API is running on http://localhost:8080
    # Health check: http://localhost:8080/api/v1/health
    # Ready for development!
    
๐Ÿ“‹ Manual Setup (Step-by-Step)
  1. Generate the project:

    gophex
    # Select: Generate a new project
    # Select: api - REST API with clean architecture
    # Enter project name: myapi
    # Choose database type: PostgreSQL/MySQL/MongoDB
    # Configure database setup and credentials
    
  2. Use Post-Generation Menu:

    # After generation, choose from menu:
    ๐Ÿ“ฆ Install dependencies (go mod tidy)
    ๐Ÿ—„๏ธ Run database migrations/initialization
    ๐Ÿš€ Start the application
    
  3. Or Manual Commands:

    cd myapi
    go mod tidy
    
    # Windows
    scripts\migrate.bat up
    
    # Unix/Linux/macOS
    ./scripts/migrate.sh up
    
    go run cmd/api/main.go
    
๐Ÿงช Testing Your API
# Health check
curl http://localhost:8080/api/v1/health

# Register a user
curl -X POST http://localhost:8080/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","username":"testuser","password":"password123"}'

# Login
curl -X POST http://localhost:8080/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"password123"}'
๐Ÿ” Change Detection & Safety

Generated projects include intelligent change detection:

# Windows
scripts\detect-changes.bat

# Unix/Linux/macOS
./scripts/detect-changes.sh

# Shows:
# - Git commits since generation
# - Modified files
# - Custom code patterns
# - Custom imports
# - Database schema changes
๐Ÿ› ๏ธ Development Tools

Database Management:

# Check migration status
scripts/migrate.sh status        # Unix
scripts\migrate.bat status       # Windows

# Create new migration
scripts/migrate.sh create add_new_table

Project Management:

# Run tests
go test ./...

# Build for production
go build -o api cmd/api/main.go

# Check for changes
scripts/detect-changes.sh
API Endpoints

Generated APIs include these endpoints:

  • GET /api/v1/health - Health check
  • POST /api/v1/auth/register - User registration
  • POST /api/v1/auth/login - User login
  • GET /api/v1/users - List users (protected)
  • GET /api/v1/users/{id} - Get user (protected)
  • PUT /api/v1/users/{id} - Update user (protected)
  • DELETE /api/v1/users/{id} - Delete user (protected)
  • GET /api/v1/posts - List posts (public)
  • GET /api/v1/posts/{id} - Get post (public)
  • POST /api/v1/posts - Create post (protected)
  • PUT /api/v1/posts/{id} - Update post (protected)
  • DELETE /api/v1/posts/{id} - Delete post (protected)

๐Ÿงช Testing

Generated projects include comprehensive testing structure:

# Run all tests
go test ./...

# Run with coverage
go test -cover ./...

# Run integration tests
go test ./tests/integration/...

# Run unit tests
go test ./internal/...

๐Ÿ“‹ Project Metadata System

๐Ÿ†• gophex.md File

Every Gophex project now includes a gophex.md file that contains comprehensive metadata about the project:

{
  "project": {
    "name": "myapi",
    "type": "api",
    "version": "1.0.0",
    "gophex_version": "1.0.0",
    "generated_at": "2025-08-03T20:00:00+05:30",
    "last_updated": "2025-08-03T20:05:00+05:30"
  },
  "hierarchy": {
    "cmd": {
      "api": {
        "main.go": "application_entry_point"
      }
    },
    "internal": {
      "api": {
        "handlers": {
          "auth.go": "authentication_handlers",
          "users.go": "user_management_handlers"
        }
      }
    }
  },
  "database": {
    "configured": true,
    "type": "postgresql",
    "config_type": "single",
    "is_clustered": false,
    "has_read_write_split": false,
    "ssl_enabled": false,
    "migrations_executed": true,
    "schema_initialized": true
  },
  "activities": {
    "project_generated": {
      "completed": true,
      "timestamp": "2025-08-03T20:00:00+05:30",
      "can_repeat": false
    },
    "dependencies_installed": {
      "completed": true,
      "timestamp": "2025-08-03T20:05:00+05:30",
      "can_repeat": true
    },
    "database_migrated": {
      "completed": true,
      "timestamp": "2025-08-03T20:03:00+05:30",
      "can_repeat": true
    }
  }
}
๐Ÿ”‘ Key Features:
  • ๐Ÿ“ Dynamic Hierarchy - Complete file structure with descriptive labels
  • ๐Ÿ—„๏ธ Database Tracking - Configuration status without sensitive credentials
  • ๐Ÿ“Š Activity Monitoring - Tracks completion of project activities
  • ๐Ÿ”„ "Re-" Prefix System - Shows which activities can be repeated
  • ๐Ÿ•’ Timestamps - When activities were completed
  • ๐Ÿ” Project Discovery - Enables automatic project loading
  • ๐Ÿ›ก๏ธ Secure - No passwords or sensitive data stored
๐Ÿ’ก Benefits:
  • Project Continuity - Resume work on any Gophex project from anywhere
  • Team Collaboration - Share project status and progress with team members
  • Development Insights - Understand what's been done and what's next
  • Automation Support - Enables intelligent tooling and workflows

๐Ÿ—„๏ธ Database Configuration Examples

PostgreSQL Single Instance
# Interactive prompts will generate:
DATABASE_URL=postgres://admin:password@localhost:5432/myapi?sslmode=disable
MySQL Read-Write Split
# Interactive prompts will generate:
DATABASE_WRITE_URL=admin:password@tcp(write-host:3306)/myapi?tls=false
DATABASE_READ_URL=admin:password@tcp(read-host:3306)/myapi?tls=false
MongoDB Cluster
# Interactive prompts will generate:
DATABASE_URL=mongodb://admin:password@node1:27017,node2:27017,node3:27017/myapi?replicaSet=rs0&authSource=admin

๐Ÿ›ก๏ธ Change Detection & Safety Features

Automatic Change Detection

Generated projects include intelligent change detection:

# Run change detection
./scripts/detect-changes.sh

# Sample output:
๐Ÿ” Gophex Change Detection Tool
================================

โœ… Gophex-generated project detected
  ๐Ÿ“… Generated: 2025-01-02T15:04:05Z
  ๐Ÿ—๏ธ  Type: api
  ๐Ÿ—„๏ธ  Database: postgresql

โš ๏ธ  Found 3 manual commits since generation
โš ๏ธ  Found 2 files modified since generation:
  ๐Ÿ“ internal/api/handlers/users.go
  ๐Ÿ“ internal/database/migrations/003_custom.sql

โš ๏ธ  Found custom code markers:
  ๐Ÿท๏ธ  // CUSTOM: (5 matches)
  ๐Ÿท๏ธ  // TODO: (2 matches)

๐Ÿ“Š Change Detection Summary
โš ๏ธ  MANUAL CHANGES DETECTED
   This project has been manually modified since generation.
   Please review changes carefully before applying updates.
Safe Update Protocol

When updating generated projects:

  1. Change Detection: Automatically detects manual modifications
  2. Step-by-Step Updates: Breaks large changes into confirmable steps
  3. Backup & Rollback: Creates backups before making changes
  4. User Confirmation: Never overwrites custom code without permission

๐Ÿ“ฆ Template System

Gophex uses Go's embedded filesystem for templates:

  • Embedded Templates: All templates are embedded in the binary
  • Database-Aware: Templates adapt based on database configuration
  • No External Dependencies: Single binary distribution
  • Fast Generation: Templates loaded from memory
  • Version Controlled: Templates are part of the codebase
  • Easy Maintenance: Each template is a separate file
  • Custom Environment Generation: Creates .env files with actual values

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
Adding New Templates
  1. Create template files in internal/templates/{type}/
  2. Use .tmpl extension for template files
  3. Available template variables:
    • {{.ProjectName}} - Project name
    • {{.ModuleName}} - Go module name
    • {{.DatabaseConfig.Type}} - Database type (postgresql, mysql, mongodb)
    • {{.DatabaseConfig.ConfigType}} - Configuration type (single, read-write, cluster)
    • {{.DatabaseConfig.Host}} - Database host
    • {{.DatabaseConfig.Username}} - Database username
    • {{.DatabaseConfig.Password}} - Database password
    • {{.GeneratedAt}} - Generation timestamp
  4. Templates are automatically discovered by the embedded filesystem
  5. Use conditional logic for database-specific code:
    {{if eq .DatabaseConfig.Type "postgresql"}}
    // PostgreSQL-specific code
    {{else if eq .DatabaseConfig.Type "mongodb"}}
    // MongoDB-specific code
    {{end}}
    

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by modern Go project layouts
  • Built with Go's powerful standard library
  • Uses industry-standard packages and patterns
  • Follows clean architecture principles

๐ŸŽฏ Key Features Summary

๐ŸŒ Cross-Platform Excellence
  • Windows, macOS, Linux: Full feature parity across all platforms
  • Platform-Specific Scripts: Generates .bat for Windows, .sh for Unix
  • Smart Tool Management: Auto-installs golang-migrate and other required tools
  • Native Integration: Uses platform-specific file managers and commands
๐Ÿš€ Workflow Automation
  • Post-Generation Menu: Continue working without exiting the application
  • Project Loading: Load and continue working on existing Gophex projects
  • Quick Start: One-click setup from generation to running application
  • Development Workflow: Automated dependency installation, database setup, testing
  • Multi-Project Sessions: Generate and manage multiple projects efficiently
๐Ÿ—„๏ธ Universal Database Support
  • 3 Database Types: PostgreSQL, MySQL, MongoDB
  • 3 Configuration Types: Single instance, read-write split, cluster
  • Automatic Setup: Custom environment files with real credentials
  • Migration Management: Database-specific scripts with auto-tool installation
๐Ÿ“‹ Smart Project Management
  • Dynamic Metadata: Comprehensive gophex.md files with project hierarchy and activity tracking
  • Activity Intelligence: "Re-" prefix system for repeated actions
  • Manual Project Loading: Load projects by specifying directory path
  • Project Continuity: Resume work on any project from anywhere
  • Secure Tracking: Metadata without sensitive credentials
๐Ÿ›ก๏ธ Intelligent Change Management
  • Change Detection: Automatically detects manual modifications via Git and file analysis
  • Safe Updates: Step-by-step confirmation process with rollback capabilities
  • Code Protection: Never overwrites custom business logic without explicit permission
  • User Control: Respects user decisions and preserves customizations
๐Ÿ—๏ธ Production-Ready Architecture
  • Clean Architecture: Domain-driven design with proper separation of concerns
  • Security First: JWT auth, CORS, rate limiting, input validation, secure password hashing
  • Performance Optimized: Connection pooling, caching, optimized middleware
  • Observability: Structured logging, health checks, error tracking
  • DevOps Ready: Migration scripts, environment management, testing structure

๐Ÿ“ž Support

๐Ÿ”„ Version History

v1.1.0 (Latest) - Smart Project Management & Metadata
  • โœ… Project Loading - Load and continue working on existing Gophex projects by path
  • โœ… Smart Metadata System - Dynamic gophex.md files with project hierarchy and activity tracking
  • โœ… Activity Awareness - "Re-" prefix system for repeated actions
  • โœ… Smart Validation - Checks for gophex.md file existence with helpful feedback
  • โœ… Secure Metadata - Tracks configuration without storing sensitive credentials
  • โœ… Project Continuity - Resume work from any directory on any project
  • โœ… Time-Aware Display - Shows when projects were last updated
  • โœ… Enhanced Developer Experience - Seamless workflow between project generation and management
v1.0.0 - Complete Development Workflow
  • โœ… Cross-Platform Support - Windows, macOS, Linux with full feature parity
  • โœ… Post-Generation Workflow - Interactive menu system for continued development
  • โœ… Automated Tool Installation - Auto-installs golang-migrate and other required tools
  • โœ… Universal Database Support - PostgreSQL, MySQL, MongoDB with all configuration types
  • โœ… Interactive Database Configuration - Step-by-step database setup with real credentials
  • โœ… Custom Environment Generation - Automatic .env files with actual values
  • โœ… Platform-Specific Scripts - Windows batch files and Unix shell scripts
  • โœ… Change Detection & Safety - Intelligent detection of manual modifications
  • โœ… Development Automation - One-click setup from generation to running application
  • โœ… Clean Architecture - Domain-driven design with repository pattern
  • โœ… Production-Ready Security - JWT auth, CORS, rate limiting, input validation
๐Ÿš€ What's New in v1.1.0
  • Project Loading: Load existing Gophex projects by specifying directory path
  • Smart Metadata: Dynamic project metadata with complete hierarchy tracking and activity monitoring
  • Activity Intelligence: "Re-" prefix system shows what's been done before and can be repeated
  • Smart Validation: Checks for gophex.md file existence with helpful error messages and fallback options
  • Enhanced Continuity: Seamless workflow between creating new projects and managing existing ones
  • Secure Tracking: Comprehensive metadata without storing sensitive information like passwords

๐ŸŒŸ Why Choose Gophex?

๐ŸŽฏ For Beginners
  • MCQ Interface: No command-line arguments to learn - just select from menus
  • Guided Setup: Interactive prompts guide you through every step
  • Auto-Installation: Installs required tools automatically
  • Learning Aid: Generated code follows Go best practices
  • Documentation: Comprehensive README and migration guides
๐Ÿš€ For Professionals
  • Production Ready: Security, performance, and observability built-in
  • Time Saving: From idea to running API in minutes
  • Customizable: Respects and preserves your custom modifications
  • Scalable: Clean architecture supports growth and team development
๐Ÿข For Teams
  • Consistent Structure: Standardized project layout across team
  • Change Detection: Track modifications and maintain code quality
  • Cross-Platform: Works on every developer's machine
  • Documentation: Auto-generated docs for easy onboarding

Made with โค๏ธ for the Go community

Gophex - Generate. Load. Configure. Deploy. Scale.

๐ŸŒ Works everywhere Go works - Windows, macOS, Linux ๐Ÿ“‚ Load any Gophex project from anywhere

Documentation ยถ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL