   [system-map component f]
   (let [components-map  (conj (component-dependencies system-map component)
                               component)]
-    (updat! system-map :components
-                   (map f components-map))))
-
-
+    (updat-system! system-map :components
+            (map f components-map))))
+
+
+;; DONE ---------------------------------------------
+(defn get-dependencies-of
+  [system-map component]
+  (let [dependencies (dependencies component)]
+    (filter #(some #{(::name %)} dependencies)
+            (vals (get-components system-map)))))
+
+(get-dependencies-of parsed-system example-component)
+
+;; DONE ----------------------------------------------
 (defn start-component!
   "Starts the given `component` of the given `system`."
   [system-map component]
-  (with-component-dependencies system-map component call-start))
-
-
-(defn start!
+  (if (started? component)
+    system-map
+    (update-in (reduce start-component! system-map
+                       (get-dependencies-of system-map component))
+               [:components (get-name component)]
+               (fn [_] (start! component {})))))
+
+
+(start-component! parsed-system example-component)
+
+
+;; DONE ----------------
+(s/def ::system-map map?)
+
+(defn start-system!
   "Starts the given `system-map`."
   [system-map]
-  (map #(start-component! system-map %) (get-components system-map)))
+  (if-not (s/valid? ::system-map system-map)
+    (throw (ex-info "Provided system is not valid" {:cause (s/explain ::system-map system-map)}))
+    (reduce start-component! system-map (vals (get-components system-map)))))
+
+(start-system! parsed-system)
+;; ----------------------
+
 
 
 

(def example-component
  {::depends-on [:sa]
   ::name :server
   ::started? true
   ::start-fn (fn [this context] (println (str "<<<<" context)))
   ::stop-fn (fn [this] (println "stoping"))})

(def example-system
  {:components [example-component]})


  (reset! system (merge system-map
                        {:components (components-map system-map)})))

(defn update-system-components!
  [system])

(defn with-component-dependencies
  "Runs the given function for all the dependencies of the given `component`
