nette-architecture
FreeNo executable scriptsNot checkedInvoke before designing presenters, modules, or application structure in web application. Use when asking about directory structure (app/ folder…
About this skill
For new projects, see the project skeleton reference.
For the #[Requires] attribute (HTTP method/AJAX restrictions on actions), see the documentation.
Application Architecture
Presenter Lifecycle
Understanding the request flow is essential for placing logic correctly:
checkRequirements()– evaluates the#[Requires]attributestartup()– use for access checks and early redirects. An override must callparent::startup(), otherwise Nette throwsInvalidStateExceptionaction<Name>()– processes the request (data writes, redirects)- canonicalization – the redirect to the canonical URL happens here, i.e. after the action
handle<Signal>()– signals run after the action phase and after canonicalization, not inside the action phasebeforeRender()– runs before every render, use for shared template variablesrender<Name>()– prepares data for the template (read-only, no redirects)afterRender()– after the render methods, before the template is sent- template is sent, then
shutdown()
Each phase also has an event: $onStartup, $onRender, $onShutdown.
The key insight: actions and signals do things (write, redirect), renders prepare views (read). Mixing these responsibilities leads to redirect-after-render bugs and untestable presenters.
Directory Structure
The application follows domain-driven organization. The reason: when code is grouped by domain (products, orders, customers), related files are close together and changes to one feature don't scatter across multiple directories.
- App: The main application namespace (
App\)- Bootstrap: Application initialization and configuration
- Core: Infrastructure concerns (routing, integrations)
- Entity: Database entities (see nette-database skill for entity design)
- Model: Business logic services organized by domain
- Presentation: UI layer organized by modules
- Tasks: Command-line executable tasks
Evolution Strategy
Start minimal -> Grow organically -> Refactor when painful
Start with flat structure – create subdirectories only when you have 5+ related files or clear implementation variants. The threshold exists because below 5 files, subdirectories add navigation overhead without improving discoverability.
Don't architect for theoretical future complexity. Address actual complexity when it emerges with clear user needs driving structural decisions.
When refactoring to deeper structure: Move files one domain at a time. Create the new subdirectory, move related presenters/services into it, update namespaces, and verify. Don't reorganize everything at once.
Configuration
- config/common.neon: Main application configuration
- config/services.neon: Service definitions and auto-wiring configuration
For DI configuration details (service registration, autowiring, parameters), see the nette-configuration skill.
Core vs Model Decision Matrix
The distinction matters because Core/ code is reusable across projects while Model/ code is specific to your business. This affects testability, replaceability, and team ownership.
Use Core/ for:
- Technology-agnostic infrastructure (MyExplorer, RouterFactory, QueueMailer)
- External service integrations (SentryLogger, AI/, GoogleSearch/)
- Framework extensions and utilities
- Code that could be moved to another project unchanged
Use Model/ for:
- Business domain logic (CatalogService, CustomerService, OrderService)
- Domain-specific operations and rules
- Entity-specific processing logic
- Code that knows about your business concepts (products, orders, customers)
Model Layer Principles
app/Model/
├── CatalogService.php ← Main domain services at root
├── CustomerService.php
├── OrderService.php
├── mails/ ← Email templates (specialized assets)
├── Payment/ ← Implementation variants
│ ├── CardOnlinePayment.php
│ ├── BankTransferPayment.php
│ └── CashPayment.php
└── exceptions.php ← Domain exceptions
Naming convention: mails/ is lowercase because it contains non-PHP assets (email templates). Payment/ is uppercase because it contains PHP classes following PSR-4.
Service placement rules:
- Main domain coordinator services directly in Model/
- Implementation variants get subdirectories when 3+ implementations exist
- Specialized assets (templates, exceptions) in focused locations
Module Structure
Modules group presenters by user audience and access requirements. Admin, Front, and Api have different authentication, layouts, and URL patterns – that's why they're separate modules, not just for organization.
app/Presentation/
├── Accessory/ ← UI shared across entire application
│ ├── LatteExtension.php
│ └── TemplateFilters.php
├── Admin/
│ ├── BasePresenter.php ← Admin-
Install nette-architecture in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
FAQ
What does the nette-architecture skill do?
Invoke before designing presenters, modules, or application structure in web application. Use when asking about directory structure (app/ folder organization), presenter organization (modules, Admin/Front/Api, BasePresenter), domain-driven placement (Core/ vs Model/), component and factory placement, presenter lifecycle (action/render/template), CLI tasks, Accessory placement, project skeleton, or refactoring architecture. Also trigger when starting a new Nette project.
How do I install the nette-architecture skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the nette-architecture skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic