root

# Shoe store

A simple scotty + persistent + sqlite webapp to demonstrate haskell fu
(or lack thereof).

Kaalani is "leg-wear" in Tamil[1].

## Set up

I haven't tested this outside of a sandbox.

```
cabal sandbox init
cabal install --dependencies-only --enable-tests
cabal build
```

## Test Suite

Tests are based on HSpec + Quickcheck.  There can be a lot more tests added,
especially to the web part.  In the interest of saving time, I have added only
the cases that I considered essential to progress with reasonable confidence.

Most of the tests use in-memory Sqlite.  However, for a few higher level tests
that verify atomicity, a persistent DB is used (saved on /tmp).  Text files are
also created and deleted (on /tmp again).

`cabal test`

## Running the app

There are two executables.  The executable for starting the web server (kaalani)
and a primitive executable (kpost) to add a shoe by calling POST on the web server.

The web app creates a Sqlite DB in the current directory (shoes.db).  The uploaded
files are saved on "uploads/img" directory in the source tree.  If the app is run
from a different folder than the root folder (housing kaalani.cabal), the upload
directory needs to be created there.

The following command should get the web server up and running.

`cabal run kaalani`

Assuming `cabal build` completed successfully, the `kpost` executable can be used
to `POST` to the running web server.

The web app can be accessed at: http://localhost:3000/shoes. (POST url is the same).


[1]: http://translate.google.com/#ta/en/காலணி