Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTful API #144

Open
michaelgfalk opened this issue Aug 23, 2022 · 13 comments
Open

RESTful API #144

michaelgfalk opened this issue Aug 23, 2022 · 13 comments

Comments

@michaelgfalk
Copy link
Contributor

michaelgfalk commented Aug 23, 2022

The big questions

  • What aspects of a RESTful architecture are most important to implement soon?
  • What concrete approaches/technologies might work?
  • What aspects might you be willing to work on, if you are a programmer?

Status Quo

Retrieving data

Currently Heurist relies mostly on URL parameters to retrieve records and other data from Heurist databases. A typical call to the public API looks something like this:

    heurist server     version   data param   database param
           |              |           |              |
|---------------------/-------/--------------&---------------|
https://heuristref.net/heurist/?recID=12735&db=falk_playspace

My preferred solution would be to implement something like the following:

    heurist server     version    database   datatype  id
           |              |          |           |      | 
|---------------------/-------/--------------/------/-----|
https://heuristref.net/heurist/falk_playspace/record/12735

User interface

On the backend, Heurist is implemented as a single page application and does not provide routing to different menus in the interface.

How important is routing on the backend? To my mind it is unimportant. Users interact with the backend interface as a software application, the way they would us Google Docs or a desktop application. In these contexts, I don't think routing is very important.

CMS websites

On websites in the Heurist CMS, the website and the current page are both indicated by URL parameters. Heurist public sites are also implemented as single page applications, and do not provide full routing—though it is possible to obtain a persistent URL to individual pages on each site.

Here I think that a better form of routing can and should be implemented. Users should be provided a subdomain for each site on each Heurist server. This may not be possible for some servers, where there are insitutional restrictions on subdomains, but generally I think it could be implemented by creating a wildcard domain for each Heurist server and then parsing the subdomain elements in a standard form, e.g.

        database name  heurist server
              |              |
|---------------------.--------------/
https://falk_playspace.heuristref.net/

Apache would direct all requests with a subdomain to a PHP script that would parse the subdomain and retrieve the website for e.g. db == falk_playspace.

Ideally this would be combined with standard page routing as in other CMSs:

        database name  heurist server     slug
              |              |              |
|---------------------.--------------/------------/
https://falk_playspace.heuristref.net/project-team/
@michaelgfalk
Copy link
Contributor Author

Heurist already uses some Symfony components (I think), so these pages could be relevant:

@wiztigers
Copy link

wiztigers commented Sep 30, 2022

Hi @michaelgfalk ,
(and sorry I just saw this discussion)

I totally agree with the need for Heurist API to be more RESTful. To my knowledge, the two main drawbacks of the current implementation are : 1) too much reliance of url params, and 2) lack of proper authentication. These prevents effective usage from CLI/scripts, yet this, to me, seems essential for my future dev needs as long as for the future of Heurist (ie. extensions and third party devs).

I kind of agree with you that routing in the client is not very important right now ; but I feel it's rather more a consequence of the way Heurist GUI is implemented right now than something that isn't desirable per se. I thing that, on the contrary, it's something desirable. Not everybody wants to clicketey-clickey each time they open Heurist, but more than that, sharing specific records uris, showing off custom templates or vocabularies, and in general working as a team (at least remotely) kind of requires this kind of permurls.
For exemple, currently you can share custom searches via urls. This is a must, very useful, and the kind of feature I'd like to see more.

And yeah, Heurist websites routes should be explicit. Urlparams are useful, but too much reliance on it should (IMO) avoided. Semantic urls is the way to go.

Proposed actions

If you don't mind, I'll share a proposal of what could be the next version of Heurist API. Probably a standalone project, which would just be a Swagger page, so we° can discuss stuff in practice, see the caveats, think about what can be made available and what shouldn't be, and so on.
Then we° can say, for example, "we° discuss it until this date, so we° have the majority of questions answered, and then we° begin implementing it".

For various reasons, I should be able to do this next month (before start of november 2022, I hope —no guarantee).

° by "we" I mind "everyone who wanna participate". As its API is/will be a core component of Heurist, we really should have these discussions in public, with as many brains participating as possible. We're talking writing a specification, here.
So, kudos to you for creating this issue instead of relying on mails. We don't have a structured "dev community" yet but —hey, we gotta start somewhere 😸

@wiztigers
Copy link

FWIW, just to be sure we're talking about the same thing, here is the original source of REST, Roy Fielding's thesis, with the 5 mandatory constraints (and a sixth optional one) of every REST interface.

And we already talked about the Richardson Maturity Model, so here is Martin Fowler's breakdown. Let's aim for level 3, baby !
(and we'll probably fall somewhere between levels 2 and 3 ... 🐈 )

@wiztigers
Copy link

Reminds me : I took some additional notes in this issue: huma-num/heurist#4.

@yangli0516
Copy link
Collaborator

Hi @michaelgfalk, thanks for inviting me to this thread.

From the discussion, the followings are the features we would like to see in Heurist API:

  • The ability to read all terms from vocabularies.
  • The ability to get record type information with field definitions.
  • The ability to read non-public records through authentication methods.
  • Would be good to have the parsed temporal object in the API result instead of the raw value only. e.g. {start: 1900, end: 2000}
  • Would be good if the API can provide write operations to the database as well.

@wiztigers
Copy link

Hi,
I've begun specification of a future RESTful API for Heurist, which is available here.
It's unfinished, for two reasons :

  • I'm "not full time" on this (which is an understatement in itself)
  • I'd like to receive feedback from any person interested in this

As you'll see, some RFC (Requests For Comments) are spread inside the documentation ; those are specific questions I'd like to have feedback about.
The main issues I have now are about:

  1. user management which would not be on a "per database" basis ;
  2. true internationalization of Heurist GUI, as long as of databases (eg. 1 field, multiple labels for each language, one value for each language).

I'll advance on this subject until the end of the year, during which I should be able to answer any request / participate to any debate.
And I'd like to begin implementation in january. Duration of this implementation phase could vary wildly depending of the answer I get to current and future RFCs, so I cannot give any deadline now.

@michaelgfalk, thanks in advance for any additional visibility you give to this initiative.

@yangli0516, to answer your specific requests :

  • "read all terms from vocabularies" this is in my mind too, and will probably specified this week ; although it's linked to the problem of databases internationalization I just talked about.
  • "get record type information with field definitions" is already specified ; although I'd like to write a few use cases for it to be crystal clear, feel free to discuss this
  • "read non-public records through authentication methods" I want this too, but ther's many questions around authentication I'd like the "Heurist dev community" to discuss about
  • "parsed temporal object" not sure what you're talking about. Personnaly I want that to be returned by the API in ISO formats, and not the human-readable but not really usable thingy we have now.
  • "provide write operations to the database" of course, that's a given ; although, one more time, what we'll be able to provide for authentication will heavily constraint this. I'd kill for ABAC.

@wiztigers
Copy link

ps. this is the link to the specification (and hopefully future documentation), and you can read it in SwaggerUI format if you prefer.
I don't, but SwaggerUI might be a more standard way of providing a simple interface to test the API once it will be implemented (@see RFC-SANDBOX for discussion and details).

@ijohnson222
Copy link
Member

ijohnson222 commented Nov 2, 2022 via email

@wiztigers
Copy link

wiztigers commented Nov 2, 2022

Hi @ijohnson222 , hope you're well, thanks for your answers

  1. (users & authentication) Of course, keeping the self-contained nature of databases but, in the future being able to say "in this specific Heurist server instance, user 3 of database db1 is the same person as user 26 of database db2" would be the best of both worlds, IMHO. We could implement a "real" authentication system (ie. token based and/or based on an identification provider, like 0Auth2, HumanId and so on) without straying off your vision, which suits me perfectly.
    So, one more time thanks, because just this answer is a huge help for me.
    My stance is to be, as you said, as simple of possible during implementation. Things will be complicated enough. However, I'd like to design the REST API in a way that allows us to provide users with new features in the future without breaking the REST interface.
    On the topic of ABAC, I think we share the same objective to be as flexible and as maintenance free as we can. But what I meant with my "i'd kill for ABAC" badly-formed pun, was that we could generalize UNIX-style permissions to more parts of Heurist than currently implemented.
    To give you examples:
    • some of "my" local Heurist users are a tad worried that you can compartiment records as much as you want, but you cannot do this for vocabs, which remain free pickings even for students who don't know what they do. I'm unsure of why vocabs don't have the same permission system as records.
    • another thing they'd like is to be able to define which workgroup can read/edit each field in a given datatype. The current mecanism of hidden/not hidden is not sufficient for some teams. In my mind, each base field could have an ownership similar to what currently exists for records. And each setting. And each vocabs|fields|types group. And so on. Thus, instead of users and groups, which is perfectly fine, you have the application of users and group to everything in Heurist. And one way of seeing this is a big matrix of "who has access to what" -it is in that sense that I talked about ABAC.
  2. (i18n) I'm looking forward to see your point of view.
    Just in case, please keep in mind the following points (which are just examples):
    • Differentiating languages is not sufficient, you should use locales at the very least (language+country) ; you're Australian, you surely know the differences between the different flavours of english, and even a snobby french guy like me wouldn't pretend that canadian french is the same that my french in every way
    • Just use UTF-8 everywhere ! And apply it to everything in Heurist, including sorting. During import, I cry each time my "État" field comes at the end of field lists. Just forget ISO.
    • Please keep in mind languages are very diverse, and the only sure way of solving this problem is to don't assume anything. For example, you see how datatypes have a name, plus a plural name? If not already done, maybe you can just ask @osmakov how russians form plural. As I understand it, the way plural works in Heurist doesn't even fully support russian-like languages. And don't even get me started on Asia ...
    • Everything could and should be internationalized: GUI labels, fields values, pictures, position of elements in the GUI, etc, etc, etc.
      In other words, I18N is a vast subject, the kind that should be not discussed alone. It's even more the case if you factor in A10N (accessibility) to support screen readers for example. Thus, I sincerely hope you're in touch with people (maybe at BNF) that really localized more than one professional software in multiple languages each time, all the while having legal constraints of multiple countries regarding accessibility to sugarcoat things... And if not, may I offer my help? Because this was exactly my life a few years ago, y'know, when I wore suits and crap ...

@ijohnson222
Copy link
Member

ijohnson222 commented Nov 2, 2022 via email

@wiztigers
Copy link

wiztigers commented Nov 4, 2022

Very interesting. Briefly cuz I don't have much time:

  • Glad to hear vocabs protection is possible at all because -yeah, here people kind of want it. IMO where possible we should really not make the choice for users, but provide a setting per database.
  • I'm super hyped by field "visibility" , as soon as it's implemented in h6-alpha please communicate about it if you can. Then if it suits 'my' needs, I'll try to document it.
  • Yeah, working on infinite perimeters with limited resources is kind of unavoidable (but not hopeless). That's why I've improved my availability for Heurist, and will try to improve even further in 2023. IMO lots of groundwork (API, testing, specifications) is necessary to create a dev environment that better welcomes new devs/users an continue to extend the dev/users communities. In my eyes, now it's really a hassle to reconcile quality and "features per month", and it shouldn't be.

Thanks a lot for the roadmap.
There are many of these items that are of special interest to the Alsatian / French public, but hell could be in the details of how we envision things. We really have stuff to talk about together, to maybe prioritize what we agree about (which I'm sure will be the majority). As soon as REST API is done, I'll probably steal items in your todo list nyahaha 😼

@wiztigers
Copy link

wiztigers commented Nov 4, 2022

IMO lots of groundwork (API, testing, specifications) is necessary ...

I might add that I'm talking about specifications, not exactly (user) documentation.
The difference is the former explain how things should work, not how they currently work-well-kind-of-if-we-retro-engineer-things-but-we-don't-really-know-in-the-end. Me, as an "outsider dev", need to know what is a bug, what is a feature, and what in my plans does align with the core team future aims. And for this Ian, I personally need your vision on features, and at best Artem's vision on architecture, so these general visions can be put on paper (by me, if you don't have time) and pave the way to future features and fixes.

That's why even just this roadmap is invaluable for me.
If you could add maybe 1-10 lines of explanation to each (because some of these I don't understand), it would be a more solid base to begin:

  1. prioritization (once we understand why a feature would exist, each one of us can know if we want it or not)
  2. specification (a design doc is important to explain how the feature ought to work, and the implication)
  3. planning (once we precisely know what must be done, we can count how much time it would cost)

@ijohnson222
Copy link
Member

ijohnson222 commented Nov 4, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants