         uri (or db-uri "datomic:mem://localhost:4334/osmium")]
     (component/system-map
      :db (db/map->Datomic {:uri uri})
-     :server (component/using (map->Server {:port http-port}) [:db]))))
+     :session-store (new-session-store)
+     :server (component/using (map->Server {:port http-port}) [:db :session-store]))))
 
 (defonce system (atom (new-system {})))
 

       (response/status (response/response "Not authorized") 401)
       (let [new-book (book/new-book! db (map-keys (partial keyword "book") params))]
         (if-let [error (:error new-book)]
           (web/error-page error)
           (response/redirect (format "/book/%s" (:db/id new-book)))))))
   (GET "/book/:id" {params :params session :session}
     (let [book (book/by-id db (Long. (:id params)))

(defn start-jetty [handler port]
  (jetty/run-jetty handler {:port (Integer. port) :join? false}))

(defrecord Server [session-store db port jetty]
  component/Lifecycle
  (start [component]
    (println "Start server at port:" port)
    (assoc component :jetty (start-jetty (app-handler session-store db) port)))
  (stop [component]
    (println "Stop server")
    (when jetty
