A foundation for web applications written in OCaml. FYI mostly written by AI.
README.md

Foundation #

One dune monorepo, multiple opam packages. Build and test everything from the repo root with dune build / dune test.

Packages #

Package Keywords Summary
foundation meta-package, ecosystem Umbrella package: opam install foundation installs all the packages below.
foundation-vault sql, database, migrations, query-builder, sqlite SQL typed query builder, inspiration taken from Jet in GO. CLI: foundation-vault.
foundation-hyperspace http, protocol, shared types Shared HTTP primitives (Hyperspace): Method, Status, Headers, Cookie. Used by both foundation-terminus and foundation-mallow.
foundation-terminus web, http, framework, api, cohttp, eio Plug-style web framework core (Web) with cohttp/eio backend (foundation-terminus.cohttp).
foundation-mallow http, client, fetch, eio, cohttp Simple fetch-style HTTP client (Mallow) on cohttp-eio: Mallow.fetch uri ~http_method ~options.
foundation-plan validation, rules, result Typed validation pipelines (`validate
foundation-coordinates openapi, codegen, cli, http, api OpenAPI codegen CLI (foundation-coordinates): generates types, Yojson codecs, router and a HANDLERS module type for foundation-terminus.

Why #

There are some web frameworks and database option inside OCaml, but all of them did not meet my needs. They did not use EIO, were not typesafe (most DB packages), were not updated in forever, or did not use modern OCaml.

Most of the ideas of these packages here are taken from other well working libraries in other languages. The web framework borrows a lot of concepts from Plug in Elixir, the database library takes inspiration from Jet in Go. The validation library will take inspiration from both FluentValidation and Valibot. Those are well working libraries, however not in a type-safe, fast compiling language that generates a single executable.

AI generated #

Most of the code is AI generated. While I do think the code is already quite solid, this is to get a concept of proof going. When that process is done, I do plan on rewriting and rereviewing the entire codebase. So for me that means i can remove the AI slop label of the project, and call it written with the help of AI. Progress is shown below:

Project Status
vault > migration > lexer Started with human code, finished by AI
vault > migration > ast AI written
vault > query Design of the API is human written, but a black box for me as of now
hyperspace > web Started with human code, finished by AI
hyperspace > backend Written by AI