I want to write a Web application for which I think Prolog would be interesting to apply rules and solve constraints. Let's say that this is an application about recommending movies to a user based on the user's preferences + a set of global relations/facts about movies. For instance a global movie_genre(terminator, action). and for one user likes_genres(alice, [action, comedy]). and for another user likes_genres(bob, [thriller, drama])., so maybe suggest_movie(alice, Movie). would return Movie = terminator.
I was thinking of having a main back-end in another language using a framework (like PHP or Node.js) and calling the Prolog back-end when needed. However, I'm not sure how to proceed. How would you:
- store data: usually, I would store data in a relational database. But from what I understand, I could also store facts with asserta/z and remove them with retract? But then, is it scalable to load all facts for all users? Or would I load facts for a given user?
- call the Prolog back-end: Run a Prolog HTTP server? Start the interpreter when needed?
- do request/get responses, in particular when there are several responses: using a higher-level protocol, or instrumenting the Prolog interpreter?
Any help or advice is appreciated, thanks!
Additional notes:
- I know there was a similar question, but it was asked literally a decade ago. Times have changed, and perhaps the answers could be different today.
- I know there are libraries implementing Prolog, and I prefer using a full (ISO compliant) Prolog interpreter.
- Performance is not a primary concern at this point, development speed is!