Ocsigen Start is a ready-to-use application skeleton for building client-server web and mobile applications with Eliom and Ocsigen Toolkit. It ships with user management, notifications, a database schema and many code examples, so you can focus on your own features from day one.
Use it to learn Ocsigen or to quickly create your own Minimum Viable Product. The application is cross-platform: it works as a Web app or as a mobile app for iOS or Android (via Cordova).
Ocsigen Start is part of the Ocsigen project.
If you want to test the demo application before installing Ocsigen Start, a live version is running here.
You can also download the mobile app on Google Play store (for Android) or download the APK for Android or the iOS version (to be installed using XCode).
Ocsigen Start is composed of two main parts:
Read this page to learn how to build your first Ocsigen Start app in 5 minutes.
The library portion of Ocsigen Start contains core functionality that is common across Ocsigen Start applications, while the template can be customized for the specific application at hand.
The template additionally contains a demonstration of relevant Ocsigen Toolkit widgets. The demo portion can easily be removed.
For implementing users, a database is needed. Specifically, we use PostgreSQL via the PGOCaml library. The template and the library make common assumptions about the database schema. The tables of Ocsigen Start are defined in the file ocsigen_start.sql of the template, and the tables of the application in PROJECT_NAME.sql. make db-update applies both: it creates the tables on a new database, and brings them up to date on an existing one. ocsigen_start.sql can be applied again and again, and PROJECT_NAME.sql must stay so (see its header). After an upgrade of Ocsigen Start, back up the database, replace ocsigen_start.sql with the one of the new template ($(opam var lib)/eliom/templates/os/ocsigen_start.sql), and run make db-update again.
The same database can be used for the specific needs of the application at hand. For that, add new tables to PROJECT_NAME.sql, keeping it replayable. The tables of Ocsigen Start should remain in place for it to work correctly.
The template is available in multiple languages (English and French) using ocsigen-i18n. The translations used in the template are defined in the files assets/PROJECT_NAME_i18n.tsv and, for the demo, assets/PROJECT_NAME_Demo_i18n.tsv. Dune rules in lib/dune generate the Eliom modules PROJECT_NAME_i18n and PROJECT_NAME_Demo_i18n, and generate them again whenever a TSV file changes.
To add a language, add it to --languages in both rules, and add a column for it to each TSV file. --default-language sets the default language.
The template application keeps track of users' e-mails and implements e-mail validation. For that, sendmail (or another mail transfer agent compatible with it) needs to be installed on the host.
The application provides a standard style matching contemporary aesthetics. For this, we use SASS. The style can be customized by modifying the SASS files that are part of the template.
Ocsigen Start can be installed via OPAM. The package name is ocsigen-start. The template application can be instantiated via eliom-distillery:
eliom-distillery -name $APP_NAME -template os(Replace $APP_NAME by the name of your application).
Then install the opam packages that the generated project depends on, from its directory:
opam install --deps-only .For details on creating the database and launching the application, refer to the template's README.
Since version 9, the modules of Ocsigen Start are submodules of Os: write Os.Session, Os.User or Os.Email instead of Os_session, Os_user or Os_email. Ocsigen Start 9 also requires Eliom 13, Ocsigen Server 8 and Ocsigen Toolkit 5, which rename their modules the same way (Eliom.Content.Html instead of Eliom_content.Html, Ocsigen.Server instead of Ocsigen_server, Ot.Popup instead of Ot_popup).
To migrate progressively, install the ocsigen-start-compat package and add the libraries ocsigen-start-compat.server and ocsigen-start-compat.client to the server and client parts of your application, respectively. They define the old Os_xxx modules, each of which includes the new module, so that existing code keeps compiling while you rename the references. Other packages do the same for the rest of the stack: eliom-compat (libraries eliom-compat.server and eliom-compat.client), ocsigenserver-compat (library ocsigenserver-compat) and ocsigen-toolkit-compat (libraries ocsigen-toolkit-compat.server and ocsigen-toolkit-compat.client).
The tables of Ocsigen Start are now in ocsigen_start.sql, separate from those of the application (see the Database section above). To move an existing project to this layout:
ocsigen_start.sql from the new template;db-update, which replaces db-schema, and the variable OS_PSQL_FILE from the Makefile.db and Makefile.options of the new template;PROJECT_NAME.sql, and make the rest replayable, as the header of the new PROJECT_NAME.sql explains;make db-update.The dune rules of the template are now generated by ocsigen-dune-rules (instead of tools/gen_dune.ml), with the code of the application in lib/ and its entry point in app/. Generating a new project with eliom-distillery and comparing it with yours is the simplest way to see what changed.
We provide a tour of the Ocsigen Start library. Most modules have server- and client-side versions. (In the API documentation, there are links near the top of each module page for selecting the side.)
The template uses all these modules, and can thus act as a good starting guide. Look around!
Various modules for producing icons, messages, custom pages, tips, connection forms, etc.
Os.Icons: manage CSS icons.Os.Msg: display messages to the user, such as error messages.Os.Page: utilities for building HTML pages that follow the standard Ocsigen Start layout.Os.Tips: display tips to the user.Os.User_view: functions for creating password forms and other common UI elements appearing in applications and for managing the user connection box.Os.Uploader: ImageMagick-based tools for manipulating avatars.Os.User, Os.Current_user, Os.Group: manage users and groups thereof.Os.Connect_phone: register and connect users with their phone number, through codes sent by SMS.Os.Db: directly access the database. In many cases, it is a better idea to use higher-level modules (e.g., Os.User).Os.Notif: send notifications to connected users.Os.Email: send e-mails.Os.Fcm_notif: send push notifications to mobile devices.Os.Comet: manage the bi-directional communication channel between client and server. This is a low-level module that you probably don't need.Os.Services: Eliom services pre-defined by Ocsigen Start. These produce the default user interface of the template. See the Eliom manual page on services for a general introduction to Eliom services.Os.Handlers: The handlers (functions) that implement the services in Os.Services. The Eliom manual page on service handlers explains how to implement handlers.Os.Session: manage user sessions, e.g., execute actions when users connect or disconnect.Os.Date: utilities for manipulating date and time values.Os.Platform: obtain information about the platform we are on (Android, iOS, ...).Os.Request_cache, Os.User_proxy: different forms of caching data.The template also uses ocsigen-ppx-rpc, a ppx syntax extension to call server-side functions from the client (let%rpc).