Skip to content
Book

Atomic Query Construction

The Design Pattern for Eliminating Repeated Queries in Modern Applications

by Raheel Shan

Atomic Query Construction

Inside the book.

9 chapters

01

What AQC is

One query, one class, one handle() method, and the problem it removes

02

The rules of the pattern

Parameters in, results out, and the single source of truth

03

A full class, step by step

One product query that serves an admin panel, a storefront and a mobile API

04

Relational data

Joins, eager loading and nested results without leaking query code

05

Arrays or DTOs

Why AQC takes and returns arrays, and when a DTO earns its place

06

Where AQC sits in your architecture

Controllers, services and onion layers around the query class

07

Keeping classes small

How to split an AQC class before it grows too large

08

AQC next to Repository, CQRS and GraphQL

What each one solves and where AQC overlaps

09

CRUD and API endpoints with AQC

Create, update, delete and DataTables filtering with the same classes

Every Laravel app has the same query written in five places.

A where chain in the controller, a copy in the export, another in the API, a fourth in a report, and a fifth nobody remembers. Change a filter and you hunt for all five.

Atomic Query Construction (AQC) gives each query one home: one class, one handle() method, parameters in and results out. You write it once and call it everywhere.

Inside the pattern

  • The rules of the pattern, in the order you need them.
  • A complete example class that serves an admin panel, a storefront and a mobile API from one query.
  • How to handle relations, pagination, sorting and filters without a pile of if statements.
  • How to keep classes small as your app grows.
  • How AQC compares with Repository, CQRS and GraphQL, so you know where it fits.

Who it is for

Laravel and PHP developers with a codebase that has outlived its first year. You know controllers should be thin. You have tried a service layer, a repository or both, and the queries still sprawl.

About the author

I created AQC and wrote the book that explains it. I have spent more than 15 years building software, as a developer and as a CTO.

What you download

A PDF, available right after payment. The download link also arrives by email.

Before you buy

Do I need to know a framework other than Laravel? No. The examples use Laravel and Eloquent. The pattern is plain PHP classes.

Can I try the pattern before I buy? Yes. The blog explains the core idea for free, starting with Introducing the Atomic Query Construction (AQC) Design Pattern.

What you get.

Instant download

Your PDF is ready the second payment clears — no waiting.

Read anywhere

One PDF that works on your laptop, tablet, or e-reader.

Lifetime access

Pay once. The download link and email copy are yours to keep.

Free updates

If the book gets a revision, you get the new version at no cost.

Raheel Shan

Written by

Raheel Shan

Fullstack Developer

Questions.

What format is the book in?

A single PDF, formatted to read well on desktop, tablet, or e-reader.

How do I get it after paying?

You are redirected straight to a download page, and a copy of the link is emailed to you at the same time.

Is the code real?

Every example in the book is real, runnable code — nothing is pseudocode.

$17.00

One-time payment · instant delivery

Double-check your email — we'll send your copy of the book there the moment payment goes through.

Not as described? Full refund within 14 days.

Read a free sample first →
  • Instant PDF download
  • Lifetime access
  • Free future updates