Programming Tips - How was Dave's Brain implemented?
Date: 2006nov6
Updated: 2018nov10
Keywords: daves, davekb.com
Q. How was Dave's Brain implemented?
A. The articles are stored in folders that group them into
categories. They are mostly plain text files. The application,
written in PHP, pretties up the text files based on a few simple
rules when displaying them.
It's LAMP without the MySql which makes LAP, I guess.
That's pretty much it. Simple is good.
The searching is reasonably fast because there aren't that many files
and because Linux probably has the files cached.
There are an number of amazing things that come for free when you
use a filesystem has a "database":
- Each file must have a unique name
- You can easily edit or spellcheck any file
- Your program can easily read any file
- They are listed in alphabetical order by default
We employ OpenID for the login. We used the SimpleOpenID php
class from http://www.fivestores.com
OpenID has a number of nice features:
- Maybe the user already has an OpenID (user friendly)
- If the user doesn't have an OpenID we thing they are more
likely to go to the trouble of getting an OpenID than
a Dave's Brain login.
- We don't need to keep a database of users
- We don't need to make pages for users to register, recover
their passwords, edit their profile, etc.
- There are weekly cron jobs to rebuild the keywords and crawlers lists.
Those are stored in php serialized format for quick retrieval.
- Hourly, the folders are checked for updates and if necessary the
list of recent article is rebuilt and stored in the same php serialized format.
- To provide better spelling suggestions the words from articles are converted
into an installation specific dictionary weekly. So if a user
enters "phq" it might suggest "php".