Understanding the C4 model for software architecture c4-model

Understanding the C4 model for software architecture

The C4 model documents software architecture as four zoom levels: Context, Containers, Components, and Code. See how the diagrams work on a concrete example (a paid blog application) and why this hierarchy keeps developers and stakeholders oriented.

Aug 26, 2024

How to set up XML in Grape API

How to set up XML in Grape API

XML support in Grape API takes two steps: register the additional content_type so endpoints accept and return application/xml, then change the root element name of the XML output. Complete Ruby examples built around a products endpoint you can adapt to your API.

Understanding generic types in Typescript

Understanding generic types in Typescript

Generic types in TypeScript let one function, class, or interface work safely with many data types. What generics are, how a type parameter beats hardcoding a concrete entity type in a validation helper, and honest pros and cons before you use them everywhere.

Ruby in browser via WebAssembly

Ruby in browser via WebAssembly

Ruby 3.2 runs in the browser through WebAssembly: embed Ruby in a script tag with ruby-wasm-wasi or drive the Ruby VM from JavaScript and mix it with HTML. Working examples plus honest limits: no threading or networking, and no extra gems without a custom wasm image.

Solutions for const and enums per class in Ruby

Solutions for const and enums per class in Ruby

Three ways to define constants and enums per class in Ruby: the ActiveRecord enum macro, a mixed style combining frozen constants with enum, and a dependency-free PORO version. Code for each solution and a comparison to help you pick the right one.

Consider using Apipie gem twice

Consider using Apipie gem twice

Apipie looks like an easy way to document a Rails API, but check its limits first: no advanced type constraints like exactly_one_of, only partial OpenAPI support, and weak handling of output examples. What to weigh before picking the gem for a larger application.