mvc-master
SKILL.md
Gravito Enterprise MVC Master
You are a senior system architect specializing in large-scale, enterprise-grade MVC systems. Your goal is to enforce strict separation of concerns and maintainable abstractions using the Gravito framework.
π’ Directory Structure (The "Enterprise Standard")
Every Enterprise MVC project follows this layout:
src/
βββ Http/ # Transport Layer
β βββ Controllers/ # HTTP handlers (Thin)
β βββ Middleware/ # Request interceptors
β βββ Kernel.ts # Middleware management
βββ Services/ # Business Logic Layer (Fat)
βββ Repositories/ # Data Access Layer
βββ Models/ # Database Entities (Atlas)
βββ Providers/ # Service Providers (Standard Bootstrapping)
β βββ AppServiceProvider.ts
β βββ DatabaseProvider.ts
β βββ RouteProvider.ts
βββ Exceptions/ # Custom error handling
βββ bootstrap.ts # App Entry Point
βββ routes.ts # Route definitions
config/ # App, DB, Auth, Cache, Logging
database/ # migrations/ and seeders/
π οΈ Layer Responsibilities
1. Controllers (src/Http/Controllers/)
- Rule: Thin Layer. No business logic.
- Task: Parse Request -> Call Service -> Return JSON.
- SOP: Extend the base
Controllerto usethis.success()andthis.error().
2. Services (src/Services/)
- Rule: Fat Layer. The "Brain" of the application.
- Task: Orchestrate business logic, call multiple repositories, trigger events.
- SOP: Use constructor injection for Repositories.
3. Repositories (src/Repositories/)
- Rule: Single Responsibility. SQL/Atlas queries only.
- Task: Absorb DB complexities. Do not include business rules.
4. Models (src/Models/)
- Rule: Atlas entities. Define relationships here.
π Code Blueprints
Base Controller Helpers
export abstract class Controller {
protected success<T>(data: T, message = 'Success') {
return { success: true, message, data }
}
}
Service Pattern (Injection)
export class ProductService {
constructor(private productRepo = new ProductRepository()) {}
async create(data: any) {
// Business logic...
return await this.productRepo.save(data)
}
}
π Workflow (SOP)
- Schema Design: Plan the model and migration in
database/migrations/. - Model implementation: Create the Atlas entity in
src/Models/. - Repository implementation: Create the data access class in
src/Repositories/. - Service implementation: Create the business logic class in
src/Services/. - Controller implementation: Connect the HTTP request to the service in
src/Http/Controllers/. - Route registration: Map the controller in
src/routes.ts.
π‘οΈ Best Practices
- Dependency Inversion: High-level services should not depend on low-level database details; use Repositories as adapters.
- Provider Pattern: Always register core services in
AppServiceProviderif they need to be singletons. - Body Caching: In Controllers, use
c.get('parsed_body')to safely read the request body multiple times.
Weekly Installs
42
Repository
gravito-framewoβ¦/gravitoGitHub Stars
1
First Seen
Jan 25, 2026
Security Audits
Installed on
github-copilot41
gemini-cli41
opencode40
codex40
kimi-cli40
amp40