Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

MoodleNet: Difference between revisions

From MoodleDocs
(Started V3 quickstart and config)
No edit summary
Line 9: Line 9:
* The MoodleNet release schedule is available on the [https://tracker.moodle.org/projects/MDLNET?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page&status=unreleased MoodleNet Roadmap].
* The MoodleNet release schedule is available on the [https://tracker.moodle.org/projects/MDLNET?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page&status=unreleased MoodleNet Roadmap].
== Quick start guide ==
== Quick start guide ==
 
====System Requirements====
==== System Requirements ====
MoodleNet requires the followings to be available on your system
MoodleNet requires the followings to be available on your system
* NodeJs ^16 [https://nodejs.org]  
*NodeJs ^16 [https://nodejs.org]
* npm ^8 [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/]
*npm ^8 [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/]
* ArangoDB [https://www.arangodb.com/]
*ArangoDB [https://www.arangodb.com/]
Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9
Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9


Line 20: Line 19:


Make sure to have nodejs ^16 installed and you should get npm ^8 as well
Make sure to have nodejs ^16 installed and you should get npm ^8 as well
====Deploy an ArangoDB instance====
MoodleNet uses [https://www.arangodb.com/ ArangoDB] as main database


==== Deploy an ArangoDB instance ====
You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process
You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process


An easy way to install ArangDB locally as a service is by using Docker[https://hub.docker.com/_/arangodb] e.g. :
An easy way to install run ArangDB locally as a service is by using Docker[https://hub.docker.com/_/arangodb] e.g. :
  docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10
  docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10
Possibly tweaking some options as you like, e.g. mounting a volume or a directory for data or setting a password
Possibly tweaking some options as you like, e.g. mounting a volume|directory for data or setting a password
 
====Install MoodleNet====
==== Install MoodleNet ====
Install Moodlenet by simply issueing the following npm command
to install Moodlenet you simply need to issue the following npm command
  npm create @moodlenet@latest path/to/installation/folder
  npm create @moodlenet@latest path/to/installation/folder
this will install all MoodleNet core packages in the choosen folder
That will install all MoodleNet core packages in the choosen folder
 
it will also create a default configuration file ('''default.config.json''') and a default cryptographic key pair for the system ('''default.crypto.privateKey , default.crypto.publicKey''')


==== Start MoodleNet process ====
it will also create a default configuration file ('''default.config.json''') and a default cryptographic key-pair for the system ('''default.crypto.privateKey , default.crypto.publicKey''')
====Start MoodleNet process ====
To start MoodleNet issue the following command from within the installation directory
To start MoodleNet issue the following command from within the installation directory
  npm start
  npm start
open your browser on http://localhost:8080  
open your browser on http://localhost:8080


'''notice:''' on the first run the system will have to compile the webapp, so you'll get a 404 until ready. It should take a few minutes
'''Notice:''' on the first run the system will have to compile the webapp, so you'll get a 404 until ready. It should take a few minutes
====MoodleNet configuration file====
MoodleNet configuration file ('''default.config.json''') holds all static system configs.


==== MoodleNet configuration file ====
Here's how the default config looks like after install:
MoodleNet configuration file ('''default.config.json''') holds all static system configs.
  {
  {
   "pkgs": {
   "pkgs": {
     "@moodlenet/core": {
     "@moodlenet/core": {
       "baseFsFolder": "/home/alec/MOODLENET/repo/moodlenet3/.dev-machines/1/fs",
       "baseFsFolder": "/path/to/installation/dir/fs",
       "instanceDomain": "<nowiki>http://localhost:8080</nowiki>",
       "instanceDomain": "<nowiki>http://localhost:8080</nowiki>",
       "npmRegistry": "<nowiki>https://registry.npmjs.org</nowiki>",
       "npmRegistry": "<nowiki>https://registry.npmjs.org</nowiki>",
       "mainLogger": {
       "mainLogger": {
         "consoleLevel": "debug",
         "consoleLevel": "info",
         "file": {
         "file": {
           "path": "./log/moodlenet.%DATE%.log",
           "path": "./log/moodlenet.%DATE%.log",
           "level": "debug"
           "level": "info"
         }
         }
       }
       }
Line 62: Line 61:
         "alg": "RS256",
         "alg": "RS256",
         "type": "PKCS8",
         "type": "PKCS8",
         "private": "/home/alec/MOODLENET/repo/moodlenet3/.dev-machines/default.crypto.privateKey",
         "private": "/path/to/installation/dir/default.crypto.privateKey",
         "public": "/home/alec/MOODLENET/repo/moodlenet3/.dev-machines/default.crypto.publicKey"
         "public": "/path/to/installation/dir/default.crypto.publicKey"
       }
       }
     },
     },
Line 87: Line 86:
     },
     },
     "@moodlenet/system-entities": {
     "@moodlenet/system-entities": {
       "rootPassword": "root"
       "rootPassword": "eqhb30x9iq5"
     },
     },
     "@moodlenet/react-app": {
     "@moodlenet/react-app": {}
      "noWebappServer": true
    }
   }
   }
}
here's some relevant configs you may want to check and tweak
here's some relevant configs you may want to check and tweak
*'''@moodlenet/arangodb.connectionCfg.url''' : the default config assumes you installed ArangoDB without password with standard port on the same host
*'''@moodlenet/core.baseFsFolder''' : path (better absolute path instead of relative to MoodleNet process cwd) to the system root folder for system filesystem persistency, if you want to change the system-filesystem-root after the system already run, move or clone the existing folder somewhere else and set this config properly to point to the new path
*'''@moodlenet/core.instanceDomain''' : the public domain of your moodlenet instance (e.g. <nowiki>https://moodlenet.example.com</nowiki>) - the default one (<nowiki>http://localhost:8080</nowiki>) is ok for testing and dev
*'''@moodlenet/email-service.nodemailerTransport''' : the [https://nodemailer.com/ nodemailer] [https://nodemailer.com/smtp/ transport configuration] for the system email service. It can be a simple smtp url string, or a [https://nodemailer.com/smtp/ nodemailer standard config object]. '''Notice''': with the default configuration '''{ "jsonTransport": true }''' the system won't send any email, it will simply log them)
*'''@moodlenet/system-entities.rootPassword''' : a static root password for edge cases - you'll use it to give the first admin permission to a user (see below) - this property is optional, if not set the root user is disabled
*'''@moodlenet/http-server.port''' : the HTTP server port to listen
Moodlenet's HTTP service doesn't support HTTPS.
It's always a good practice to back Moodlenet with a HTTP reverse proxy (e.g. nginx, Apache) and it is a must if you want to publish over HTTPS, configuring TLS on it
====Default authentication system====
Moodlenet comes with a simple email+password authentication system (pkg @moodlenet/simple-email-auth) that lets users signup and login with a verified email
Users can sign up with their email, receive in their inbox a confirmation link to click and create their user-account
====Assign admin privileges to user====
As you deploy a new instance, no user is present in the system.
Signup with your email and create your user.
Test login, then logout and browse to the hidden page '''<nowiki>http://localhost:8080/login/root</nowiki>''', here you can type in the '''rootPassword''' (specified in config file) to login as root.
Open the avatar menu on top right header, and click '''admin''' link
Click on '''Users''' section on the left, and see your user listed there. Activate the '''admin''' icon to give your user admin privileges
Now you can log out and login back with your email, see you gained the '''admin''' link in your avatar menu
== Migrate from V2 ==
If you have a v2 running and want to migrate it to v3 , you can use the [https://www.npmjs.com/package/@moodlenet/v2-migrate-v3 @moodlenet/v2-migrate-v3]
The v3 system must have access to Moodlenet-V2 persistencies: its running arangoDB instance and the MN2 filesystem as configured in [https://gitlab.com/moodlenet/moodlenet/-/tree/1c8c7eb9b9aa2a3ee912871c670480b3e5fa0f70/packages/ce-platform#set-environment-variables V2 env variable '''STATICASSETS_FS_ROOT_FOLDER'''] 


* '''@moodlenet/arangodb.connectionCfg.url''' : the default config assumes you installed ArangoDB without password with standard port on the same host
After installed Moodlenet, issue the following command from the installation folder
* '''@moodlenet/core.baseFsFolder''' : path to the system root folder for system filesystem persistency (better use absolute paths instead of relative to MoodleNet process cwd)
npm install @moodlenet/v2-migrate-v3
* '''@moodlenet/core.instanceDomain''' : the public domain for your moodlenet instance (e.g <nowiki>https://myorg.moodle.net</nowiki> )
Edit the '''default.config.json''' adding a '''@moodlenet/v2-migrate-v3''' section beside the others, it should look like that
* '''@moodlenet/email-service.nodemailerTransport''' : the [https://nodemailer.com/ nodemailer] [https://nodemailer.com/smtp/ transport configuration] for the system email service (notice, with the default configuration the system won't send any email, it will simply log them)
    "@moodlenet/v2-migrate-v3": {
      "v2DbConnectionCfg": {
        "url": "<nowiki>http://your-mn-v2-arangodb-host:8529</nowiki>"
      },
      "v2AssetFolder": "/path/to/v2/asset/folder"
    }
re/start the system, all the services will start after the migration done


== MoodleNet architecture ==
==MoodleNet architecture==
MoodleNet is a full stack TypeScript/JavaScript system using:
MoodleNet is a full stack TypeScript/JavaScript system using:
* NodeJs
*NodeJs
** NPM Packages [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/]
** NPM Packages [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/]
** ESM Modules [https://nodejs.org/api/esm.html#introduction]
**ESM Modules [https://nodejs.org/api/esm.html#introduction]
* Browsers
*Browsers
** ReactJs 18 [https://reactjs.org/]
**ReactJs 18 [https://reactjs.org/]
** HTML5 [https://html.spec.whatwg.org/multipage/]
**HTML5 [https://html.spec.whatwg.org/multipage/]
** CSS3 [https://www.w3.org/Style/CSS/]
**CSS3 [https://www.w3.org/Style/CSS/]
== MoodleNet development environment ==
==MoodleNet development environment==
* NodeJs v16+ https://nodejs.org/
*NodeJs ^16 https://nodejs.org/
* ArangoDB (we suggest using [https://www.docker.com/ Docker])
* ArangoDB ^3 (we suggest using [https://www.docker.com/ Docker])
* We recommend the open source IDE Visual Studio Code https://code.visualstudio.com/
*We recommend the open source IDE Visual Studio Code https://code.visualstudio.com/
=== Setup development environment ===
=== Setup development environment===
'''From the command line interface (CLI):'''
'''From the command line interface (CLI):'''


Ensure ArangoDB is running on localhost. You may use Docker with a command as below that can be tweaked as needed to ensure it is listening locally on port 8529:
Ensure ArangoDB is running on localhost. You may run it in a Docker container issueing a command as below:
  docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 --rm --name=mn3arango arangodb
  docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn3-dev arangodb:3.10
Clone the repository, you may wish to fork it, but that's not required:
Clone the repository, you may wish to fork it, but that's not required:
  git clone <nowiki>https://gitlab.com/moodlenet/moodlenet.git</nowiki>
  git clone <nowiki>https://gitlab.com/moodlenet/moodlenet.git</nowiki>
Line 125: Line 157:
Install and initialize the project:
Install and initialize the project:
  npm install
  npm install
Install a development deployment:
Install a development server:
  npm run dev-install-backend [install dir name]
  npm run dev-install-backend my-dev # <- my-dev: an arbitrary dev-installation name
We have used "my-dev" as [install dir name] in the following instructions.
In the example we choosed '''my-dev''' as installation name, the tool will then setup a dev installation in '''./.dev-machines/my-dev'''


You’ll find the newly created dev-installation in .dev-machines/my-dev and can create as many dev installations as you wish.
You can create as many dev installations as you wish.


Run development backend:
Run development backend:
  npm run dev-start-backend my-dev
  npm run dev-start-backend my-dev # <- my-dev : the name you choosed when installed
The first run of the system takes some time to install.
The first run of the system may take some time to install.
 
Once installed, browse http://localhost:8080
 
Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help.
=== The moodlenet extension package template ===
You can use core MoodleNet development environment and processes to develop your packages.
 
We recommend to start understanding the extension framework tweaking the template package “my-moodlenet-mjs-pkg-template” you’ll find it in the folder “packages”.
 
It is written in Javascript (EMS) instead of Typescript for a better understanding by newcomers.
 
Using typescript for package development is strongly recommended, as ts-experienced-devs will take advantage of the strongly-typed framework. However this requires good typescript knowledge, and some measures and ceremonies as all MoodleNet official packages are written in Typescript.
=== Install my-moodlenet-mjs-pkg-template ===
Signup using the web-app .


Note: Do not use sensible passwords as the system saves the email-password credentials unencrypted in the database.
The default configuration for dev includes the config '''@moodlenet/react-app.noWebappServer: true''' that prevents the server to serve the webapp, so you won't access the webapp on <nowiki>http://localhost:8080</nowiki>


Since no SMTP has been configured, the signup confirmation email supposed to be sent will be logged in the terminal:
Instead, you'll want to run a webpack+HMR serving the webapp issueing
  hey {display name} confirm your email with /.pkg/@moodlenet/simple-email-auth/confirm-email/{LONG_HASH}
  npm run dev-start-webapp my-dev # <- my-dev: the installaton server to point to
Copy the url path (/.pkg/@moodlenet/simple-email-auth/confirm-email/{LONG_HASH}) apply the localhost and paste it to the browser to confirm your email
Once all started, browse http://localhost:3000
localhost:8080/.pkg/@moodlenet/simple-email-auth/confirm-email/{LONG_HASH}
===Mono-Repository management with Lerna.js===
You’ll be logged in automatically and will be able to use the chosen credentials to login other times
When logged-in, navigate to the settings page in advanced section, where you can enable "dev mode”.
 
Then proceed to extensions / install extension section and submit the package absolute path to your package local folder.
 
The system will install the package and restart.
 
It will take some time to rebuild the web-app to see the results
 
Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help.
== Creating custom MoodleNet packages ==
A Moodlenet package is a standard [https://nodejs.org/api/esm.html#introduction ESM] package defining a main [https://nodejs.org/api/esm.html#introduction ESM] module.
@moodlenet/core will import it at startup.<syntaxhighlight lang="javascript" line="1" start="1">
// package.json
{
"name”: "my-moodlenet-package”,
"version”: "1",
 "type": "module",
"exports": {
  ".": "./src/server/main.mjs"
}
}
</syntaxhighlight>
===== Declare dependency =====
Your MN package must declare its dependency to the @moodlenet/core and other relevant packages package.json.
The core will import the main module at startup. The package "connects” to the core:<syntaxhighlight lang="javascript" line="1" start="1">
// package.json
{
  "peerDependencies”: {
    "@moodlenet/core”: "^0.2.0”
}
}
</syntaxhighlight>
=== Mono-Repository management with Lerna.js ===
MoodleNet project takes leverages [https://lerna.js.org/ lerna.js] to manage multi-package mono-repository .
MoodleNet project takes leverages [https://lerna.js.org/ lerna.js] to manage multi-package mono-repository .


Please refer to [https://lerna.js.org/ Lerna documentation] to understand how it manages mono-repo and project-packages dependency linking in the development environment.
Please refer to [https://lerna.js.org/ Lerna documentation] to understand how it manages mono-repo and project-packages dependency linking in the development environment.
When you need to add or remove a dependency for your package to some MoodleNet core package you can issue
lerna add -P <needed pkg> <packages/your-pkg-dir>
e.g. lerna add -P @moodlenet/react-app packages/my-moodlenet-mjs-pkg-template
You may also add/remove peerDependencies manually in package.json, in this case remember to execute:
npm run bs
From the root folder to update links to dependent packages.
=== Extend the web application ===
Use @moodlenet/react-app "plugin” api, during initialization to extend the web-app with a custom set of components.<syntaxhighlight lang="javascript" line="1" start="1">
import { pkgConnection } from '@moodlenet/core'
import reactApp from '@moodlenet/react-app'
const reactAppPkg = await pkgConnection(import.meta, reactApp)
await reactAppPkg.api('plugin')({
 mainComponentLoc:
    [‘path’, 'to', 'MainComponent.jsx']
})
</syntaxhighlight>
=== Define and deploy APIs ===
Your package will probably need to define and deploy its own APIs.
APIs are simply a collection of async functions - along with a params formal validation function - organized in a structured Js object.
APIs will be registered in the system with a path-like string, having your package name as prefix and apth following api structure.
// src/server/main.mjs
import { connectPkg, defApi } from '@moodlenet/core'
const myApis = {
   hello:{
      world: defApi( ctx =>
         async (p1,p2) => { return // something } ,
        (...params) => { /* … validate params */ }
   )
}
const connection = await connectPkg(import.meta, {
   apis: myApis
})
// will register 1 api:
// my-moodlenet-package/1.0/hello/world
=== APIs access ===
Apis can be accessed by any package running in NodeJs processes using specific @moodlenet/core functions pointing to the path of the desired API.
// from within the backend:
// locate an package api by path
import myMNPkgConn from
   ‘my-moodlenet-package’
const myMNPkg = await pkgConnection(import.meta, myMNPkgConn)
const helloWorldApi =
  myMNPkg.api(‘hello/world’)
// call api as an async function
const result = await
  helloWorldApi(helloParam, worldParam)
=== APIs Primary Adapters ===
Primary adapters implement API accessibility from external processes using some transport and protocols. Currently MoodleNet provides one Api-primary-adapter to access APIs by HTTP, which is implemented by @moodlenet/http-server. @moodlenet/http-server API HTTP adapter exposes package APIs as HTTP-POST endpoints. That endpoint is a path comprising the package name and the defined API path base, after the base API endpoint ( currently .pkgs ), having a JSON object body representing the api arguments. For example,
.pkgs/my-moodlenet-package/1.0/hello/world
<blockquote>
body:
</blockquote>
{
<blockquote>
 "args” : [
</blockquote>
   "hello-param1”,
<blockquote>
   "world-param2”
</blockquote>
 ]
<blockquote>
}
</blockquote>
Furthermore, in the web-app, @moodlenet/react-app provides libraries to use a syntax similar to within-backend-access for easy and strongly typed API calls to the server.
=== APIs Access Control ===
Packages register apis to @moodlenet/core which mediates api-call requests and responses, performing all fundamental checks and access controls.
* checks requested pkg version against deployed pkg version for granting compatibility
* calls api’s params formal validation function before forwarding to actual api function
* (TBD) checks matching of scopes associated with api and caller (user or package)
* provides the api a call-context holding an extensible set of metadata (e.g. user session, caller pkg … )
* (TBD) any package can register for adding context metadata to an api call
=== APIs Authorization Scopes (TBD) ===
The core will export functions to define package-specific auth-scopes - similar to OAuth specs.
defApi() will provide options to apply own or other-pkg’s auth-scopes to api.
All Api accesses will be authorized at core level checking scopes assigned to api against scopes assigned to caller. Note that the caller may be a user using some primary adapter e.g. HTTP or can be simply another package, on its behalf, from within the system.
Packages will have to declare which scopes they will need to be granted in order to perform their functionalities.
Package scope-dependencies should be granted by the admin at installation time in order to complete the installation - similar to what happens on smartphones.
== Testing MoodleNet packages ==
Once we’re happy with package development on dev-environment, we can try to install it on a real MoodleNet installation, using the admin UI.
Installation of MoodleNet in a production-like environment is a one liner cmd:
npx install \ @moodlenet/create \ dest/folder
Ensure ArangoDB is running and once inside the "dest/folder" installation directory:
npx @moodlenet/core
Create a user and navigate to the settings page where you can enable "dev mode”. Then proceed to extensions/install section and submit the package absolute path to local folder.


Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help.
Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help.
== Important links ==
*[https://moodledev.io/general/development/tracker Using Tracker]
* [https://moodledev.io/general/development/tracker Using Tracker]  
*[https://www.npmjs.com/package/@moodlenet/ce-platform Code repository]
* [https://www.npmjs.com/package/@moodlenet/ce-platform Code repository]
*[https://docs.moodle.org/moodlenet/Main_Page MoodleNet user documentation]
* [https://docs.moodle.org/moodlenet/Main_Page MoodleNet user documentation]
*[https://moodle.org/mod/forum/view.php?id=8726 MoodleNet news and discussion]
* [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet news and discussion]
*[https://tracker.moodle.org/secure/RapidBoard.jspa?rapidView=167&view=detail MoodleNet Issue Tracker]
* [https://tracker.moodle.org/secure/RapidBoard.jspa?rapidView=167&view=detail MoodleNet Issue Tracker]
*[https://gitlab.com/moodlenet/moodlenet/-/issues MoodleNet Gitlab Issues]
* [https://gitlab.com/moodlenet/moodlenet/-/issues MoodleNet Gitlab Issues]
[[es:MoodleNet]]
[[es:MoodleNet]]

Revision as of 13:10, 6 July 2023

Moodlenet-logo.png

What is MoodleNet?

MoodleNet is a flexible Open Education Technology platform for curating collections of the best known Open Educational (and other) Resources. You'll find more general information in the MoodleNet user documentation.

If you are looking to get started as a MoodleNet developer, we recommend taking the MoodleNet for Developers course with Moodle Academy.

Current status

Take a look at MoodleNet releases in our Tracker.

Roadmap

Quick start guide

System Requirements

MoodleNet requires the followings to be available on your system

Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9

We tested so far with the previous LTSs nodejs ^16 and npm ^8

Make sure to have nodejs ^16 installed and you should get npm ^8 as well

Deploy an ArangoDB instance

MoodleNet uses ArangoDB as main database

You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process

An easy way to install run ArangDB locally as a service is by using Docker[4] e.g. :

docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10

Possibly tweaking some options as you like, e.g. mounting a volume|directory for data or setting a password

Install MoodleNet

Install Moodlenet by simply issueing the following npm command

npm create @moodlenet@latest path/to/installation/folder

That will install all MoodleNet core packages in the choosen folder

it will also create a default configuration file (default.config.json) and a default cryptographic key-pair for the system (default.crypto.privateKey , default.crypto.publicKey)

Start MoodleNet process

To start MoodleNet issue the following command from within the installation directory

npm start

open your browser on http://localhost:8080

Notice: on the first run the system will have to compile the webapp, so you'll get a 404 until ready. It should take a few minutes

MoodleNet configuration file

MoodleNet configuration file (default.config.json) holds all static system configs.

Here's how the default config looks like after install:

{
  "pkgs": {
    "@moodlenet/core": {
      "baseFsFolder": "/path/to/installation/dir/fs",
      "instanceDomain": "http://localhost:8080",
      "npmRegistry": "https://registry.npmjs.org",
      "mainLogger": {
        "consoleLevel": "info",
        "file": {
          "path": "./log/moodlenet.%DATE%.log",
          "level": "info"
        }
      }
    },
    "@moodlenet/crypto": {
      "keys": {
        "alg": "RS256",
        "type": "PKCS8",
        "private": "/path/to/installation/dir/default.crypto.privateKey",
        "public": "/path/to/installation/dir/default.crypto.publicKey"
      }
    },
    "@moodlenet/arangodb": {
      "connectionCfg": {
        "url": "http://localhost:8529"
      }
    },
    "@moodlenet/http-server": {
      "port": 8080,
      "defaultRpcUploadMaxSize": "5MB"
    },
    "@moodlenet/ed-resource": {
      "resourceUploadMaxSize": "1.2GB"
    },
    "@moodlenet/simple-email-auth": {
      "newUserNotPublisher": false
    },
    "@moodlenet/email-service": {
      "nodemailerTransport": {
        "jsonTransport": true
      }
    },
    "@moodlenet/system-entities": {
      "rootPassword": "eqhb30x9iq5"
    },
    "@moodlenet/react-app": {}
  }

here's some relevant configs you may want to check and tweak

  • @moodlenet/arangodb.connectionCfg.url : the default config assumes you installed ArangoDB without password with standard port on the same host
  • @moodlenet/core.baseFsFolder : path (better absolute path instead of relative to MoodleNet process cwd) to the system root folder for system filesystem persistency, if you want to change the system-filesystem-root after the system already run, move or clone the existing folder somewhere else and set this config properly to point to the new path
  • @moodlenet/core.instanceDomain : the public domain of your moodlenet instance (e.g. https://moodlenet.example.com) - the default one (http://localhost:8080) is ok for testing and dev
  • @moodlenet/email-service.nodemailerTransport : the nodemailer transport configuration for the system email service. It can be a simple smtp url string, or a nodemailer standard config object. Notice: with the default configuration { "jsonTransport": true } the system won't send any email, it will simply log them)
  • @moodlenet/system-entities.rootPassword : a static root password for edge cases - you'll use it to give the first admin permission to a user (see below) - this property is optional, if not set the root user is disabled
  • @moodlenet/http-server.port : the HTTP server port to listen

Moodlenet's HTTP service doesn't support HTTPS.

It's always a good practice to back Moodlenet with a HTTP reverse proxy (e.g. nginx, Apache) and it is a must if you want to publish over HTTPS, configuring TLS on it

Default authentication system

Moodlenet comes with a simple email+password authentication system (pkg @moodlenet/simple-email-auth) that lets users signup and login with a verified email

Users can sign up with their email, receive in their inbox a confirmation link to click and create their user-account

Assign admin privileges to user

As you deploy a new instance, no user is present in the system.

Signup with your email and create your user.

Test login, then logout and browse to the hidden page http://localhost:8080/login/root, here you can type in the rootPassword (specified in config file) to login as root.

Open the avatar menu on top right header, and click admin link

Click on Users section on the left, and see your user listed there. Activate the admin icon to give your user admin privileges

Now you can log out and login back with your email, see you gained the admin link in your avatar menu

Migrate from V2

If you have a v2 running and want to migrate it to v3 , you can use the @moodlenet/v2-migrate-v3

The v3 system must have access to Moodlenet-V2 persistencies: its running arangoDB instance and the MN2 filesystem as configured in V2 env variable STATICASSETS_FS_ROOT_FOLDER

After installed Moodlenet, issue the following command from the installation folder

npm install @moodlenet/v2-migrate-v3

Edit the default.config.json adding a @moodlenet/v2-migrate-v3 section beside the others, it should look like that

    "@moodlenet/v2-migrate-v3": {
      "v2DbConnectionCfg": {
        "url": "http://your-mn-v2-arangodb-host:8529"
      },
      "v2AssetFolder": "/path/to/v2/asset/folder"
    }

re/start the system, all the services will start after the migration done

MoodleNet architecture

MoodleNet is a full stack TypeScript/JavaScript system using:

  • NodeJs
    • NPM Packages [5]
    • ESM Modules [6]
  • Browsers

MoodleNet development environment

Setup development environment

From the command line interface (CLI):

Ensure ArangoDB is running on localhost. You may run it in a Docker container issueing a command as below:

docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn3-dev arangodb:3.10

Clone the repository, you may wish to fork it, but that's not required:

git clone https://gitlab.com/moodlenet/moodlenet.git

Change to the project's folder:

cd moodlenet

Install and initialize the project:

npm install

Install a development server:

npm run dev-install-backend my-dev # <- my-dev: an arbitrary dev-installation name

In the example we choosed my-dev as installation name, the tool will then setup a dev installation in ./.dev-machines/my-dev

You can create as many dev installations as you wish.

Run development backend:

npm run dev-start-backend my-dev # <- my-dev : the name you choosed when installed

The first run of the system may take some time to install.

The default configuration for dev includes the config @moodlenet/react-app.noWebappServer: true that prevents the server to serve the webapp, so you won't access the webapp on http://localhost:8080

Instead, you'll want to run a webpack+HMR serving the webapp issueing

npm run dev-start-webapp my-dev # <- my-dev: the installaton server to point to

Once all started, browse http://localhost:3000

Mono-Repository management with Lerna.js

MoodleNet project takes leverages lerna.js to manage multi-package mono-repository .

Please refer to Lerna documentation to understand how it manages mono-repo and project-packages dependency linking in the development environment.

Questions? Please take a look in the MoodleNet Community and Tracker for answers or to ask for help.