CKTIS / JavaScript
Program architecture
Program architecture defines responsibilities, data flow, and dependency direction. In JavaScript, domain logic can be separated from use-case orchestration and environment interactions without requiring a particular framework.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
program architecture: domain logic + application orchestration + environment adaptersResponsibilities and boundaries
Program architecture (program architecture) is the arrangement of cooperating parts: their responsibilities, interfaces, and dependencies. It is not a single JavaScript construct. ECMAScript defines language mechanisms, including functions and modules, but does not prescribe application architecture. Splitting code into files alone does not guarantee separation of concerns.
A practical division
A useful arrangement separates domain logic, use-case orchestration, and environment adapters. Domain logic computes a result; application code determines the sequence of actions; an adapter stores data or handles input and output. Passing in a function for an external operation is a simple form of dependency injection: application code need not select a concrete storage mechanism.
Reading the example
calculateTotal sums amounts in minor currency units without changing the supplied array. createCheckout receives the saveTotal function, and the returned checkout function computes the total and passes it to storage. The savedTotals array stands in for an external data store. For [1200, 800], the expected total is 2000. The example assumes valid, nonnegative integers and a total within the safe integer range.
Scope and limitations
This is a synchronous demonstration of responsibility boundaries, not a complete payment system: validation, storage failures, and concurrency are omitted. Functions remain in one snippet for easy execution; a larger program can expose such boundaries through export and import. The example uses language features available since ECMAScript 2015. It requires no Web APIs; console.log is supplied by the environment, not ECMAScript. Node 24 in a repository does not establish browser API support.
Examples
function calculateTotal(prices) {
return prices.reduce((sum, price) => sum + price, 0);
}
function createCheckout(saveTotal) {
return function checkout(prices) {
const total = calculateTotal(prices);
saveTotal(total);
return total;
};
}
const savedTotals = [];
const checkout = createCheckout((total) => savedTotals.push(total));
const total = checkout([1200, 800]);
console.log(JSON.stringify({ total, savedTotals }));Result
{"total":2000,"savedTotals":[2000]}The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.