Skip to content

Software Architecture Design

Weixian edited this page May 27, 2026 · 13 revisions

Proposed patterns

  • Composite root - wires up the dependency injection container at startup
  • Transaction Script - Organizes business logic by procedures where each procedure handles a single request from the presentation layer
  • Domain Model - classes and structs interconnected to model the business domain and incorporates both behavior and data.
  • Table Data Gateway - An object that acts as a gateway to a database table. One instance handles all the rows in the table.
  • Row Data Gateway - An object that acts as a gateway to a single record in a data source. There is one instance per row.
  • Repository Pattern - creates an abstraction layer between an application's business logic and its data storage. It provides a standardized, collection-like interface to query, add, and remove data, hiding the low-level database implementation details from the rest of the application.

Which architecture should I pick?


Summary

Scenario Architecture
Small/simple app Layered
Enterprise system with complex logic Onion
Fast MVP/prototype Layered
Long-term scalable platform Onion
Mostly CRUD operations Layered

Layered Architecture for Small-Medium Projects


Characteristics

  • simple business logic that does not grow complex.
  • You want fast development
  • simple app, API, POC or MVP
  • You are building:
  • CRUD apps
  • Internal enterprise systems
  • Admin portals

Layered Architecture

Frontend

Presentation Layer - WebUI, Desktop App, Mobile App, CLI, Foundry Agent Service, more...

Backend

  • Application (API) Layer
  • Business Logic (Domain) Layer
    • Transaction Script pattern
  • Data Access Layer
    • Table Data Gateway
    • Row Data Gateway
    • Repository pattern

Onion Architecture for Medium-Large Projects


Characteristics

  • Complex business logic
  • Need for long-term maintainability
  • Multiple external dependencies (DB, APIs, queues)
  • Requirement for easy testing
  • Need to keep business rules independent from frameworks/technology
  • You are building:
  • Enterprise systems
  • Banking/payment systems
  • Large AI or logistics platforms
  • Systems expected to evolve for years
image

Logging

API layer logs:

request received correlation ID / trace ID authenticated user / tenant response status unhandled exception

Application layer logs:

use case started important decisions or branches use case completed business failure that matters operationally

Domain layer logs:

generally no logging maybe only in rare cases if your domain services are acting like transaction scripts and you really need observability even then, keep it minimal

Infrastructure layer logs:

external calls failed DB retries / timeouts queue publish failures HTTP client failures adapter-specific technical details

  1. Agile Delivery
    1. Product Requirement Template
    2. Documenting Product Requirements
    3. Estimation & Sizing
  2. DevOps
    1. Gitlab Flow with Release Branches
    2. DevOps Pipelines
  3. Software Architecture Design
    1. Agent Engineering
    2. Logging
  4. Tech Stack
  5. Testing & Quality
  6. Observability & Operations

Clone this wiki locally