/ocaml-dream-mvc

Primary LanguageReasonMIT LicenseMIT

OCaml MVC

This is a simple example of a blog application using the Model-View-Controller (MVC) design pattern in OCaml.

Getting Started

To run the application, you need to have OCaml installed on your machine. You can download OCaml from the official website.

After installing OCaml, you can run the following commands to build and run the application:

Note: Environment variables DATABASE_URI must be set to connect to a PostgreSQL database.

opam install . --deps-only --yes
dune build --profile=release
dune exec src/main.exe
open http://localhost:3000

Technologies

  • Server: Dream

    Dream is a web framework for OCaml that is designed to be easy to use, fast, and secure.

  • SQL: Caqti

  • Templating: Html_of_jsx

    Html_of_jsx is a library to convert JSX to HTML in OCaml. See views for examples.

File Structure

  • src/Main.ml: The entry point of the application.
  • src/controllers: Contains the controllers for the application.
  • src/models: Contains the models interacting with the database.
  • src/views: Contains the views for the application.
  • src/types: Contains the types for the application.

License

This project is licensed under the MIT License - see the LICENSE file for details.