liveBook · Manning

Constraint

As explained in Grokking Software Architecture

A practical limitation imposed by a project's operating context, such as available resources or environmental conditions.

A constraint is a practical limit that shapes which solutions are feasible. Time, money, and team capacity can narrow the options—and help focus design decisions. section 2.12 section 2.5.1

State constraints plainly before comparing designs. They help determine which qualities can be traded down and which must remain protected: an internal tool might temporarily favor speed over scalability, while security, reliability, or data integrity may be non-negotiable. section 2.5.1

A one-day CSV export

A background worker, message queue, and notification service would take about a week. With one day available, a direct web-request export can meet the immediate need in hours, but may time out on large datasets. It is a reasonable fit only if its limits and acceptable risks are understood. section 2.5.1

Listing 2.9 “Good enough for now” solution (exportCSV.js)
app.get('/export-user-data', async (req, res) => {
    try {
        const userId = req.user.id;
        const userData = await db.fetchUserData(userId); #A
 
        if (!userData) {
            return res.status(404).send('User not found.');
        }
 
        // Simple CSV conversion
        const headers = 'id,name,email\n';
        const csvRow = '${userData.id},${userData.name},
                        ${userData.email}\n';
        const csvData = headers + csvRow;
 
        res.setHeader('Content-Type', 'text/csv');
        res.setHeader('Content-Disposition', 
        'attachment; filename="user_data_${userId}.csv"');
        res.status(200).end(csvData);
 
    } catch (error) {
        console.error('Export failed:', error);
        res.status(500).send('An error occurred during export.');
    }
});

See a direct CSV-export implementation that illustrates the faster, less scalable option. section 2.5.1

How Grokking Software Architecture covers it

How deep it goes
Explains resource limits through a worked CSV-export tradeoff and distinguishes adjustable qualities from non-negotiable ones.
Examples
Uses a one-day CSV-export deadline and a small team, limited budget, and six-week deadline as concrete cases.
What you can do after
Apply constraints by stating project limits, comparing feasible options, and making deliberate quality tradeoffs.
How it connects
Connects constraints to quality attributes, the Tradeoff Triangle, Architecture Decision Records, and the CAP theorem.

Also explained in

Compare how 29 books explain constraint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.