bakend

package module
v0.0.0-...-70a5fc5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

README

Bakend Framework

Read in Turkish

bakend-framework is a powerful framework developed in Go, designed for building modular, scalable, and modern backend applications. By adopting CQRS (Command Query Responsibility Segregation), Event-Driven Architecture, and Clean Architecture principles, it provides a solid foundation for developers.

Features

  • Modular Structure: Increases manageability and testability by separating your application into independent modules.
  • CQRS Support: Ensures performance and scalability by separating Command and Query responsibilities.
  • Event-Driven Architecture: Provides loose coupling by enabling communication between modules via events.
  • Built-in Server: Start developing APIs quickly with HTTP server integration.
  • Scheduler: Built-in scheduler support for managing background tasks and scheduled jobs.
  • Extensible: Easily integrate your own modules and components.

Installation

To add bakend-framework to your project, use the following command:

go get github.com/Deepreo/bakend

Usage

You can follow these steps to create a simple bakend application:

package main

import (
	"context"
	"log/slog"
	"os"

	"github.com/Deepreo/bakend"
	"github.com/Deepreo/bakend/core"
	// ... other imports
)

func main() {
    // Create Logger
    logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))

    // Initialize necessary components (Server, Buses, etc.)
    // Note: Implementations of these components must be provided within the framework or externally.
    // For example, mock or in-memory implementations can be used.
    
    // Create the application
    app, err := bakend.New(
        server,
        commandBus,
        queryBus,
        eventBus,
        scheduler,
        *logger,
    )
    if err != nil {
        logger.Error("Failed to create application", "error", err)
        os.Exit(1)
    }

    // Run the application
    if err := app.Run(context.Background()); err != nil {
        logger.Error("Application error", "error", err)
        os.Exit(1)
    }
}

Modules

The framework offers (or aims to offer) ready-made modules for various functions:

  • Auth: Authentication and authorization.
  • Database: Database connection and management operations.
  • Cache: Caching mechanisms.
  • Event: Event management and distribution.
  • Scheduler: Scheduled tasks.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteQuery

func ExecuteQuery[Q core.Query, R core.QueryResponse](ctx context.Context, bus core.QueryBus, query Q) (R, error)

func RegisterCommand

func RegisterCommand[C core.Command, H core.CommandHandler[C]](app *Application, handler H) error

func RegisterEndpoint

func RegisterEndpoint[R core.Request, Res core.Response](app *Application, method, path string, handler core.HandlerInterface[R, Res])

func RegisterEvent

func RegisterEvent[E core.Event](app *Application, handler core.EventHandler[E]) error

func RegisterQuery

func RegisterQuery[Q core.Query, R core.QueryResponse](app *Application, handler core.QueryHandler[Q, R]) error

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func New

func New() (*Application, error)

func (*Application) GetCommandBus

func (app *Application) GetCommandBus() core.CommandBus

func (*Application) GetEventBus

func (app *Application) GetEventBus() core.EventBus

func (*Application) GetQueryBus

func (app *Application) GetQueryBus() core.QueryBus

func (*Application) GetScheduler

func (app *Application) GetScheduler() core.Scheduler

func (*Application) Run

func (app *Application) Run(ctx context.Context) error

func (*Application) Shutdown

func (app *Application) Shutdown(ctx context.Context) error

Directories

Path Synopsis
modules

Jump to

Keyboard shortcuts

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