prabogo

repository·master·Indexed 18 days ago

https://github.com/prabogo/prabogo

A Go framework for streamlined software engineering featuring an interactive CLI and spec-driven development. It integrates with AI agents via Spec Kit, supports automated scaffolding for HTTP handlers and database adapters, and utilizes Hexagonal Architecture (Ports and Adapters) to isolate core business logic from external dependencies. The framework includes support for Authentik JWT and internal bearer key authentication, and provides Docker Compose configurations for PostgreSQL, Redis, and RabbitMQ.

Tokens
13.2K
Snippets
64
Records
72
Agent score
62%

What's inside prabogo

  1. Understand the Prabogo Hexagonal Architecture

    master

    Prabogo uses a hexagonal architecture (ports and adapters) to ensure a strict separation between core business logic and external infrastructure.

    Core Components

    • Domain Logic (internal/domain/): Contains the core business rules. It is technology-agnostic and only interacts with the outside world through Ports.
    • Ports (internal/port/): Interfaces that define contracts for communication.
      • Inbound Ports: How the world talks to your app (e.g., HTTP, CLI, RabbitMQ consumers).
      • Outbound Ports: How your app talks to the world (e.g., Databases, HTTP clients, Redis).
    • Adapters (internal/adapter/): Concrete implementations of ports.
      • Inbound Adapters: Handle incoming requests (e.g., Fiber for HTTP, Temporal for workflows).
      • Outbound Adapters: Handle outgoing requests (e.g., Postgres for DB, Redis for cache).
    • Models (internal/model/): Shared data structures and entities used across the application.

    Dependency Flow

    To maintain decoupling, dependencies must always point inward:

    1. Domain logic depends on ports (interfaces).
    2. Adapters implement those ports.
    3. The application wires the specific adapters to the ports at startup.
  2. Compare Prabogo authorization methods

    master

    Choose the authentication strategy based on your security and scalability requirements:

    FeatureInternal Bearer KeyAuthentik JWT
    Setup ComplexitySimpleModerate
    Security LevelGood (with mTLS)Excellent
    ScalabilityLimitedHigh
    External DependenciesDatabase onlyAuthentik server
    Token ManagementManualAutomatic
    SSO SupportNoYes
  3. How Spec-Driven Development works in Prabogo

    master

    Prabogo uses Spec Kit to implement a Spec-Driven Development workflow. Instead of using traditional agent roles, you guide an AI agent (like GitHub Copilot) through a structured seven-step process using specific slash commands. This workflow separates the definition of what to build (requirements) from how to build it (technical implementation), ensuring that specifications are validated before any code is written.

    The 7-Step Workflow

    1. Define Constitution: Set core project rules.
    2. Specify Requirements: Describe the feature's purpose and user needs.
    3. Clarify Specification: Resolve ambiguities in the requirements.
    4. Validate Specification: Generate a checklist to ensure the spec is complete.
    5. Plan Implementation: Define the tech stack and architecture.
    6. Generate Tasks: Create a dependency-ordered list of actionable tasks.
    7. Analyze and Implement: Audit the plan for consistency, then execute the tasks.
    1. /speckit.constitution [Rules]
    2. /speckit.specify [Requirements]
    3. /speckit.clarify [Ambiguities]
    4. /speckit.checklist
    5. /speckit.plan [Tech Stack]
    6. /speckit.tasks
    7. /speckit.analyze
       /speckit.implement
  4. Understand Hexagonal Architecture (Ports and Adapters)

    master

    Prabogo utilizes Hexagonal Architecture (also known as the Ports and Adapters pattern) to isolate core business logic from external dependencies. This design ensures that the application can evolve independently of databases, APIs, or user interfaces.

    Core Components

    • Domain: The core business logic and rules. It is entirely independent of external systems or frameworks.
    • Application: The layer responsible for coordinating activities and orchestrating the domain logic.
    • Port: An interface that defines how the application communicates with the outside world. Ports act as the boundary for the core.
    • Adapter: A component that implements a Port to connect the core to external technologies or systems.

    Interaction Model

    External entities interact with the application through specific adapters:

    • REST: Interacts via RESTful APIs through an adapter.
    • Message Broker: Communicates asynchronously via a messaging adapter.
    • MCP Client: Invokes application tools through a Model Context Protocol (MCP) adapter.
    • Database/Cache: Accessed through adapters for data persistence and retrieval.

    By using this pattern, you can substitute real external systems with mocks or stubs during testing, allowing the core logic to be tested in isolation.

  5. Use Spec Kit commands in AI Agents

    master

    Once Spec Kit is initialized, you can use the following structured commands within your configured AI agent (like GitHub Copilot) to drive development:

    • /speckit.constitution: Define project principles.
    • /speckit.specify: Write technical specifications.
    • /speckit.plan: Create an implementation plan.
    • /speckit.tasks: Generate specific tasks.
    • /speckit.implement: Execute implementation based on the plan.
  6. Install and use prabogo-cli

    master

    The prabogo-cli is used for code generation and managing runtime targets.

    Installation:

    go install github.com/prabogo/prabogo-cli@latest

    Interactive Mode: Run prabogo-cli run to open an interactive menu for selecting targets. If fzf is installed, it uses fuzzy-search; otherwise, it falls back to a numbered menu.

    To install fzf (recommended):

    • macOS: brew install fzf
    • Linux: apt install fzf (Ubuntu/Debian) or dnf install fzf (Fedora)
    • Windows: choco install fzf
    go install github.com/prabogo/prabogo-cli@latest
    prabogo-cli run
  7. Run Prabogo in Development Mode

    master

    To run the application directly using Go, ensure all required environment variables are set (via .env or manual export) and external dependencies (PostgreSQL, RabbitMQ, Redis) are running.

    go run cmd/main.go <option>

    Example:

    go run cmd/main.go http
  8. Generate PDF from documentation files

    master

    You can convert Markdown documentation files into PDF format using the md-to-pdf utility. This requires installing the package globally via npm and then running the command against your target Markdown file.

    $ npm install -g md-to-pdf
    $ md-to-pdf docs/filename.md
  9. Configure Spec Kit for different AI Agents

    master

    Spec Kit supports multiple AI coding agents. You can list available integrations and reinitialize the project to match your specific tool.

    1. List integrations:

      specify integration list
    2. Reinitialize for a specific agent: Use the --integration flag with your preferred tool (e.g., claude or gemini). This rewrites the agent-specific command and instruction files while maintaining the core workflow.

    specify init . --integration claude
    specify integration list
    specify init . --integration claude
  10. Generate new components with prabogo-cli

    master

    Prabogo provides specialized generators to automate the creation of boilerplate for models, migrations, and adapters. When providing a <name>, use snake_case (e.g., user_profile).

    Models and Migrations

    • prabogo-cli model <name>: Creates a new model structure.
    • prabogo-cli migration-postgres <name>: Creates PostgreSQL migration files.

    Inbound Adapters (Receiving Requests)

    • prabogo-cli inbound-http-fiber <name>: Creates HTTP handler interfaces, Fiber adapters, and registry updates.
    • prabogo-cli inbound-message-rabbitmq <name>: Creates RabbitMQ consumer interfaces and adapters.
    • prabogo-cli inbound-command <name>: Creates CLI command handler interfaces and adapters.
    • prabogo-cli inbound-workflow-temporal <name>: Creates Temporal workflow interfaces and adapters.

    Outbound Adapters (Sending Requests)

    • prabogo-cli outbound-database-postgres <name>: Creates PostgreSQL database interfaces and adapters.
    • prabogo-cli outbound-http <name>: Creates HTTP client interfaces and adapters.
    • prabogo-cli outbound-message-rabbitmq <name>: Creates RabbitMQ producer interfaces and adapters.
    • prabogo-cli outbound-cache-redis <name>: Creates Redis cache interfaces and adapters.
    • prabogo-cli outbound-workflow-temporal <name>: Creates Temporal workflow starter interfaces and adapters.
  11. Install and Initialize Spec Kit

    master

    Prabogo uses Spec Kit for spec-driven development, allowing you to guide AI agents through structured planning and implementation.

    Prerequisites:

    • Python 3.11+
    • uv installed

    Installation: Install the specify-cli tool via uv:

    uv tool install specify-cli --from git+https://github.com/github/spec-kit.git@v0.8.4
    specify version

    Initialization: To initialize or refresh Spec Kit files in your project (e.g., for GitHub Copilot), run:

    specify init . --integration copilot

    This creates .specify/ for project files and .github/ directories for agent instructions and prompts.

    uv tool install specify-cli --from git+https://github.com/github/spec-kit.git@v0.8.4
    specify init . --integration copilot
  12. Configure Internal Bearer Key Authentication

    master

    Internal Bearer Key authentication uses client bearer keys stored in your database. This is the simplest method to implement but requires additional security layers for production use.

    To enable this method, set AUTH_DRIVER to an empty or blank value and provide your database connection details via environment variables.

    Security Recommendation: It is highly recommended to implement mTLS (mutual TLS) when using this approach to ensure mutual authentication and protect against man-in-the-middle attacks.

    # Set AUTH_DRIVER to empty/blank for internal authentication
    AUTH_DRIVER=
    
    # Other required configurations
    DATABASE_USERNAME=prabogo
    DATABASE_PASSWORD=prabogo
    DATABASE_HOST=localhost
    DATABASE_PORT=5432
    DATABASE_NAME=prabogo