architecture

A description of a Go service organized with clean architecture, where business rules, application actions, outside-system connections, and API handling are kept in separate layers. It uses gRPC, MySQL, Docker, Go Modules, and Protocol Buffers.

In plain words
What is it for?
Use it as a reference when designing or changing this project's domain, use-case, infrastructure, or presentation layers and their data flow.
Why use it?
Separating these responsibilities makes it clearer where code belongs and reduces the chance that API, database, and business logic become tangled together.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/showcase-gig-platform/cursor-rules-initializer/architecture
Clone the repo
git clone --depth 1 https://github.com/showcase-gig-platform/cursor-rules-initializer

Made for: Cursor.

Per session 2,621 This file is loaded in full into every session.
When invoked 2,621 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02621 $0.02621
Opus 5 $0.01311 $0.01311
Sonnet 5 $0.00524 $0.00524
Haiku 4.5 $0.00262 $0.00262

Measured 2d ago against content hash 48aab392e5e1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/commands/cursor-rules-initializer/sample/rules/base/architecture.mdc · 208 lines

How it starts

The opening of the file, as written. The whole thing — 208 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Sample Go Project アーキテクチャ概要

技術スタック

バックエンド

  • 言語: Go
  • フレームワーク: gRPC
  • データベース: MySQL
  • コンテナ化: Docker, Docker Compose

開発ツール

  • パッケージ管理: Go Modules
  • モック生成: gomock
  • プロトコル定義: Protocol Buffers

アーキテクチャ

クリーンアーキテクチャの採用

  • このプロジェクトはクリーンアーキテクチャ/オニオンアーキテクチャのプリンシパルに従って設計されています。
app/
├── domain/          # ドメインロジック、エンティティ、値オブジェクト
├── usecase/         # ユースケース(アプリケーションロジック)
├── infrastructure/  # 外部サービスとの連携、データベースアクセス
└── presentation/    # プレゼンテーション層(API エンドポイント)

レイヤー構造

  1. ドメイン層 (domain/)

    • ビジネスロジックの中心
    • エンティティと値オブジェクトの定義
    • リポジトリインターフェースの定義
    • ドメインサービスの実装
    • 詳細は domain-rule.mdc を参照すること
  2. ユースケース層 (usecase/)

    • アプリケーションのユースケース実装
    • ドメインオブジェクトの操作
    • トランザクション管理
    • 入出力データ変換(DTOパターン)
    • 詳細は usecase-rule.mdc を参照すること
  3. インフラストラクチャ層 (infrastructure/)

    • データベースアクセス実装
    • 外部APIクライアント
    • リポジトリの実装
    • 詳細は infrastructure-rule.mdc を参照すること
  4. プレゼンテーション層 (presentation/)

    • API エンドポイントの定義
    • リクエスト/レスポンスの変換
    • バリデーション
    • エラーハンドリング
    • 詳細は presentation-rule.mdc を参照すること

データフロー

典型的なリクエスト処理のフローは以下のようになります:

  1. クライアントからのgRPCリクエストがプレゼンテーション層のコントローラーに到達
  2. コントローラーがリクエストを検証し、DTOに変換
  3. 対応するユースケースを呼び出し
  4. ユースケースがドメインオブジェクトを操作し、ドメインロジックを実行する
  5. ユースケースから、リポジトリを使用することで永続化の実行、データの取得をする
  6. ユースケースが結果をDTOに変換
  7. コントローラーがDTOをプロトコルバッファレスポンスに変換
  8. レスポンスがクライアントに返される

依存性の方向

依存関係は常に外側から内側に向かって流れます:

Presentation → Usecase → Domain
Infrastructure → Domain

ドメイン層は他のどの層にも依存せず、最も安定した層です。これにより、ビジネスロジックの変更が他の層に影響を与えにくくなります。

主要なコンポーネント

gRPCサービス
  • proto/ ディレクトリにサービス定義
  • 型安全なAPI通信
  • 双方向ストリーミングのサポート
  • 自動生成されたコードは gen/ ディレクトリに配置

実装ポイント:

  • プロトコル定義は明確で一貫性のある命名規則に従います
  • バージョニングを適切に行い、後方互換性を維持します
  • フィールドには明示的な番号を割り当て、将来の拡張性を確保します
  • コメントを適切に記述し、自動生成されるドキュメントを充実させます
依存性注入
  • cmd/di/ で依存関係を管理
  • クリーンな依存グラフの実現
  • テスタビリティの向上

実装ポイント:

  • 依存関係は明示的にコンストラクタで注入します
  • 循環依存を避けるために依存グラフを慎重に設計します
  • テスト時にはモックオブジェクトを注入できるようにします
  • 依存関係の初期化順序に注意します

Read the full file on GitHub · 208 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 208 lines · 2,621 tokens per session scan A 48aab392e5e1

Subscribe to this mod's changes

architecture is a cursor rule published in the GitHub repository showcase-gig-platform/cursor-rules-initializer (7 stars, last pushed 9mo ago), licensed MIT. It adds 2,621 tokens to every session, about $0.0131 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.