architecture-for-apps

Rules for organizing an ArchiPy application into layers such as configuration, data models, repositories, business logic, and web or network services.

In plain words
What is it for?
Use them when designing an ArchiPy app, deciding where code belongs, or checking how requests should flow from services to databases.
Why use it?
They prevent unrelated layers from depending on each other in confusing ways and keep business rules separate from frameworks and data access.

Cursor rule

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/syntaxarc/archipy-plugin/architecture-for-apps
Clone the repo
git clone --depth 1 https://github.com/SyntaxArc/archipy-plugin
Per session 691 This file is loaded in full into every session.
When invoked 691 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.00691 $0.00691
Opus 5 $0.00345 $0.00345
Sonnet 5 $0.00138 $0.00138
Haiku 4.5 $0.00069 $0.00069

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

Security

Grade A, and why

architecture-for-apps 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.

rules/architecture-for-apps.mdc · 70 lines

How it starts

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

Architecture for ArchiPy Apps

Use this when building applications that depend on the archipy package (not when maintaining ArchiPy itself).

Live concepts: https://syntaxarc.github.io/ArchiPy/getting-started/concepts/

Layer Map

your_app/
├── configs/          # BaseConfig subclasses, DI containers
├── models/           # Entities, DTOs, errors, types — data structures only
│   └── dtos/{domain}/
│       ├── domain/v{n}/   # Versioned — cross service boundary
│       └── repository/    # Internal — never versioned
├── repositories/
│   └── {domain}/
│       ├── adapters/              # Domain wrappers around ArchiPy adapters
│       └── {domain}_repository.py # Orchestrate adapters; map to DTOs
├── logics/
│   └── {domain}/         # Use-case / unit-of-work boundaries
└── services/
    └── {domain}/v{n}/    # Transport (HTTP/gRPC routers), versioned

Optional app-local helpers (prefer archipy.helpers first): helpers/{utils,decorators,interceptors}/.

Call Flow

services → logics (atomic UoW) → repositories → adapters → ArchiPy

Plugin shorthand @atomic means a real *_sqlalchemy_atomic_decorator — there is no decorator named atomic.

Layer Rules

Layer details live in the matching using-archipy-*.mdc / config-and-di.mdc / testing-bdd-for-apps.mdc rules when those files are open. This always-on rule keeps only the global map:

  • models/ — data only (no I/O, no business rules).
  • repositories/ — domain data access; adapters under repositories/{domain}/adapters/; no cross-domain repo calls; map driver errors with raise ... from e.
  • logics/ — business rules + UoW (*_sqlalchemy_atomic_decorator); may call other logics; never other domains' repositories; no FastAPI/gRPC.
  • services/ — thin transport; versioned v{n}/; no UoW / business rules.
  • helpers/ — pure only; prefer ArchiPy; no adapter construction at module level.
  • configs/ — extend BaseConfig; set_global once; no secrets in code.

Read the full file on GitHub · 70 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 · 70 lines · 691 tokens per session scan A 8e459e7af121

Subscribe to this mod's changes

architecture-for-apps is a cursor rule published in the GitHub repository SyntaxArc/archipy-plugin (2 stars, last pushed 8d ago), licensed MIT. It adds 691 tokens to every session, about $0.0035 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.