I read a short story online a few years ago, in late 2022, that I can't seem to find again. The closest I seem to get when I search various terms is "Autofac" by Philip K. Dick, but it definitely wasn't that.
It was about an orphaned(?) boy being taken in by the massive factory that his grandfather(?) had designed. The factory was operated under philanthropic ideals - orphans, the homeless, the jobless were all welcome to apply for work within it, and would be given food and shelter in return for completing simple jobs.
The factory is extremely modular, made out of standardized stamped metal sheets and grating. It is also self-sufficient - the factory had its own animal pens and slaughterhouses and was even built on top of a mine.
The boy is given a privileged spot in the top floor of the factory, and sneaks off to explore and investigate much of the facility. He realizes that the water supply is being doctored with some sort of mysterious compound - possibly lead - that makes the workers docile and incurious. The higher up in the factory you go, the less of the compound is added to the water, establishing a sort of "caste" system.
While exploring, the boy finds his grandfather's private office, long sealed shut except for access by the ventilation ducts. He throws a special lever that had been jammed, is discovered by the matron who runs the factory, and tells her he thinks its all rather wonderful.
The story ends with the reveal that the lever was meant to activate a self-replication function for the factory - it begins to expand and pave over the city it's located nearby. The boy is excited - soon everyone will live inside the wondrous, self-maintaining system.