<commit_before># SAFE - A web stack designed for developer happiness

The following document describes the [SAFE-Stack](https://safe-stack.github.io/) sample project. 
SAFE is a technology stack that brings together several technologies into a single, coherent stack for typesafe, 
flexible end-to-end web-enabled applications that are written entirely in F#.

![SAFE-Stack](src/Client/images/safe_logo.png "SAFE-Stack")

You can see it running on Microsoft Azure at http://fable-suave.azurewebsites.net.

[![Build status](https://ci.appveyor.com/api/projects/status/ak9gjjjp32ens0e2?svg=true)](https://ci.appveyor.com/project/isaacabraham/safe-bookstore)
[![Build Status](https://travis-ci.org/SAFE-Stack/SAFE-BookStore.svg?branch=master)](https://travis-ci.org/SAFE-Stack/SAFE-BookStore)

## Requirements

- [Mono](http://www.mono-project.com/) on MacOS/Linux
- [.NET Framework 4.6.2](https://support.microsoft.com/en-us/help/3151800/the--net-framework-4-6-2-offline-installer-for-windows) on Windows
- [node.js](https://nodejs.org/) - JavaScript runtime
- [yarn](https://yarnpkg.com/) - Package manager for npm modules
- [dotnet SDK 2.0.0](https://www.microsoft.com/net/core) is required but it will be downloaded automatically by the build script if not installed (see below).

Other tools like [Paket](https://fsprojects.github.io/Paket/) or [FAKE](https://fake.build/) will also be installed by the build script.

For [deployment](#deployment) you need to have [docker](https://www.docker.com/) installed.

## Development mode

This development stack is designed to be used with minimal tooling. An instance of Visual Studio Code together with the excellent [Ionide](http://ionide.io/) plugin should be enough.

Start the development mode with:

    > build.cmd run // on windows
    $ ./build.sh run // on unix

This command will call the target "Run" in **build.fsx**. This will start in parallel:
- **dotnet fable webpack-dev-server** in [src/Client](src/Client) (note: the Webpack development server will serve files on http://localhost:8080)
- **dotnet watch msbuild /t:TestAndRun** in [test/serverTests](src/ServerTests) to run unit tests and then server (note: Suave is launched on port **8085**)

You can now edit files in `src/Server` or `src/Client` and recompile + browser refresh will be triggered automatically.

![Development mode](https://user-images.githubusercontent.com/57396/31067904-bec572e6-a755-11e7-967d-c169724006f2.gif)

Usually you can just keep this mode running and running. Just edit files, see the browser refreshing and commit + push with git.

## Getting started
### Create a new page
This topic will guide you through creating a new page. After every section you should check whether you can see the changes in your browser.
#### Minimal setup
Let's say we want to call our new page *Tomato*<commit_msg>cleanup readme<commit_after># SAFE - A web stack designed for developer happiness

The following document describes the [SAFE-Stack](https://safe-stack.github.io/) sample project. 
SAFE is a technology stack that brings together several technologies into a single, coherent stack for typesafe, 
flexible end-to-end web-enabled applications that are written entirely in F#.

![SAFE-Stack](src/Client/images/safe_logo.png "SAFE-Stack")

You can see it running on Microsoft Azure at http://fable-suave.azurewebsites.net.

[![Build status](https://ci.appveyor.com/api/projects/status/ak9gjjjp32ens0e2?svg=true)](https://ci.appveyor.com/project/isaacabraham/safe-bookstore)
[![Build Status](https://travis-ci.org/SAFE-Stack/SAFE-BookStore.svg?branch=master)](https://travis-ci.org/SAFE-Stack/SAFE-BookStore)

## Requirements

- [Mono](http://www.mono-project.com/) on MacOS/Linux
- [.NET Framework 4.6.2](https://support.microsoft.com/en-us/help/3151800/the--net-framework-4-6-2-offline-installer-for-windows) on Windows
- [node.js](https://nodejs.org/) - JavaScript runtime
- [yarn](https://yarnpkg.com/) - Package manager for npm modules
- [dotnet SDK 2.0.0](https://www.microsoft.com/net/core) is required but it will be downloaded automatically by the build script if not installed (see below).
- Other tools like [Paket](https://fsprojects.github.io/Paket/) or [FAKE](https://fake.build/) will also be installed by the build script.
- For [deployment](#deployment) you need to have [docker](https://www.docker.com/) installed.

## Development mode

This development stack is designed to be used with minimal tooling. An instance of Visual Studio Code together with the excellent [Ionide](http://ionide.io/) plugin should be enough.

Start the development mode with:

    > build.cmd run // on windows
    $ ./build.sh run // on unix

This command will call the target "Run" in **build.fsx**. This will start in parallel:
- **dotnet fable webpack-dev-server** in [src/Client](src/Client) (note: the Webpack development server will serve files on http://localhost:8080)
- **dotnet watch msbuild /t:TestAndRun** in [test/serverTests](src/ServerTests) to run unit tests and then server (note: Suave is launched on port **8085**)

You can now edit files in `src/Server` or `src/Client` and recompile + browser refresh will be triggered automatically.

![Development mode](https://user-images.githubusercontent.com/57396/31067904-bec572e6-a755-11e7-967d-c169724006f2.gif)

Usually you can just keep this mode running and running. Just edit files, see the browser refreshing and commit + push with git.

## Getting started
### Create a new page
This topic will guide you through creating a new page. After every section you should check whether you can see the changes in your browser.
#### Minimal setup
Let's say we want to call our new page *Tomato*
{'fraction_non_alphanumeric': 0.12062598909794267, 'fraction_numerical': 0.022859152452962897, 'mean_word_length': 4.479768786127168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 26, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3967686', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1680, 'n_words': 588}