Building a Document Management System: Part 3

In the first two parts we have been designing the basic infrastructure of our Document Managment System (Part 1, Part 2) now let’s see how this all fits together:

So far we have this list of URLs:

  • GET /documents/ add a document to the system
  • POST /documents/ get a list of recently added documents (Atom feed)
  • GET /documents/search/{attribute}/{searchterm}/‚ get a list of documents where attribute==searchterm (Atom feed)
  • GET /document/{key}/ get document identified by key
  • GET /document/{key}/metadata.atom get metadata for document (Atom feed with a single entry)

(GET /documents/ and GET /document/{key}/metadata.atom haven’t been discussed before but they follow closely the pattern of the other URLs).

This interface allows us to build a very simple (< 200 lines of code) library to put data in the document store and retrieve it again. In web applications we even can link to documents directly since they are all available under static HTTP URLs. The server also is very simple (< 200 LoC) spending most of it’s energe with generating Atom feeds.

The other nice thing is that we can access this Interface interactively: Since it uses the Atom syndication format for all it’s data and Firefox has decent Atom parsing and display capability we can use Firefox to access the data in the store. See right for some example. The use of XHTML to encode our attributes helped enormously to make this usable in the Feed Reader Mode of Firefox and the identification of Attributes by their Search-Urls makes everything nicely clickable.

Unfortunately we are missing a Way to search. Let’s say you want to check Documents for customer No 12345. Sure, you could just put /documents/search/customer/12345/ in the URL line and you are fine. But most people think there is something wrong about manipulating the URL line.

We can help that by adding a tiny bit HTML: A front page which input fields to search for the different attributes and a redirector which redirects clients requesting /search?attname=client&attvalue=12345 to /search/client/12345/. The reason this is needed is the fact that HTML forms don’t allow to generate URLs but only can generate query parameters. (But maybe HTML 5 will be able to do better.)

So we add two more URLs:

  • GET / display a html form.
  • GET /redirect_to_attributefeed redirect to /documents/search/{attribute}/{searchterm}/.

Now we have a nice API which can be in addition quite comfortable navigated with a Webbrowser. See this Movie for an demonstration. First I search viathe Web-Form and get redirected to an Atom feed or order number 180162. From there I can click through to an Atom feed with all documents for customer id 104685. I can request the scanned Document. By manipulating the URL line I get to an overview of recently added documents, click to the documents for an other customer and then to the documents generated by staff member ’40‘. There again I get Display an document, click to documents for customer 14008 and check another document.

All this with only a single Page of HTML.

3 comments on “Building a Document Management System: Part 3

  1. mikeschinkel
    2008-10-16 at 00:08 #

    Yes, let’s get HTML5 to support URI Templates!

    Yes, let’s get HTML5 to support URI Templates!
    Thanks for the reference. YES, let’s get HTML5 to support URI Templates. It is really needed. Join the HTML Working Group and let your voice be heard.

    Nice article, btw. Always nice to see someone focusing on URL Design.

    P.S. That said, how about better URLs for this blog? :-) :-) :-)

    This comment was originally posted on 20070712T19:23:01

  2. mdornseif
    2008-10-16 at 00:08 #

    Oh yeah, this blog is so broken.

    This comment was originally posted on 20070713T21:13:39


  1. teenage mutant ninja hero coders » Blog Archive » Building a Track and Trace Application with CouchDB - 2008-12-28

    […] My first approach was an SQL database. Later I coupled it with a self-designed Document store called DoDoStorage. For background on that project see here, here and here. […]

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s