Skip to content

2 ‐ Architecture

Oscar Figueroa edited this page Aug 10, 2025 · 3 revisions

Layered Architecture

Organizes an application into horizontal tiers, each with a defined responsibility and dependency direction.

Presentation Layer

Handles HTTP requests, validation, and response formatting.

Application Layer

Orchestrates business use cases and workflows.

Domain Layer

Encapsulates core business rules, entities, value objects, and invariants.

Persistence Layer

Manages data storage and retrieval via repositories or DAOs.

Infrastructure Layer

Integrates with external systems (email, cache, logging).

Benefits:

  • Clear separation of concerns makes onboarding and maintenance easier.
  • Layers can be developed and tested independently.
  • Encourages consistent organization across teams and services.

Dependency Injection

Is a design pattern that externalizes object creation, allowing components to declare dependencies rather than construct them.

Benefits:

  • Decouples high-level modules from low-level implementations.
  • Simplifies testing by swapping real dependencies with mocks or stubs.
  • Centralizes configuration of shared resources (database connections, services).

ORM

Object-Relational Mapping (ORM) frameworks bridge the gap between in-memory object models and relational databases.

Benefits:

  • Reduces boilerplate CRUD code.
  • Enforces schema and model consistency.
  • Integrates migrations for safe schema updates.
  • Entity mapping with decorators or configuration files.
  • Query builders and repositories for type-safe data access.

Relational Data Base

Relational databases store data in structured tables with defined schemas and relationships.

Benefits:

  • Structured schema with data validation at the database level.
  • Powerful querying with SQL, including joins and aggregations.
  • Mature tooling for backup, replication, and monitoring.

RESTful

Defines principles for building scalable and evolvable web APIs.

Benefits:

  • Countless frameworks come with built-in support for REST.
  • Easier Evolution and Versioning.
  • Proven web security practices (HTTPS/TLS, OAuth, JWT)

Containerization

Packages applications and their dependencies into isolated, lightweight units.

Benefits:

  • Consistent environments across development, testing, and production.
  • Faster startup and lower overhead compared to VMs.
  • Simplified dependency and version management.

Architecture Diagram

                    REQUEST              RESPONSE
           Host OS    ↓                     ↑ 
           +-------------------------------------------+
           |                 Container                 |
           |          ↓                     ↑          |
           |  +-------------------------------------+  |
           |  |  Presentation Layer (Controllers)   |  |
           |  +-------------------------------------+  |
           |          ↓                     ↑          |
           |  +-------------------------------------+  |
           |  |  Application Layer (Services)       |  |
           |  +-------------------------------------+  |
           |          ↓                     ↑          |
           |  +-------------------------------------+  |
           |  |  Domain Layer (Entities)            |  |
           |  +-------------------------------------+  |
           |          ↓                     ↑          |
           |  +-------------------------------------+  |
           |  |  Persistence Layer (Repositories)   |  |
           |  +-------------------------------------+  |
           |          ↓                     ↑          |
           |  +-------------------------------------+  |
           |  |  Infrastructire Layer (RDBMS)       |  |
           |  +-------------------------------------+  |
           +-------------------------------------------+
Clone this wiki locally