     ::run-state
     ::raw})
 
-(defn get-readable-project [project-name]
-  (apply dissoc (get-project* project-name)
+(defn get-readable-project []
+  (apply dissoc (get-project*)
          non-data-keys))
 
-(defn get-readable-raw-project [project-name]
-  (apply dissoc (::raw (get-project* project-name))
+(defn get-readable-raw-project []
+  (apply dissoc (::raw (get-project*))
          non-data-keys))
 
-(defn project-summary [project]
-  {:url (url-for-project (:name project))
-   :name (:name project)
-   :version (:version project)
-   :root (:root project)})
-
-(defn get-projects []
-  {:projects (for [[name project] @projects]
-               (project-summary project))})
-
-(defn add-project [project-root]
-  (load-project! project-root))
-
+(defn project-summary []
+  (let [project (get-project*)]
+    {:url (base-api-url)
+     :name (:name project)
+     :version (:version project)
+     :root (:root project)}))
 
 (defn bootstrap-self []
   (load-project! ".")
-  (swap! (-> "lein-ui" (get-project*) ::run-state)
-         assoc :repl self-repl
-               :figwheel (figwheel-process (get-project* "lein-ui"))))
+  (swap! (-> (get-project*) ::run-state) :repl self-repl)
+  (start-figwheel!))
 
 
 ;;; Server

  (go-loop []
    (<! (timeout 500))
    (doseq [[project subscribers] @figwheel-receivers]
      (let [output (-> (get-project* project)
                       ::run-state
                       deref
                       :figwheel


;;; Projects

(defonce project (atom nil))

(defn get-project* []
  (if-let [project @project]
    project
    (throw (ex-info "Project doesn't exist" {:name name}))))

(defn new-project [project-map raw-project-map]
  (assoc project-map
    ::run-state (atom {})
    ::raw raw-project-map))

(defn load-project! [root]
  (let [path (->>  (io/file root "project.clj")
                      (.getAbsolutePath))
        project-map (project/read path)
        raw-project-map (project/read-raw path)
        ui-project (new-project project-map raw-project-map)
        name (-> ui-project :name)
        root (-> ui-project :root)]
    (reset! project ui-project)
    name))


(def self-repl {:host "localhost"
                :port 7888})


;; TODO remove this for nrepl.client-manager
(defn repl-eval! [code]
  (let [{:keys [host port]} (-> (get-project*) ::run-state deref :repl)]
    (with-open [conn (nrepl/connect :host host
                                    :port port)]
      (-> (nrepl/client conn 1000)
