Looking for advice for my school project rule based expert system

Hi everyone, I have a school project that requires me to build a rule-based expert system and I was thinking of building one using the web, anyone has any resource or suggestion on resources i can find building a rule based system using web?.

I just started with php and mysql, and wondering if its possible to build one full stack with a backend database or isit too ambitious?. I only have experience with front end staff , html,css and javascript. I have explored some libraries like Json rule engine but it seems to be fixed rule set.

Hope to get some advice :slight_smile:

Its just a bunch of objects and if/else statements, so you can build it in anything. A rules engine is literally this simple (example via Martin Fowler article):

if car.owner.hasCellPhone then premium += 100;
if car.model.theftRating > 4 then premium += 200;
if car.owner.livesInDodgyArea && car.model.theftRating > 2 then premium += 300;

However it’s really easy to design individual rules, it’s just that all those rules have to interact, which gets impossible to manage very quickly. Inference engines are non-trivial, but if it’s just for a school project I assume the requirements are simple enough for it to be doable in anything.

It’ll likely be much easier in something that is actually designed to do it though - for example, the language Prolog and its descendents (eg Mercury) are rules engines, that’s the point of them. Note there’s basic Prolog implementation ported to most languages via MiniKanren, though slow and limited compared to Prolog itself (which isn’t terribly quick anyway).

If you’ve got very little time, just a massive blob of if/else statements. If you’ve got a term or so, probably learn something that’s designed to make it all easier

The json rule engine makes it easier to handle nested if/else and store the rules in object. The only problem i have is whether to go full out using php and mysql to create an api for the client to fetch data from. (Im new to backend). Wonder if its overambitious

To be honest, I don’t think it is - you don’t need to go crazy here, you can keep the functionality simple, but the core idea of an expert system is that it provides an API for a non-technical user to ask questions of it. That is definitely hard, but personally, that’s where I would focus on - you want to create some way for a user to easily query that rules engine. It could be just a form, and you kinda turn that into a way for a user to write sentences, maybe using dropdowns, each one selected reveals a new dropdown, and build up the queries that way, using natural language (like the insurance example - car > owner|model > hasCellPhone|theftRating|livesInDodgyArea -> calculatePremium).

You’ve got three elements here - the database to store the data, the rules engine which knows how that data is structured and solves queries on it, and a user API that allows the non-technical person to make queries using the rules engine