Go API Framework
Go to file
2026-06-17 21:41:40 +08:00
data upd: framework and software resources added 2026-06-14 02:33:41 +08:00
essential upd: helper utilities updated 2026-06-17 21:41:40 +08:00
operational add: project structure created 2026-06-11 08:13:48 +08:00
run add: project structure created 2026-06-11 08:13:48 +08:00
.gitignore upd: makefile, readme, and license updated 2026-06-12 22:49:08 +08:00
CHANGELOG.md add: project structure created 2026-06-11 08:13:48 +08:00
go.mod upd: helper utilities updated 2026-06-17 21:35:35 +08:00
go.sum upd: helper utilities updated 2026-06-17 21:35:35 +08:00
LICENSE.md upd: makefile, readme, and license updated 2026-06-12 22:49:08 +08:00
Makefile upd: makefile, readme, and license updated 2026-06-12 22:49:08 +08:00
README.md upd: helper utilities updated 2026-06-17 21:35:35 +08:00

API Framework

Description

API Framework is a layered API software framework designed to provide a structured foundation for building maintainable, scalable, and extensible web services.

The framework separates framework capabilities, software capabilities, resource management, request processing, policy enforcement, and runtime execution into clearly defined architectural layers. It provides standardized request handling, response generation, execution pipelines, reusable utility services, and runtime orchestration while maintaining strict ownership boundaries between framework and software components.

The framework supports:

  • API request routing
  • Request processing
  • Response generation
  • Policy-driven execution
  • Authentication and authorization pipelines
  • Rate limiting and validation policies
  • Runtime lifecycle management
  • Reusable infrastructure services

The architecture is organized into four primary layers:

  • Data — Framework and software resources.
  • Essential — Reusable framework capabilities and infrastructure.
  • Operational — Software-specific business capabilities and policies.
  • Run — Runtime initialization, execution, and request processing.

This separation enables developers to focus on software behavior while relying on a consistent framework foundation for API processing, security, policy enforcement, utility services, and runtime coordination.


Purpose

API Framework exists to provide a consistent, maintainable, and extensible architecture for building API-driven softwares while establishing clear boundaries between framework responsibilities and software responsibilities.

Objectives

  • Establish clear separation of concerns.
  • Standardize API request and response processing.
  • Distinguish framework-owned and software-owned resources.
  • Provide reusable infrastructure and utility capabilities.
  • Centralize policy enforcement and access control.
  • Simplify software development through a structured architecture.
  • Improve maintainability and scalability.
  • Enable controlled software extensibility.
  • Protect internal framework implementation details.
  • Encourage consistent API design and execution patterns.

Design Principles

Layered Architecture

Each architectural layer is responsible for a specific concern and communicates through clearly defined boundaries.

Ownership Separation

Framework-owned capabilities remain separate from software-owned capabilities to prevent implementation leakage and architectural drift.

Extensibility

Softwares extend the framework through approved extension surfaces without modifying framework internals.

Reusability

Common functionality is implemented once and reused throughout both framework and software layers.

Encapsulation

Internal framework implementation details remain hidden behind stable interfaces.

Policy-Driven Execution

Request processing and business operations are governed through dedicated execution pipelines and policy enforcement mechanisms.

Consistency

Request handling, response generation, execution patterns, and resource management follow standardized conventions throughout the framework.


Architecture

High-Level Structure

source
├── data
├── essential
├── operational
└── run

The architecture is organized into four primary layers that collectively provide resource management, reusable framework capabilities, software capabilities, policy enforcement, and runtime execution.


Data Layer

The Data Layer stores all framework-owned and software-owned resources.

source/data
├── framework
│   ├── metadata
│   └── glossary
└── software
    ├── metadata
    └── glossary

Responsibilities

  • Store framework metadata and configuration resources.
  • Store framework glossary and terminology resources.
  • Store software metadata and configuration resources.
  • Store software glossary and terminology resources.
  • Provide centralized resource ownership boundaries.

Ownership

Area Owner
data/framework Framework
data/software Software

Essential Layer

The Essential Layer contains reusable framework capabilities, infrastructure services, request processing capabilities, and shared functionality.

source/essential
├── exchange
├── hidden
└── visible

Essential Exchange

Provides the framework API interaction model.

exchange
├── router
├── request
├── response
└── imperative

Responsibilities

  • API request routing.
  • Request processing.
  • Response generation.
  • Imperative execution.
  • Framework-level API orchestration.

Essential Hidden

Contains internal framework capabilities that are not intended for software consumption.

hidden
└── service
    └── management

Management

Framework runtime management capabilities.

management
├── initialize
├── lifecycle
├── config
├── monitor
└── cleaner
Initialize

Responsible for framework and runtime initialization.

Lifecycle

Responsible for:

  • Startup
  • Shutdown
  • Restart operations
Config

Responsible for runtime configuration management.

Monitor

Responsible for runtime health and operational monitoring.

Cleaner

Responsible for maintenance and cleanup operations.

Responsibilities

  • Runtime initialization.
  • Lifecycle management.
  • Runtime configuration.
  • Monitoring and observability.
  • Maintenance operations.

Essential Visible

Contains reusable framework capabilities available to softwares.

visible
└── service
    └── helper

Available helper capabilities include:

retriever
status
log
progress
filesystem
datetime
marker
key
hash
cipher
codec

Responsibilities

  • Resource retrieval.
  • Status reporting.
  • Structured logging.
  • Progress tracking.
  • Filesystem operations.
  • Date and time utilities.
  • Identifier generation.
  • Key generation.
  • Hash calculation and comparison.
  • Encryption and decryption.
  • Encoding and decoding.

Operational Layer

The Operational Layer contains all software-specific behavior, business capabilities, and policy definitions.

source/operational
├── exchange
├── pipeline
└── service

This is the primary software development area.


Operational Exchange

Provides the software API interaction model.

exchange
├── router
├── request
├── response
└── imperative

Responsibilities

  • Software request routing.
  • Software request processing.
  • Software response generation.
  • Imperative execution.
  • Software-level API orchestration.

Operational Pipeline

Contains software-defined policy execution capabilities.

pipeline
└── policy
    ├── validation
    └── ratelimit

Validation

Responsible for request validation policies.

Examples:

  • Schema validation
  • Payload validation
  • Business rule validation

Rate Limit

Responsible for request throttling and usage control.

Examples:

  • Client limits
  • Endpoint limits
  • Resource protection

Responsibilities

  • Request validation.
  • Request throttling.
  • Policy definition.
  • Software-specific execution controls.

Operational Service

Contains software-specific business capabilities.

service
└── [service]
    └── [feature]

Example:

service
├── user
│   ├── create
│   └── delete
├── customer
│   └── register
└── invoice
    └── generate

Feature structure:

service
└── user
    └── create
        ├── function.go
        └── function-data.json

Responsibilities

  • Implement business rules.
  • Manage software workflows.
  • Execute domain-specific operations.
  • Consume reusable framework capabilities.

Runtime Layer

The Runtime Layer initializes, secures, coordinates, and executes API requests.

source/run
├── exchange
├── pipeline
└── main

Runtime Exchange

Receives incoming requests and dispatches execution.

exchange
├── router
├── request
├── response
└── imperative

Responsibilities

  • Runtime request handling.
  • Request dispatching.
  • Response delivery.
  • Execution coordination.

Runtime Pipeline

Provides execution-time access control and policy enforcement.

pipeline
├── access
└── policy

Access

Access control pipeline.

access
├── authentication
└── authorization
Authentication

Verifies the identity of the request originator.

Examples:

  • API Keys
  • JWT Tokens
  • Session Authentication
Authorization

Determines whether authenticated entities can access requested resources.

Examples:

  • Role-based access control
  • Permission-based access control
  • Scope validation

Policy

Responsible for runtime policy enforcement.

policy
└── enforce.go

Responsibilities:

  • Execute policy decisions.
  • Enforce validation outcomes.
  • Enforce access decisions.
  • Coordinate runtime controls.

Runtime Main

Software bootstrap and startup.

main
└── main.go

Responsibilities

  • Framework initialization.
  • Software initialization.
  • Runtime startup.
  • Lifecycle coordination.
  • API server bootstrap.

Request Lifecycle

The framework follows a layered request processing model.

Client Request
      │
      ▼
Runtime Exchange
      │
      ▼
Access Pipeline
(Authentication / Authorization)
      │
      ▼
Policy Enforcement
      │
      ▼
Software Exchange
      │
      ▼
Software Policies
(Validation / Rate Limiting)
      │
      ▼
Software Service
      │
      ▼
Framework Services
      │
      ▼
Resource Layer
      │
      ▼
Response

Ownership Model

Layer Owner Responsibility
data/framework Framework Framework resources
data/software Software Software resources
essential Framework Reusable framework capabilities
operational Software Business capabilities and policies
run Framework Runtime execution and enforcement

Extension Surface

Softwares are expected to extend the framework through the following locations:

source/data/software
source/operational

Softwares should consume reusable framework capabilities from:

source/essential/visible

Softwares should not directly depend on:

source/essential/hidden

as these components are considered internal framework implementation details and may change without notice.