Skip to main content

Architecture Layers

Simple Manager follows Clean Architecture principles with four distinct layers. Dependencies flow inward: outer layers depend on inner layers, but inner layers never depend on outer layers.

Layer Hierarchy

1

Domain Layer (Core)

Pure business logic and entities - no dependencies
2

Application Layer

Use cases and services - depends only on Domain
3

Infrastructure Layer

Database and external services - implements Domain interfaces
4

Presentation Layer

UI and user interaction - depends on Application

1. Domain Layer

Location

src/domain/
The innermost layer containing pure business logic with zero external dependencies.

Responsibilities

  • Define core entities and types
  • Establish business rules
  • Define interfaces (contracts)

Structure

Example: Record Entity

Domain entities are plain TypeScript interfaces with no dependencies on frameworks or libraries.

2. Application Layer

Location

src/application/
Contains use cases and business logic orchestration.

Responsibilities

  • Implement business use cases
  • Coordinate between domain and infrastructure
  • Handle validation
  • Manage error handling

Structure

Example: RecordService

Services contain business logic and use repositories to access data. They don’t know about UI or database implementation details.

3. Infrastructure Layer

Location

src/infraestructure/
Handles external concerns like databases, APIs, and file systems.

Responsibilities

  • Implement data persistence
  • Database access and queries
  • External API integration (future)
  • File storage

Structure

Example: Database Setup

Example: Repository Implementation

Repositories handle all database interactions. Never access the database directly from services or UI components.

4. Presentation Layer

Location

src/presentation/
The outermost layer containing UI components and user interaction logic.

Responsibilities

  • Render UI components
  • Handle user input
  • Manage local component state
  • Connect to application services via hooks

Structure

Example: Custom Hook

Custom hooks bridge the presentation layer and application layer, providing a clean API for components.

Benefits of This Architecture

Testability

Each layer can be tested independently with mocked dependencies

Maintainability

Clear separation of concerns makes code easier to understand and modify

Scalability

Easy to add new features without affecting existing code

Flexibility

Swap implementations (e.g., SQLite → API) without changing business logic

Dependency Rule

Critical Rule: Dependencies must point inward only. Inner layers must never import from outer layers.

Data Flow

See how data moves through layers

Folder Structure

Explore the complete project structure