AetherGo is a lightweight, modular web framework written in Go, designed for building fast and scalable web applications.
AetherGo follows a lightweight, modular architecture inspired by MVC (Model-View-Controller) but optimized for Go. The framework is structured as follows:
-
Defined in:
internal/dbandnocash/models -
Database ORM: Uses GORM for Object-Relational Mapping (ORM).
-
Functionality: Simplifies database interactions, supporting migrations, relationships, and hooks.
-
Defined in:
internal/app -
Functionality: Handles the application lifecycle, bootstrapping the router, database, and middleware.
-
Defined in:
nocash/routes/routes.go -
Functionality: Similar to Django’s
urls.pyor Laravel’sroutes/web.php, registers HTTP endpoints and connects them to handlers.
-
Defined in:
nocash/handler/commonHandler.go -
Functionality: Handles incoming HTTP requests and maps them to appropriate views. Acts similarly to controllers in MVC.
-
Defined in:
nocash/templates/ -
Functionality: Renders HTML templates using
render.RenderTemplate. Similar to Django’s MVT View layer or Laravel’s Blade templates.
-
Defined in:
internal/contextandinternal/middleware -
Functionality: Manages the request lifecycle, authentication, logging, and custom middleware. It allows for dependency injection, session management, and logging.
-
🚀 High Performance: Written in Go, compiled for low-latency and high throughput.
-
🛠️ Built-in ORM (GORM): Simplifies database interactions without needing raw SQL, supports migrations, relationships, and hooks.
-
🔄 Custom Context System: Provides middleware-like request handling, allowing dependency injection, session management, and logging.
-
🏗️ Modular Design: Encourages separating concerns between models, routes, and handlers, making the framework easy to extend.
-
🔥 Live Reloading (Air): Hot reloading during development, avoiding manual restarts when modifying code.
-
🛣️ Simple Routing: Easily map routes with parameters and custom handler functions.
-
🎨 Template Rendering: Renders HTML templates for dynamic content generation.
go get github.com/rifat977/AetherGo
package main
import (
"AetherGo/internal/app"
"AetherGo/internal/context"
"AetherGo/internal/render"
)
func main() {
application := app.NewApp()
// Register Routes
RegisterRoutes(application)
// Start the server
application.Run()
}
func indexHandler(c *context.Context) {
render.RenderJSON(c.Response, map[string]string{"message": "Hello, World!"})
}
func aboutHandler(c *context.Context) {
name := c.Params["name"]
render.RenderTemplate(c.Response, "nocash/templates/about.html", map[string]string{"Name": name})
}AetherGo provides a simple and flexible router with parameter support.
package routes
import (
"AetherGo/internal/app"
"AetherGo/nocash/handler"
)
func RegisterRoutes(application *app.App) {
application.Router.Add("GET", "/", handler.IndexHandler)
application.Router.Add("GET", "/about/:name", handler.AboutHandler)
application.Router.Add("GET", "/login", handler.LoginHandler)
}Handlers process HTTP requests using the Context object.
package handler
import (
"AetherGo/internal/context"
"AetherGo/internal/render"
"fmt"
)
func IndexHandler(c *context.Context) {
render.RenderJSON(c.Response, map[string]string{"message": "Welcome to AetherGo!"})
}
func AboutHandler(c *context.Context) {
name := c.Params["name"]
render.RenderTemplate(c.Response, "nocash/templates/about.html", map[string]string{"Name": name})
}
func LoginHandler(c *context.Context) {
fmt.Println("Login Handler triggered")
if c.Request.Method == "GET" {
render.RenderTemplate(c.Response, "nocash/templates/login.html", nil)
}
}AetherGo supports middleware for request processing, such as logging and panic recovery.
app.Use(middleware.Logger)
app.Use(middleware.Recovery)Each request handler receives a Context object that provides access to:
- HTTP Request and Response
- URL Parameters
- Helper methods for JSON and HTML responses
func userHandler(c *context.Context) {
id := c.Params["id"]
c.JSON(200, map[string]string{"id": id})
}AetherGo supports HTML template rendering with data binding.
render.RenderTemplate(c.Response, "templates/page.html", map[string]interface{}{
"Title": "AetherGo Page",
"User": "John Doe",
})AetherGo includes built-in ORM support using GORM for seamless database interactions.
import (
"AetherGo/internal/db"
"gorm.io/gorm"
)
type User struct {
gorm.Model
Name string
Email string `gorm:"unique"`
}
func InitDB() {
db := db.GetDB()
db.AutoMigrate(&User{})
}AetherGo provides an environment-based configuration system, allowing you to access settings dynamically.
app.Config.GetPort() // Returns configured port
app.Config.GetEnv() // Returns current environment🔹 JWT Authentication – Secure user authentication with JSON Web Tokens
🔹 WebSockets Support – Enable real-time features like notifications & chat
🔹 Task Scheduling & Job Queue – Background processing for better performance
🔹 GraphQL Support – Alternative to REST for more flexible APIs
🔹 Rate Limiting – Protect endpoints from abuse
🔹 CLI Tools – Command-line utilities for managing the app easily
Contributions are welcome! Feel free to submit a Pull Request or raise an issue.
AetherGo is open-source and available under the MIT License.
Happy coding! 🚀