Architecture
TableOfContents
The bags and recipes model is a reference architecture for how tiddlers can be shared between multiple wikis. It was first introduced by TiddlyWeb in 2008.
The principles of bags and recipes can be simply stated:
A very simple example of the recipe/bag model might be for a single user who maintains the following bags:
Those bags would be used with the following recipes:
All of this will work dynamically, so changes to the app bag will instantly ripple into the affected hosted wikis.
A more complex example might be for a teacher working with a group of students:
Those bags would be exposed through the following hosted wikis:
MWS uses SQLite for data storage. It supports choosing between two "database engines" that are based on two different npm modules:
By default npm install
will install both database engines. By default it will use better-sqlite3
. To switch to using node-sqlite3-wasm
, set the system configuration tiddler $:/config/MultiWikiServer/Engine
to wasm
(the default value is better
). Note that this tiddler resides in the Administration Wiki.
If you encounter errors during npm install
related to gyp
or prebuild
, you may be able to avoid them by using node-sqlite3-wasm
instead of better-sqlite3
. However, it will be necessary to manually install node-sqlite3-wasm
and its dependencies. This can be done by running the following commands in your terminal:
npm install node-sqlite3-wasm
MultiWikiServer is a new development that drastically improves TiddlyWiki's capabilities when running as a server under Node.js. It brings TiddlyWiki up to par with common web-based tools like WordPress or MediaWiki by supporting multiple wikis and multiple users at the same time.
Features under development include:
MWS is currently under development at GitHub but it is already functional and usable.
These instructions require minimal knowledge of the terminal. There are also alternative instructions for those using Git.
npm install
npm start
See Troubleshooting if you encounter any errors.
To update your copy of MWS in the future with newer changes will require re-downloading the code, taking care not to lose any changes you might have made.
These instructions require basic knowledge both of the terminal and of Git. There are also alternative instructions without using Git.
git clone -b multi-wiki-support --single-branch https://github.com/TiddlyWiki/TiddlyWiki5
npm install
npm start
See Troubleshooting if you encounter any errors.
To update your copy of MWS with newer changes from GitHub, run the following command:
git pull
SQLite is a very popular open source embedded SQL database with some unusual characteristics. It has proved itself to be robust, fast and scalable, and has been widely adopted in a range of applications including web browsers, mobile devices, and embedded systems.
The "embedded" part means that developers access SQLite as a library of C functions that run as part of a larger application. This contrasts with more familiar database applications like Microsoft's SQL Server or Oracle that are accessed as network services.
MWS uses SQLite for the tiddler store and associated data. It brings many advantages:
TiddlyWiki 5 has always incorporated a database. Until MWS, that database has always been a custom tiddler database written in JavaScript. Over the years it has been enhanced and optimised with indexes and other database features that have given us reasonably decent performance for a range of common operations.
In terms of the traditional architecture of TiddlyWiki, MWS uses SQLite as the basis for an internal API that is equivalent to that of the $tw.Wiki
object: basic CRUD operations on a database of tiddlers stored by their titles.
In the context of MWS, SQLite is just a fast and efficient equivalent of TiddlyWiki's existing JavaScript database engine. It gives us the option of persisting the database in file storage, but we also retain the option to run the database entirely within memory and rely on a file synchronisation process to save changes as individual .tid
files in the file system, just as we do today.
One particular misconception to avoid is the idea that SQLite replaces the folders of .tid
files that characterise the Node.js configuration of TiddlyWiki. These are separate components with a different purpose. The tiddler files are the result of syncing a database to the filesystem, and that database can be conceptually interchanged between our custom JavaScript database or the new SQLite implementation in MWS.
Our application has transitioned from a conventional username/password authentication system to a more robust Authentication and Authorization implementation. This new system supports multiple user accounts, roles, permissions, and a comprehensive access control list.
When you first launch the Multiwiki Server, it operates in an unauthenticated mode to facilitate initial configuration. During this initial state, the system creates a temporary anonymous administrator account. Upon accessing the landing page, you'll receive a prominent security warning with instructions to establish a permanent ADMIN account. It's crucial to create this account immediately to secure your installation.
This security model allows for fine-grained control over content access while maintaining flexibility for both private and public wiki deployments.
Users can be administered through two interfaces:
Each user account contains the following essential components:
Roles serve as permission containers and provide organized access control. The system includes:
Built-in Roles:
ADMIN
USER
MANAGER
Core Permissions:
READ
PermissionWRITE
PermissionThe ACL system provides granular security control through:
This comprehensive security model provides flexible, maintainable, and secure access control while supporting both authenticated and guest users within the Multiwiki Server environment.
The MultiWikiServer HTTP API provides access to resources hosted by the MWS store. It is based on the API of TiddlyWeb, first developed in 2008 by Chris Dent.
The design goals of the API are:
General points about the design:
Installation may fail with errors related to gyp
or prebuild
. These errors are caused by missing dependencies or incorrect versions of dependencies.
Note that in most cases, these errors occur because of the use of the npm module better-sqlite3. This module is mostly written in C, and thus requires compilation for the target platform. MWS supports switchable database engines, and also supports the use of the node-sqlite3-wasm module which is written in JavaScript and does not require compilation and so may avoid these errors. See Database Engines for more details of how to switch between engines.
The following steps may help resolve errors involving gyp
or prebuild
:
npm install -g npm@latest
npm cache clean --force
node_modules
folder in your TiddlyWiki directory by running the following command in your terminal: rm -rf node_modules
npm install
npm rebuild
gyp
and prebuild
dependencies. You can do this by running the following commands in your terminal: npm install -g node-gyp
npm install -g prebuild
npm install
Once MWS is successfully installed, you can access it by visiting http://localhost:8080 in a browser on the same computer.
By default, MWS is installed with full anonymous access enabled, meaning that anyone with access to the server has full access to read and modify anything. However, also by default, the server is only accessible to browsers on the same machine.
If you intend to put an MWS installation on a public network like the Internet, the server will need to be secured with the following steps: