Skip to content

bcattle/cheesegrate

Repository files navigation

cheesegrate

Cheesegrate is a centralized place to model the data in your application, and generate a variety of representations of it. Model once, use often.

Picture an iOS app backed by an a Java backend, persisting to Cassandra.

You model your data, something like

class User(BaseModel):
    name = StringField()
    is_followed = BooleanField()
    profile_pic_small = UrlField()

From this data model, you could

  1. Generate Objective-C data model classes that use Mantle
  2. Generate Java (POJO) data model classes for use in the backend
  3. Generate JSON fixtures, populated with random or sequential data using a rich Factory syntax
  4. Generate Gatling Scala scripts that exercise the app's REST endpoints
  5. Generate unit tests that verify HTTP authentication/authorization rules are working
  6. Generate a Objective-C data controller that exercises the REST, exposing methods like [dataController getUsersWithSuccessHandler:^{ ... }];
  7. Generate Java validation code using XXX
  8. Generate Cassandra CQL commands to build the database schema
  9. Define denormalized data "views" of the data in the datastore. For example imagine two tables, "users by ID" and "users by timestamp".
  10. Data views need to be synchronized in schema and data. Persisting a single User object should automatically update "users by ID" and "users by timestamp". Generate the code to make this happen.
  11. Generate URL routes for the backend
  12. Generate HTML documentation of the HTTP API, database schemas, and Objective-C models and data controller

Data model

class User(BaseModel):
    name = StringField()
    is_followed = BooleanField()
    profile_pic_small = UrlField()

Fields

  • UIntField
  • FloatField
  • StringField
  • BooleanField
  • UrlField
  • EnumField
  • DateField
  • GUIDField

Reference fields

  • EmbeddedField
  • ArrayField

Factories

Something like

class UserFactory(Factory):
    name = IndexedChoiceField(sequence=user_names_and_pics, seq_index=0)
    profile_pic_small = IndexedChoiceField(sequence=user_names_and_pics, seq_index=1)
    is_followed = RandomBooleanField()

Fields

  • ChoiceField
  • IndexedChoiceField
  • RandomBooleanField
  • RandomIntField
  • RandomFloatField
  • DateNowUTCField
  • RandomGuidField
  • ArrayOfModelsField

Adapters

Classes that describe how to convert

  • data model -> Objective-C model class
  • data model -> Java model (POJO)
  • data model -> Cassandra CQL

etc.

About

An data-modelling framework and DSL for generating tasty slices in various places across your app stack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages