Giter Club home page Giter Club logo

arosenius-api's Introduction

The Ivar Arosenius archive backend

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.

Requirements

  • 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.

Getting started

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

Documentation

The ApiDoc documentation in documentation/ is very incomplete and oudated. Improve it or ignore it.

Images

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

Users are defined in the users.js file. All users have the same privileges.

Data model

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.

Migrating from Elasticsearch to MySQL

Consider this as documentation for a one-shot operation in the past.

  1. Run npm install to get new dependencies
  2. Run elasticdump on the server and scp it to ./arosenius_v4.json
  3. Create a MySQL database locally
  4. Extend config.js with the mysql.* properties (see config.demo.js)
  5. 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

Adapting to custom data

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).

arosenius-api's People

Contributors

traustid avatar arildm avatar majsan avatar dependabot[bot] avatar

Stargazers

yana avatar

Watchers

James Cloos avatar  avatar

arosenius-api's Issues

Allow only some image sizes

The route for serving resized images allows any size specification. This can fill up disk space if abused. A reasonable mitigation would be to refuse all exept the sizes needed for the frontend (see ImageSizes.js)

Exclude keywords for deleted artworks

http://cdh-vir-1.it.gu.se:8004/persons includes "Ole Kruse ", which is a bad variant of "Ole Kruse" and now is only used for the deleted artwork GUB-599 (it has deleted: true). Another example is "Eva "Lillan" Arosenius". This is visible and confusing in the GUI.

/persons and similar endpoints should filter out keywords for deleted artworks.

Some images never finish loading in full

On http://aroseniusarkivet.org/#/image/PRIV-4582 the image remains blurred and the spinner keeps spinning. This is not the only one.

This request to the IMGR part of the api gets a 500 error response:

http://cdh-vir-1.it.gu.se:8004/images/1600x/gkm_diabilder_odaterade_068.jpg

From the systemd log (I suppose it's relevant):

Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: Error: Command failed: gm convert: Image sequence is required (unable to coalesce image).
Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: at ChildProcess.onExit (/appl/cdh/arosenius-api/node_modules/gm/lib/command.js:301:17)
Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: at emitTwo (events.js:125:13)
Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: at ChildProcess.emit (events.js:213:7)
Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: at maybeClose (internal/child_process.js:897:16)
Sep 09 16:49:11 cdh-vir-1.it.gu.se arosenius-api[18399]: at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.