Added new templates
diff --git a/planetstack/apigen/deps.template.json b/planetstack/apigen/deps.template.json
new file mode 100755
index 0000000..e4164cf
--- /dev/null
+++ b/planetstack/apigen/deps.template.json
@@ -0,0 +1,8 @@
+{
+{% for o in generator.all %}
+    "{{ o.camel }}": [
+	{% for f in o.refs %}"{{ f.camel }}",
+	{% endfor %}]
+{% endfor %}
+}
+
diff --git a/planetstack/apigen/dot.template.dot b/planetstack/apigen/dot.template.dot
new file mode 100755
index 0000000..eade386
--- /dev/null
+++ b/planetstack/apigen/dot.template.dot
@@ -0,0 +1,7 @@
+digraph plstack {
+{% for o in generator.all %}
+{% for f in o.refs %}
+  "{{ o.camel }}"->"{{ f.camel }}";
+{% endfor %}
+{% endfor %}
+}
diff --git a/planetstack/apigen/modelgen b/planetstack/apigen/modelgen
new file mode 100755
index 0000000..4c8a0f1
--- /dev/null
+++ b/planetstack/apigen/modelgen
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+
+import os
+import pdb
+import sys
+import json
+import re
+from django.template import Context, Template
+
+# Django set up
+
+sys.path.append('.')
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
+from django.db.models.fields.related import ForeignKey
+from core.models import *
+
+g = globals()
+
+def enum_classes():
+	model_classes = []
+	for c in g.values():
+		if type(c)==type(PlCoreBase):
+			model_classes.append(c)
+	return model_classes
+
+
+class GenObj(object):
+	def __str__(self):
+		return str(self.model.__name__.lower())
+
+	def __init__(self, m):
+		self.model = m
+		self.props = []
+		self.refs = []
+
+	def plural(self):
+		name = str(self)
+		if (name.endswith('s')):
+			return name+'es'
+		else:
+			return name+'s'
+
+	def camel(self):
+		name = str(self.model.__name__)
+		return name.title()
+		
+class Generator(dict):
+	def all(self):
+		return self.values()
+	
+	def regex(self, r):
+		filtered = filter(lambda o:re.match(r,str(o)), self.values())
+		return filtered
+
+	def add_object(self, o):
+		obj = GenObj(o)
+		fields = o._meta.fields
+		self[str(obj).lower()]=obj
+
+	def compute_links(self):
+		for obj in self.values():
+			fields = obj.model._meta.fields
+			for f in fields:
+				if type(f)==ForeignKey and f.name in self.keys():
+					refobj = self[f.name]
+					obj.refs.append(refobj)
+				else:
+					obj.props.append(f.name)
+			
+def main():
+	try:
+		output = sys.argv[1]
+	except:
+		print 'Usage: modelgen <output template>'
+		exit(1)
+
+	generator = Generator()
+
+	models = enum_classes()
+
+	for m in models:
+		generator.add_object(m)
+
+	generator.compute_links()
+	template_contents = open(output).read()
+	template = Template(template_contents)
+	context = Context({'generator':generator})
+	print template.render(context)
+
+
+if (__name__=='__main__'):
+	main()
diff --git a/planetstack/apigen/simple.template.txt b/planetstack/apigen/simple.template.txt
new file mode 100644
index 0000000..109927e
--- /dev/null
+++ b/planetstack/apigen/simple.template.txt
@@ -0,0 +1,8 @@
+{% for object in generator.all %}
+Object {{ object }}:
+Refs:
+{% for ref in object.refs %}{{ ref }}{% endfor %}
+Props:
+{% for prop in object.props %}{{ prop }}
+{% endfor %}
+{% endfor %}