Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adapt the document to the release and add JSON views doc #127

Merged
merged 19 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Lenra's documentation web site

## Development

To launch the server in dev mode, run the following commands:

```bash
Expand Down
4 changes: 2 additions & 2 deletions doc-deps.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
components:
- name: components-api
url: https://github.com/lenra-io/components-api
version: v1.0.0-beta.85
version: v1.0.0-beta.88
filePrefix: lenra-api-docs
containsVersion: true
- name: cli
url: https://github.com/lenra-io/lenra_cli
version: v1.0.0-beta.31
version: v1.1.0
filePrefix: lenra-cli-docs
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
{
"from": "^/todo-list-guide.html$",
"to": "/guides/todo-list-app.html",
"to": "/guides/apps/lenra-todo-list.html",
"type": "permanent"
},
{
Expand All @@ -108,6 +108,11 @@
"from": "^/references/cli/commands/dev/reload.html$",
"to": "/references/cli/commands/reload.html",
"type": "permanent"
},
{
"from": "^/guides/todo-list-app.html$",
"to": "/guides/apps/lenra-todo-list.html",
"type": "permanent"
}
]
}
Expand Down
9 changes: 8 additions & 1 deletion src/markdown/features/data-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ Lenra Data system is based on Mongo.

There is two ways to handle data in Lenra:
- in the listeners: you can use the [API](#api) to manage your data
- in the views: you can use the [View component](/references/components-api/components/view.html) to adapt your application interface
- in the views: you can use the [View component](../references/components-api/components/view.html) to adapt your application interface


## @me

The `@me` value is a special string that represents the current user.
It can be used for document manipulation and queries.

To use it, you need just need to set the `@me` value to a field of the document like is done in our templates (see [the create a tempalte from scratch guide](../guides/create-from-scratch.html) to better understand how to use it).
taorepoara marked this conversation as resolved.
Show resolved Hide resolved

## API

To manage the data in your application, you can utilize our REST API.
Expand Down
46 changes: 27 additions & 19 deletions src/markdown/getting-started/create-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Create a project
---

## New project
## New Lenra app

Once the [Lenra CLI is installed](./install.html), you can use it to create a new Lenra app.

Expand All @@ -12,10 +12,20 @@ Once the [Lenra CLI is installed](./install.html), you can use it to create a ne
Creating an app from a template is the easiest way to start.
The Lenra templates are just git repositories with a basic app that implements the Lenra app API.

You can find the list of available templates [{:rel="noopener" target="_blank"}here](https://github.com/search?q=topic%3Alenra+topic%3Atemplate&sort=stargazers&type=repositories).
You can find the list of [{:rel="noopener" target="_blank"}available templates on GitHub](https://github.com/search?q=topic%3Alenra+topic%3Atemplate&sort=stargazers&type=repositories).

{:#templates}
- ![JavaScript](/img/languages/javascript.svg)
- ![TypeScript](/img/languages/typescript.svg)
- ![Rust](/img/languages/rust.svg)
- ![Python](/img/languages/python.svg)
- {:.soon}
![PHP](/img/languages/php.svg)
- {:.soon}
![Elixir](/img/languages/elixir.svg)

To create a new Lenra project you can just run the [`lenra new` command](../references/cli/commands/new.html).
Pass a list of GitHub topics to find the list of corresponding templates.
Pass a list of GitHub topics to find the list of corresponding templates (for example the language you want to use).
If none is specified, the CLI will let you choose in the full list.
You also can specify the name of a target directory for the new app with the `--path` option.

Expand All @@ -30,19 +40,6 @@ Once the [Lenra CLI is installed](./install.html), you can use it to create a ne
lenra dev
```

#### Maintained by the **Lenra team**

We have created a few templates to help you start your next project.

{:#templates}
- [{:.btn rel="noopener" target="_blank"}![JavaScript](/img/languages/javascript.svg)](https://github.com/lenra-io/template-javascript)
- [{:.btn rel="noopener" target="_blank"}![TypeScript](/img/languages/typescript.svg)](https://github.com/lenra-io/template-typescript)
- [{:.btn rel="noopener" target="_blank"}![Rust](/img/languages/rust.svg)](https://github.com/lenra-io/template-rust)
- [{:.btn rel="noopener" target="_blank"}![Python](/img/languages/python.svg)](https://github.com/lenra-io/template-python)
- {:.soon}
[{:.btn rel="noopener" target="_blank"}![PHP](/img/languages/php.svg)](https://github.com/lenra-io/template-php)
- {:.soon}
[{:.btn rel="noopener" target="_blank"}![Elixir](/img/languages/elixir.svg)](https://github.com/lenra-io/template-elixir)

- ### from **scratch**

Expand All @@ -51,10 +48,21 @@ Once the [Lenra CLI is installed](./install.html), you can use it to create a ne
[{:.btn.link}Read the specific guide for that](../guides/create-from-scratch.html)


## Start **developing**
## Start developing

Now that you have a new Lenra app project, you can start developing it.
Be shure you've understand the [Lenra principles](../guides/principles.html) before starting.
Be shure you've understand the [Lenra principles](./principles.html) before starting since Lenra is a bit different of the classical frameworks.
taorepoara marked this conversation as resolved.
Show resolved Hide resolved

### Features

One of most important thing to know is that Lenra is how to [manage data](../features/data-management.html).
taorepoara marked this conversation as resolved.
Show resolved Hide resolved

Find all the features you need for your app in the [{:.btn.link.lenra-icon-arrow-right}features list](../features/)

### Guides

There is also [some guides](../guides/) that can explain you the next steps for creating your app.

<!-- TODO: add showcase app when it's ready -->

[{:.btn.link.lenra-icon-arrow-right}Look at our todo list app guide](../guides/todo-list-app.html)
You should look at our [{:.btn.link.lenra-icon-arrow-right}app guides](../guides/apps/)
35 changes: 30 additions & 5 deletions src/markdown/getting-started/deploy-app.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
---
name: Deploy your app
---

When your application is ready to be shared with others you might find interest into deploying it to the online platform.

## Prerequisites

If you don't have a Lenra app yet, you can [create one](./create-project.html).

Before deploying your app, you need to push to a git repository.
taorepoara marked this conversation as resolved.
Show resolved Hide resolved
This repo have to be accessible from the internet, so you can use GitHub, GitLab, BitBucket or any other git hosting service.
taorepoara marked this conversation as resolved.
Show resolved Hide resolved
You can use a private repository, but you will need to follow [our dedicated guide](../guides/use-private-repository.html).

Make sure your app is working in production mode locally (using [the Lenra CLI](./install.html)) before deploying it by running the next command in your app directory:
taorepoara marked this conversation as resolved.
Show resolved Hide resolved

```bash
# Build the app for production
lenra build --production
# Start the app previously built
lenra start
```

You can then test your app by opening [http://localhost:4000](http://localhost:4000) in your browser or starting your custom client.

## Deploy your app

Create an account on [{:rel="noopener" target="_blank"}dev.lenra.io](https://dev.lenra.io).
You will be asked for a token to join our developer platform as our platform is in private beta phase.
We will be sending you one as soon as possible.

After successfully completing this step you will be redirected to the creation of your first project, just enter a name and the URL of the app git repository.
For private repositories, follow [our dedicated guide](../guides/use-private-repository.html).

Then you simply click `Publish my application` at the top right corner, your application will be sent to Lenra's servers and deployed to be accessible directly for the Lenra Store.
Once your application is fully deployed on our servers, it will be accessible by clicking the `See my application` button.
You can share this application by changing its visibility to `public` in the settings and sending the link to people (which should look close to **app.lenra.io/app/f6279d6a-3b71-4520-a7f8-0f7b28700de9**).

Once your application is fully deployed on our servers, it will be accessible by clicking the `See my application` button.
This will open a new tab with the application running on the Lenra client (still in beta).

You can configure an external client to have advanced customisation on the UI of your app.
Look at [the corresponding guide](../guides/create-client.html) to configure your clients.

You also can configure the access to your application by reading [the corresponding guide](../guides/manage-access.html).
17 changes: 8 additions & 9 deletions src/markdown/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ docker compose --version

{:.or}
- ### using **cargo**
Simply install the latest package using the [{:rel="noopener" target="_blank"}cargo CLI](https://doc.rust-lang.org/cargo/getting-started/installation.html) and since we are still in beta, you'll have to define the version.
The next command will install the latest beta version:
Simply install the latest package using the [{:rel="noopener" target="_blank"}cargo CLI](https://doc.rust-lang.org/cargo/getting-started/installation.html):

```bash
cargo install lenra_cli@~1.0.0-beta.0
cargo install lenra_cli
```

For more installation instructions, you can directly check the CLI repository.
Expand All @@ -39,21 +38,21 @@ docker compose --version
- ### using **the binary**
<details id="download-linux" open><summary class="lenra-icon-linux">Lenra for Linux</summary>

- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-linux-x86_64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-linux-x86_64.tar.gz)
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-linux-x86_64](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-linux-x86_64)

- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-linux-aarch64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-linux-aarch64.tar.gz)
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-linux-aarch64](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-linux-aarch64)

</details>
<details id="download-windows"><summary class="lenra-icon-windows">Lenra for Windows</summary>

- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-windows-x86_64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-windows-x86_64.tar.gz)
<!-- - [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-windows-aarch64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-windows-aarch64.tar.gz) -->
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-windows-x86_64.exe](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-windows-x86_64.exe)
<!-- - [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-windows-aarch64.exe](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-windows-aarch64.exe) -->

</details>
<details id="download-macos"><summary class="lenra-icon-apple">Lenra for MacoS</summary>

- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-macos-x86_64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-macos-x86_64.tar.gz)
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-macos-aarch64.tar.gz](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-macos-aarch64.tar.gz)
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-macos-x86_64](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-macos-x86_64)
- [{:.btn.link.lenra-icon-download target="_blank" rel="noopener" target="_blank"}lenra-macos-aarch64](https://github.com/lenra-io/lenra_cli/releases/latest/download/lenra-macos-aarch64)

</details>

Expand Down
114 changes: 20 additions & 94 deletions src/markdown/getting-started/principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ description: Understand how our app development framework works.
position: 0
---

Lenra is an open source framework to create your app using any language, and deploy it without any Ops scale, built on ethical values.


## Framework

Our framework is based on four parts: data, views, listeners, and users.
Expand Down Expand Up @@ -42,58 +39,27 @@ For example, create a `ingredients` collection that will store all the ingredien
Then create a `recipes` collection to store your recipes…

You can also query into your documents using the [{:rel="noopener" target="_blank"}mongo query language](https://www.mongodb.com/docs/manual/tutorial/query-documents/).
For example, let’s say you want to get all the ingredients that are currently in your fridge.
Your query will look like that:

```json
{
"coll": "ingredients",
"query": {
"inFridge": true
}
}
```


{:.green.lenra-icon-grid}
### Views

The views are simple functions with 2 arguments: the **data** query result, a property object (**props**).
This function will return a json tree composed by native components or other views.
The views are simple functions with optional arguments:
- the **data** query result
- a property object (**props**)
- the **context** of the view

This function will return a JSON tree.
If one of the two argument changes, the view is rebuilt.

You can find all of the existing components by [checking our documentation](/references/components-api/).

For example, the counter view (in the template app) uses the `props` to customize the printed message and the `data` to get the counter value.
When the **+** button is pressed, the `increment` listener will be called.

{:data-file="views/counter.js"}
```javascript
export default async function(data, counter) {
return {
"type": "flex",
"spacing": 2,
"mainAxisAlignment": "spaceEvenly",
"crossAxisAlignment": "center",
"children": [
{
"type": "text",
"value": `${counter.text}: ${data[0].count}`
},
{
"type": "button",
"text": "+",
"onPressed": {
"action": "increment",
"props": {
"id": data[0]._id,
"datastore": data[0].datastore
}
}
}
]
}
}
```
There is two kind of views in Lenra apps:
- the JSON views that are used by external clients.
They let you define any kind of JSON structure as output.
The JSON views are preferred for front-end developers.
taorepoara marked this conversation as resolved.
Show resolved Hide resolved
- the Lenra views that are used by the Lenra client.
They output needs to be a [Lenra component](../references/components-api/).
taorepoara marked this conversation as resolved.
Show resolved Hide resolved
The Lenra views are preferred for back-end developers.
taorepoara marked this conversation as resolved.
Show resolved Hide resolved


{:.blue.lenra-icon-users}
### Users
Expand All @@ -106,54 +72,14 @@ This system make it simpler for you to handle user data and give the users the a

To link a data to the current user, just use the `@me` string as the user ID in your data and queries, and it will be replaced by the unique user ID of the current user for your app.


{:.yellow.lenra-icon-bell}
### Listeners

The listeners are event based workflows and are the only way to change the data.
A listener is a function that is able to call the data API to get/create/update/delete a document.
This function is called when an action is performed by the user on the UI (button pressed, click, checkbox checked…) or by external events (CRON, WebHooks...).

The listener takes 3 arguments: a property object (**props**), the **event** that triggered this listener and an **api** object that contains all the informations needed to call the API.

To update the model, simply call the HTTP data API in your listener. For example, the increment listener in the node template simply increments the counter given in the props. Here, the event is irrelevant (button click).

{:data-file="listeners/increment.js"}
```javascript
import { Counter } from "../classes/Counter.js";

/**
*
* @param {import("@lenra/app-server").props} props
* @param {import("@lenra/app-server").event} _event
* @param {import("@lenra/app-server").Api} api
* @returns
*/
export default async function(props, _event, api) {
let counter = await api.data.getDoc(Counter, props.id);
counter.count += 1;
await api.data.updateDoc(counter);
return {};
}
```

## The tech stack

In order to build that platform we had to create a custom application system based on open-source technologies.

{:style="width: 100%"}
![Lenra architecture](/img/architecture.svg)

If you want to know more about our tech stack, you can visit their website by clicking on the links below:

{:.list}
- [{:rel="noopener" target="_blank"}Flutter](https://flutter.dev/)
- [{:rel="noopener" target="_blank"}Phoenix](https://phoenixframework.org/)
- [{:rel="noopener" target="_blank"}PostgreSQL](https://www.postgresql.org/)
- [{:rel="noopener" target="_blank"}Mongodb](https://mongodb.com/)
- [{:rel="noopener" target="_blank"}OpenFaaS](https://www.openfaas.com/)
- [{:rel="noopener" target="_blank"}Kubernetes](https://kubernetes.io/)

A listener is a function that is able to call the data API to get/create/update/delete documents.
They are called when an action is performed by the user on the UI (button pressed, click, checkbox checked…) or by external events (CRON, WebHooks...).

If you've already used Flutter or Mongo, you will probably see a lot of the same principles while building your app with Lenra. You can use this knowledge !
A listener takes 3 arguments: a property object (**props**), the **event** that triggered this listener and an **api** object that contains all the informations needed to call the API.

Look at our [{:.lenra-icon-github rel="noopener" target="_blank"}GitHub](https://github.com/lenra-io) for more informations about our tech stack.
To update the model, simply call the [HTTP data API](../features/data-management.html) in your listener.
Loading
Loading