> For the complete documentation index, see [llms.txt](https://blog.htunnthuthu.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.htunnthuthu.com/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns.md).

# UI Patterns

UI patterns define how user interface code is structured — specifically how the **view layer** communicates with business logic and data. Getting this right prevents the classic problem of business logic scattered inside button click handlers.

## Pattern Index

| #  | Pattern                                                                                                                                 | Description                                          | Best For                         |
| -- | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -------------------------------- |
| 01 | [Forms and Controls](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/01-forms-and-controls.md) | Structuring form state, validation, and submissions  | Data-entry UIs, admin dashboards |
| 02 | [MVC — Model View Controller](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/02-mvc.md)       | Controller mediates user actions to model updates    | Web frameworks, desktop GUIs     |
| 03 | [MVP — Model View Presenter](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/03-mvp.md)        | Presenter handles all view logic; view is passive    | Android, testable UIs            |
| 04 | [MVVM — Model View ViewModel](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/04-mvvm.md)      | ViewModel exposes observable state; view binds to it | React, Vue, WPF, data-driven UIs |

## How to Navigate

If you are choosing a pattern for a new project, a short decision guide:

* Building a **Vue or React** reactive frontend → [MVVM](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/04-mvvm.md)
* Need a **fully testable presenter layer** without a real DOM → [MVP](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/03-mvp.md)
* Working with a **server-side rendered framework** (Django, Rails, Express) → [MVC](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/02-mvc.md)
* Focused on **form-heavy data entry** with complex validation → [Forms and Controls](/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns/01-forms-and-controls.md)

## Relationship to Application Patterns

UI patterns describe the view tier in isolation. They sit on top of the application patterns described in the `application-patterns/` directory:

```
UI Pattern (View layer)
  └── Application Pattern (Use case / service layer)
        └── System Pattern (Infrastructure / deployment)
```

An MVVM ViewModel calls an application service. That service follows Layered, Onion, or Ports & Adapters architecture internally. The choice of one layer's pattern is independent of the other layers.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.htunnthuthu.com/architecture-and-design/architecture-and-patterns/software-architecture-101/ui-patterns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
