What do a bag of fruit, the number 5, and a line of code have in common?
Nothing, if you look at what they're made of. A fruit is a fruit, a number is a quantity, a line of code is an instruction. But zoom out far enough and something strange happens: they all live inside worlds that behave exactly the same way.
Each world has "things" in it. Each world has "arrows" connecting some of those things to others. And in every single one of these worlds, you can chain two arrows into a third, and there's always an arrow that does nothing at all.
That's it. That's the whole pattern. Category theory is the study of that pattern, not any one version of it. It's math about math, grammar instead of vocabulary.
Same grammar, different vocabulary
Think about grammar for a second. English, French, and Japanese are wildly different languages. Different words, different sounds, different alphabets. But they all have nouns, they all have verbs, and a verb always connects a subject to something else.
Category theory found the same thing hiding inside math. It calls the "nouns" objects and the "verbs" arrows (mathematicians also say morphisms). A category is just: a bunch of objects, some arrows between them, and two rules about how those arrows behave.
Try it below. Same diagram, three different mathematical languages.
Same three dots, same two arrows, three completely different mathematical worlds. Switch worlds and watch only the labels change.
Notice what didn't change: there are still three objects, still two arrows, and the arrows still chain together. Only the meaning of the dots and lines changed. That's the entire insight of category theory in one picture.
Chaining arrows: composition
But how do the arrows actually combine? Take an arrow from to , and an arrow from to . Follow , land at , then follow . You end up at , and you can also describe that whole trip as a single arrow straight from to .
We write this new arrow as , read " after ." This gluing-arrows-together operation is called composition, and it's the main event in category theory. Everything else is commentary.
Now here's a question worth sitting with: if you have three arrows in a row, does it matter which pair you glue first?
Slide through the steps to watch f, then g, then h chain into a single arrow. Toggle the grouping, the resulting arrow never moves.
Slide through the steps and you'll see , then , then the full chain . Now flip the grouping toggle. The arrow doesn't move. Whether you glue and first, or and first, you land on the exact same arrow from to . We write this as:
This property is called associativity, and it's one of the two rules every category must obey. Grouping is bookkeeping. The destination never cares how you got there.
The arrow that does nothing
Every object also needs a special arrow, one that loops back to itself and changes nothing when you compose with it. We call it the identity arrow, written for the identity on object .
Sounds pointless, right? An arrow that does nothing. But watch what happens when you send a traveler through it.
Pick a route for the traveling dot. Looping through an identity arrow adds distance traveled, never changes where you end up.
Pick "" or "" and hit play. The dot takes a longer road, looping through the identity arrow first. But it always lands exactly where alone would've taken it. More steps, same destination. That's the second rule every category must satisfy:
Identity arrows are the "do nothing" element, the same role plays in addition or plays in multiplication. You can always detour through one, and it never changes your answer.
Translating between categories
Once you have categories, a natural question shows up: can you map one category into another, in a way that respects all this structure? Not just object to object, but arrow to arrow, and composition to composition?
Yes, and that map has a name: a functor. Think of it as a translator between two languages that preserves the grammar. If is a functor from category to category , it sends every object in to some object in , and every arrow to some arrow , without breaking anything.
A functor F translates category C into category D. Slide through the reveal, or hover a node to see its image light up on the other side.
Slide through the reveal and watch the translation build up, piece by piece. Hover any object on either side and its partner lights up. By the last step, you can check the one rule that makes this a real functor and not just a random relabeling:
The translated composite equals the composite of the translations. Compose first then translate, or translate first then compose, same result either way. That's what "structure-preserving" actually means.
Math about math
Here's the part that gives category theory its name. Categories themselves, the sets-and-functions one, the numbers-and-≤ one, the types-and-code one, can all be treated as objects. And functors between categories act as arrows between those objects.
Which means: the collection of all categories is itself a category. Mathematicians call it . You can compose functors the same way you compose ordinary arrows, and there's an identity functor that does nothing, same two rules, same pattern, one level up.
This is why people call category theory "math about math." It's not a theory of numbers, or shapes, or equations. It's a theory of the pattern that shows up whenever mathematicians build a world of things and the maps between them. Once you see it in one place, you start seeing it everywhere, groups, topological spaces, databases, even parts of programming languages.
The short version
A category is just objects, arrows between them, a way to chain arrows called composition, and a do-nothing arrow for every object. Composition doesn't care how you group it. Identity arrows are detours that change nothing. A functor is a translator between two categories that respects all of it. And because categories and functors form their own category, category theory ends up studying itself, which is exactly why it earns the name math about math.
The next time you notice the same pattern showing up in sets, numbers, and code, that's not a coincidence. That's category theory, quietly running underneath.
All visualizations are interactive React components running entirely in your browser, built with plain SVG. The composition and functor demos use exact coordinate geometry, no external charting libraries.