Hierarchical/non-relational data structures in MongoDB2.
Keywords:
MongoDb, TypeScript, Functor, Monada, Cartesian Closed CategoriesAbstract
The proposal of this article is to explore the integration of fundamental concepts of functional programming into TypeScript - in particular functionary and monad - in the architecture of a persistent booking application NoSQL based on MongoDB. An architectural model is proposed in which domain operations (creation, modification, cancellation of reservations) are expressed through the composition of functors and monads, clearly separating pure logic from interactions with the infrastructure. Persistence in MongoDB is encapsulated in monadic layers that explicitly model errors, missing data, allowing declarative composition of data flows. The study presents a reservation application (e.g. for rooms, events or appointments) as a case study, highlighting how the types TypeScript and functional abstractions can increase the robustness, testability, and clarity of code, without sacrificing the pragmatism needed in a real system. The result is a design style in which business rules remain pure and verifiable.