![neutral](top-neutralts.png)

Neutral TS Web APP Example
==========================

Simple example of Neutral TS to create a Progressive Web Application (PWA) or Web APP, in Rust with Actix Web and for HTML design Bootswatch and Bootstrap. This example will show you how to create a template structure and how to do theming among other things.

It is not an example of Rust or Actix, it is not an example of design, it is an example of Neutral TS, so you can use this example as a prototype or as the basis of your own Web APP taking into account that what is really intended to illustrate is the use of templates.

Download from [repository](https://gitlab.com/neutralfw/neutralts/), the crate is here [neutralts](https://crates.io/crates/neutralts)

### Contents of the directories

```
 web-app
    ├── neutral -----------------> Neutral TS files and templates
    │   ├── css -----------------> Statics CSS files
    │   ├── data ----------------> Neutral TS json data and locale files
    │   ├── img -----------------> Statics image files
    │   ├── js ------------------> Statics js files
    │   ├── plugins -------------> Neutral TS utilities
    │   ├── pwa -----------------> Statics files for PWA
    │   ├── service-worker.js ---> Service Worker for PWA
    │   └── tpl -----------------> Neutral TS templates
    ├── php ---------------------> PHP source
    ├── python ------------------> Python source
    └── rust --------------------> Rust source
```

The files and templates have comments explaining the use.

Rust
----

Navigate to the web-app/rust directory and then:

```
cargo run --release
```

A server will be available on port 9090

```
http://127.0.0.1:9090/
```

PHP
----

Navigate to the web-app/php directory and then:

```
php -S localhost:8000
```

A server will be available on port 8000

```
http://127.0.0.1:8000/
```
(*) Requires an IPC server that you can download from the [repository](https://gitlab.com/neutralfw/neutralts)

Python
----

Navigate to the web-app/python directory and then:

```
export FLASK_APP=index.py && flask run
```

A server will be available on port 5000

```
http://127.0.0.1:5000/
```
(*) Requires an IPC server that you can download from the [repository](https://gitlab.com/neutralfw/neutralts)

IPC Server
----------

Navigate to the ipc directory and then:

```
cargo run --release
```

Performance
-----------

The example has all the elements of a production PWA, so it is a good approximation of real performance with a **4000MHz** CPU.

### Rust (actix-web)

```
wrk http://localhost:9090/
Running 10s test @ http://localhost:9090/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   536.77us   75.85us   1.92ms   76.15%
    Req/Sec     9.30k   246.26     9.79k    76.24%
  186876 requests in 10.10s, 5.60GB read
Requests/sec:  18503.80
Transfer/sec:    567.76MB
```

### PHP (apache mod_php)
```
wrk http://localhost.php/
Running 10s test @ http://localhost.php/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     0.96ms  139.40us   3.96ms   83.15%
    Req/Sec     5.21k   157.62     5.42k    81.68%
  104703 requests in 10.10s, 3.15GB read
Requests/sec:  10367.26
Transfer/sec:    318.98MB
```

### Python (apache mod_python)
```
wrk http://localhost.python/
Running 10s test @ http://localhost.python/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.09ms    1.04ms  52.85ms   99.72%
    Req/Sec     4.72k   179.71     4.94k    79.70%
  94966 requests in 10.10s, 2.85GB read
Requests/sec:   9402.61
Transfer/sec:    289.17MB
```
