Here is the source code for the backend for the Ivar Arosenius online archive (http://aroseniusarkivet.org).
The frontend can be found here: https://github.com/CDH-DevTeam/arosenius-archive-gui
The admin system for the database can be found here: https://github.com/CDH-DevTeam/arosenius-admin
This documentation also addresses server requirements and server setup.
- MySQL (5.7, other versions may also work)
- Node.js (12.18, other versions may also work)
- GraphicsMagick
The API runs on port 3010 by default, but this can be overridden in config.
To run the backend, first clone the repository or your own fork of it. Then install all JS dependencies, create config files and start it.
git clone https://github.com/CDH-DevTeam/arosenius-api.git
cd arosenius-api
npm install
cp config.demo.js config.js
cp users.demo.js users.js
# Edit config.js and users.js
node app.js
During development, you can use nodemon to have the server restart whenever any source file is changed:
npm --global install nodemon
nodemon app.js
The ApiDoc documentation in documentation/
is very incomplete and oudated. Improve it or ignore it.
Images are handled through the IMGR framework via Express.js.
It requires GraphicsMagick (gm
).
The server can serve images in an arbitrary resolution which is defined in the url. For example, the image 1.jpg
can be accessed in full resolution via [url]/images/1.jpg
and in max 1600px resolution via the url [url]/images/1600x/1.jpg
Original images are read from the directory specified by image_path
in the config. It can be an absolute or a relative path. When using the resizing urls, the resulting resized images are stored in the directory specified by image_temp_path
as a cache.
Note that there is no cleanup or expiry mechanism of resized images, nor any restriction on what sizes can be requested.
Users are defined in the users.js
file. All users have the same privileges.
The data model for this project began as an Elasticsearch index, before it was converted to MySQL in 2020. The data structure is still artwork-document-centered, and some other design choices in the model and code are due to this Elasticsearch legacy.
Consider this as documentation for a one-shot operation in the past.
- Run
npm install
to get new dependencies - Run
elasticdump
on the server and scp it to./arosenius_v4.json
- Create a MySQL database locally
- Make sure to use
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_swedish_ci
(see https://mariadb.com/kb/en/setting-character-sets-and-collations/)
- Make sure to use
- Extend
config.js
with themysql.*
properties (seeconfig.demo.js
) - Run the data migration:
- Run the SQL commands in
arosenius-model.sql
to delete (!) and create necessary tables. - Run
node es-to-mysql.js
- Inspect the MySQL database
- Improve the script and
arosenius-model.sql
- Repeat
- Run the SQL commands in
This database backend is open source, and we encourage you to use it for your own data. If you do, we also recommend using arosenius-archive-gui as a user-friendly GUI and arosenius-admin for manually managing data entries.
As the data model is quite hard-coded into the code, this requires that you can either structure your data into the same model, or edit the code to fit your data better. See arosenius-model.sql
for the SQL definition of the data model (schema).