Skip to content

Repository files navigation

Codo Framework

A production-ready Go backend framework with multi-router HTTP architecture, database abstraction, and authentication integrations.

Installation

go get github.com/codoworks/codo-framework

Quick Start

package main
import (
"github.com/codoworks/codo-framework/core/config""github.com/codoworks/codo-framework/core/db""github.com/codoworks/codo-framework/core/http"
)
funcmain() {
// Load configurationcfg, _:=config.Load()
// Connect to databasedbClient, _:=db.NewClient(cfg.Database)
// Register handlershttp.RegisterHandler(NewUserHandler(dbClient))
// Start serverrouter:=http.NewRouter(http.ScopeProtected, cfg)
router.Start()
}

Multi-Router Architecture

Three independent routers for Kubernetes ingress separation:

RouterPortScopePurpose
Public8081http.ScopePublicHealth checks, public endpoints
Protected8080http.ScopeProtectedUser-facing API (requires auth)
Hidden8079http.ScopeHiddenAdmin/internal endpoints

Core Packages

PackageDescription
core/configConfiguration loading (env, files)
core/dbDatabase client, repository pattern, migrations
core/httpRouter, handlers, middleware, context
core/authOry Kratos/Keto integration
testutilTesting utilities for handlers

Creating a Handler

typeUserHandlerstruct {
service*UserService
}
func (h*UserHandler) Prefix() string { return"/api/v1/users" }
func (h*UserHandler) Scope() http.RouterScope { returnhttp.ScopeProtected }
func (h*UserHandler) Middlewares() []echo.MiddlewareFunc { returnnil }
func (h*UserHandler) Initialize() error { returnnil }
func (h*UserHandler) Routes(g*echo.Group) {
g.GET("", http.WrapHandler(h.List))
g.POST("", http.WrapHandler(h.Create))
g.GET("/:id", http.WrapHandler(h.Get))
}

CLI Commands

codo serve # Start all servers
codo start public # Start public server only
codo start protected # Start protected server only
codo db migrate # Run migrations
codo db rollback # Rollback migrations
codo db seed # Run seeds
codo info routes # Show registered routes
codo info env # Show environment info

Documentation

Full documentation: Coming soon

License

MIT

About

Production ready go framework

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages