Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gojangframework/gojang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gojang Framework

v0.1.3 - pagination added to admin panel data list and user management improved

A modern, batteries-included web framework for Go with HTMX. Build dynamic web applications with minimal JavaScript and maximum productivity.

🌟 Why Gojang?

  • Batteries Included: Authentication, admin panel, ORM, security - ready to go
  • HTMX First: Modern interactions without heavy JavaScript frameworks
  • Developer Joy: Minimal boilerplate, maximum productivity
  • Type Safe: Ent ORM catches errors at compile time
  • Production Ready: Security, logging, and best practices built-in
  • Easy to Learn: Clear documentation and simple patterns

✨ Features

  • πŸ” Authentication & Authorization - Built-in user system with sessions
  • πŸ‘₯ User Management - Complete user CRUD with permissions
  • πŸŽ›οΈ Auto-Generated Admin Panel - Automatic CRUD interface for any model
  • πŸ“Š Type-Safe ORM - Powered by Ent with reflection-based queries
  • 🎨 HTML Templates - Go templates with layouts and partials
  • ⚑ HTMX Integration - Dynamic interactions without heavy JavaScript
  • οΏ½ Security First - CSRF protection, rate limiting, password hashing
  • 🎯 Simple & Clean - Minimal boilerplate, maximum productivity
  • πŸš€ Production Ready - Audit logging, middleware, error handling

πŸ› οΈ Technology Stack

Technology Purpose
Go 1.21+ Backend language
HTMX Dynamic interactions
Ent Type-safe ORM
Chi HTTP router
Custom CSS Clean, semantic styling
SQLite / PostgreSQL Database

πŸ“ Project Structure

gojang/
β”œβ”€β”€ admin/             # Auto-generated admin panel
β”œβ”€β”€ cmd/web/           # Application entry point
β”œβ”€β”€ config/            # Configuration management
β”œβ”€β”€ http/
β”‚   β”œβ”€β”€ handlers/      # Request handlers
β”‚   β”œβ”€β”€ middleware/    # Auth, security, sessions
β”‚   └── routes/        # Route definitions
β”œβ”€β”€ models/
β”‚   └── schema/        # Database models (define here)
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ forms/         # Form validation structs
β”‚   β”œβ”€β”€ renderers/     # View renderer 
β”‚   β”œβ”€β”€ templates/     # HTML templates
└── └── static/        # CSS, images

πŸš€ Quick Start

  1. Clone the repository:

    git clone https://github.com/gojangframework/gojang
    cd gojang
  2. Copy environment file:

    cp .env.example .env
  3. Install dependencies:

    go mod download
  4. Run the application:

    go run ./gojang/cmd/web
  5. Visit: http://localhost:8080

That's it! The database is automatically created and migrated on first run.

🌱 First Admin Login (Seed)

You need to run seed program to insert the first admin account

go run ./gojang/cmd/seed

βš’οΈ Installation

This project uses Task for task automation (cross-platform alternative to Make).

Install Task:

macOS/Linux:

go install github.com/go-task/task/v3/cmd/task@latest

Or using Homebrew:

brew install go-task

Windows:

go install github.com/go-task/task/v3/cmd/task@latest

Or using Chocolatey:

choco install go-task

For other installation methods, see the official Task installation guide.

Install Air (Optional - for live reload):

Air provides automatic reload when code changes, making development faster.

All platforms:

go install github.com/air-verse/air@latest

After installation, you can use task dev to run the server with live reload.

πŸ”§ Development Commands

Run task --list to see all available tasks:

task dev              # Run server with live reload
task build            # Build the application
task test             # Run tests
task migrate          # Run database migrations
task seed             # Seed database with initial data
task schema-gen       # Generate Ent code after schema changes
task addpage          # Create a new static page interactively
task addmodel         # Create a new data model interactively

Or use plain Go commands:

go run ./gojang/cmd/web              # Run server
go build -o app ./gojang/cmd/web     # Build binary
go test ./...                         # Run tests
cd gojang/models && go generate ./... # Generate code

πŸ€– Automation Commands

Gojang includes powerful code generators to speed up development:

Add a New Data Model

Automatically generate a complete CRUD model with handlers, routes, templates, and admin integration:

task addmodel
# or
go run ./gojang/cmd/addmodel

This interactive tool will:

  • βœ… Create Ent schema with fields
  • βœ… Generate database code
  • βœ… Add form validation
  • βœ… Create CRUD handlers
  • βœ… Set up routes
  • βœ… Generate HTML templates
  • βœ… Register with admin panel

Example:

$ task addmodel
Model name: Product
Icon: πŸ“¦
Fields: name:string, price:float, stock:int
# Creates complete CRUD in seconds!

See Add Model Documentation for details.

Add a Static Page

Quickly add a new static page:

task addpage
# or
go run ./gojang/cmd/addpage

Creates template, handler, and route for simple pages like About, Contact, etc.

πŸ“š Documentation

Ready to start building? Check out our comprehensive guides:

Quick Examples

Add a simple page (Automated):

go run ./gojang/cmd/addpage
# Interactive prompt creates everything!

Add a data model (Automated):

go run ./gojang/cmd/addmodel
# Interactive prompt creates complete CRUD!

Manual approach:

// 1. Create schema: gojang/models/schema/product.go
// 2. Generate: go generate ./...
// 3. Register admin: registry.RegisterModel(...)

See the documentation for detailed step-by-step guides!

🎯 Key Features

Auto-Generated Admin Panel

Register any model and get a full admin interface automatically:

registry.RegisterModel(ModelRegistration{
    ModelType:      &models.Product{},
    Icon:           "πŸ“¦",
    NamePlural:     "Products",
    ListFields:     []string{"ID", "Name", "Price"},
    ReadonlyFields: []string{"ID", "CreatedAt"},
})

Includes:

  • βœ… List view with sorting
  • βœ… Create/Edit forms with validation
  • βœ… Delete with confirmation
  • βœ… Relationship handling
  • βœ… Search and filters (coming soon)

HTMX Integration

Dynamic interactions without writing JavaScript:

<button hx-get="/products/load" 
        hx-target="#product-list"
        hx-swap="innerHTML">
    Load Products
</button>

Type-Safe Database

Define schemas once, use everywhere:

// Define schema
field.String("name").NotEmpty()
field.Float("price").Positive()

// Use with type safety
product := client.Product.Create().
    SetName("Widget").
    SetPrice(19.99).
    Save(ctx)

🀝 Contributing

Contributions are welcome!

Please feel free to submit a Pull Request or email [email protected]

πŸ“ License

BSD 3-Clause "New" or "Revised" License


About

Django-like Web Framework Written in Go and HTMX

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •