Directory Structure

Learn about the directory structure of a Dracory application.

Directory Structure (Blueprint)

The Dracory Blueprint is the recommended starter layout for new Dracory apps. It provides clear separation of concerns and follows Go standard project layout patterns.

Root

Top-level folders in the Blueprint repository:

  • .github/ – CI workflows, e.g., workflows/tests.yml.
  • .vscode/ – Editor settings and launch configs.
  • cmd/ – CLI apps (e.g., server, deploy, envenc, snakecase).
  • internal/ – Application code (app boot, controllers, stores, etc.).
  • pkg/ – Reusable packages exported for import by other projects.
  • Project files: go.mod, Dockerfile, taskfile.yml, etc.

cmd

Command-line applications:

  • cmd/server/ – Main application entry point. Split into main.go, background.go, background_processes.go, and cli_mode.go for clean separation of server lifecycle, background workers, and CLI mode.
  • cmd/deploy/ – Deployment utility.
  • cmd/envenc/ – Environment encryption utility.
  • cmd/snakecase/ – String case conversion utility.

Internal

Key internal packages (Blueprint):

  • internal/app/ – App bootstrap, lifecycle, stores wiring (datastores.go), database connection (database_open.go), and migrations.
  • internal/cache/ – Cache interfaces and implementations.
  • internal/cli/ – CLI entry points and flags; cli.go bundles commands.
  • internal/cmsblocks/ – CMS block type components (e.g., blogpost).
  • internal/config/ – Configuration system with Blueprint-style environment loading. Contains constants.go (env keys), config_interfaces.go (interfaces), config_implementation.go (implementation), section-specific loaders (app_config.go, auth_config.go, database_config.go, email_config.go, etc.), store_builders.go (store factory functions), and version.go.
  • internal/controllers/ – Admin/Website controllers and their routes.
  • internal/emails/ – Email templates and sending logic.
  • internal/ext/ – External integrations.
  • internal/helpers/ – Shared helpers and utilities.
  • internal/layouts/ – Layout templates.
  • internal/links/ – Centralized route constants.
  • internal/middlewares/ – HTTP middlewares.
  • internal/models/ – Shared model definitions.
  • internal/resources/ – Static resource handling (embedded assets).
  • internal/routes/ – Router setup using github.com/dracory/rtr.
  • internal/rules/ – Business rule definitions (e.g., rules/auth).
  • internal/schedules/ – Scheduled job configuration.
  • internal/tasks/ – Background task definitions, each in its own subdirectory. Includes internal/tasks/constants/ for compile-time safe task alias constants.
  • internal/testutils/ – Test environment and HTTP helpers with automatic store migrations via migrations.MigrateAll.
  • internal/types/ – Shared interfaces and type definitions.
  • internal/utils/ – Miscellaneous utilities.
  • internal/widgets/ – UI widget components.

pkg

Selected reusable packages included with the Blueprint:

  • pkg/blogblocks/ – Block editor definitions.
  • pkg/blogtheme/ – Theme components (images, links, headings).
  • pkg/pool/ – Worker pool and build cache helpers.
  • pkg/testimonials/ – Testimonial types and list handling.

Note: Other repos (like this website) may contain additional pkg/* modules (e.g., pkg/gos/, pkg/blogadmin/, pkg/ragstore/, pkg/useradmin/). The Blueprint focuses on essentials.

Configuration

Configuration is env-driven and loaded from .env via internal/config. The entry point is config.NewFromEnv() which reads environment variables, hydrates encrypted values, validates required keys, and returns a config.ConfigInterface. Env keys are defined in internal/config/constants.go.

Assets & Templates

The Blueprint itself does not ship with public/ or views/ by default. Applications created from the Blueprint typically add these as needed.