Jiffy Development Steps

Jiffy Pre-Generation Workflow

Jiffy is intended to generate a clean, straight-forward and secure application services platform just like the one you would write by hand. Jiffy originally started as a few Go templates used to generate boiler-plate code that seemed onerous to type. Generation is a lot nicer than cut-and-paste. There are places in the generated code where things could be more elegant, but the code is intended to be easy to work on even if one is not familiar with it. File and folder names are somewhat subjective; an attempt has been made to be descriptive and organized.

Design Steps

  1. You are building a back-end of some sort where you need to reliably read and write data. Before you start building the ‘real’ Jiffy model of your application, try some of the demo models to get a feel for what Jiffy is and what it isn’t. It is a lot easier to design if you know what the platform provides and what it does not.

  2. Start messing around with entity ideas. What is the best way to represent your data? Transferring your ideas into a few rough diagrams often changes your understanding of what you are modeling.

  3. Consider the relationships you would like to have between your entities. Does your model still hold up?

  4. Add some detail to your proposed entities in terms of fields. Remember that Jiffy will insert a primary-key (id), as well as a self-referencing entity href into the model for you. This is important when you are considering relationships, as Jiffy applications have some expectations regarding the name of the referencing field. See the Entity Relations section of this documentation set for details.

  5. Once you are comfortable with the entities and the fields that they will contain, it is time to create the model in the Jiffy model file format.

  6. Jiffy model files are simple JSON and at the moment need to be coded up by hand. Taking a copy of one of the sample model-files is the best way to start. Short of creating a graphical model file generator, maintaining the models via direct file maintenance is the most direct and transparent way to edit them. Remember that you do not have to put your entire model in one file. Jiffy is quite happy to accept any number of model files for your project with the entities defined in any order. The generator will sort it all out.

  7. Check your model files as best as possible before feeding them into Jiffy. If you get an error, don’t worry; look at the error message, then check the model-file for problems. If you can’t see anything wrong, log an issue along with an example of the model-file that is causing the problem. Usual suspects for errors are missing double-quotes on field-names or string-values, missing closing parentheses on a list, missing brace on struct or sub-struct, putting quotes on a bool value, putting quotes on an int or dec value etc.

  8. Again, don’t worry too much about formal inter-entity rules in the beginning. The idea is to get something up and running quickly so you can try out the services. You can generate your application many times over without touching anything but the model-file / model-files. Generation is fast.

  9. Generate a version of your application and start it up. Try it out with a tool like Postman. See the Quickstart for an overview of application generation through to application testing, or go to the formal section dealing with each of the application creation steps.

  10. It is not (typically) necessary to do early development testing via https. If this is not the case for you, see the Testing with TLS section in this document set. Step-by-step instructions are given to create and install self-signed certificates that will permit you to test locally with https.

  11. As you test your application, you will probably see some fields missing, some fields that you don’t care for, and maybe the need for an additional entity. Update your model files and generate the application again. Try it out. Repeat.

  12. As your model becomes more refined, consider formally adding relationships. Generate, test, repeat.

  13. Consider foreign-keys. Generate, test, repeat.

  14. Consider start-values for id. Not everybody is okay to start at 1, particularly if you are planning on migrating existing data into your application. Generate and test.

  15. Consider static-queries and add the selection options to each field that can be queried. Generate, test, repeat. See the static query section for details.

  16. Consider indices and add indexes to the model definitions where needed. Generate, test, repeat.

  17. Access restrictions can be assigned at the end-point-level, and this is built into the generated application. Don’t worry about testing authorization and authentication for now.

Development

  1. When you are satisfied with your model, generate a version of the application and place it under source-code control.

  2. Implement extension-points in the controller and model go source as per your requirements. Implemented extension-points will not be over-written should you need to regenerate the application. Test often.

  3. Implement normalization and validation at the field-level in the generated entity model go source file. This part is slightly contentious, as field normalization and validation is performed directly in the generated code, rather than off to the side in extension-points. We suggest that if you are worried about over-writing your normalization and validation code with an accidental regeneration, you create a model_normalization package for each model and implement field-level normalizations and checks there. Of course, you are free to ignore the provided field-level normalization and validation methods and perform all checks in one of the model extension-points. Its up to you, and it will make more sense once you take a look through one of the generated files.

  4. When you are happy with the way things are working, think about user access. Sketch out user-groups and assign end-points to them until you have something that you like. Use Postman to create UserGroups and assign Auths to them, then create new users and allocate the relevant UserGroups to their ID. That is all you need to do; the Jiffy middleware will take care of the rest. See the Access Control section for a detailed discussion of how users are authenticated and authorized.

Deployment

Jiffy generated applications can be deployed in any number of ways. For example:

  • On your laptop
  • On a server under your desk
  • On a blade running the os of your choice. This is not entirely true anymore, as a bash shell is now required to build the Jiffy binary.
  • On a VM (xen etc.)
  • Docker image / Droplet / Cloud Foundry etc.
  • In a Kubernetes cluster
  • Across a collection of the above

At the software level, the Jiffy generated application can be deployed as:

  • A single environment hosting the DBMS and application
  • A single application instance talking to a database
  • Multiple application instances talking to a database

Considerations for deployment

  • SSL certificates - you will need them
  • Is there a need to support JWTs from JWT-capable Identity Providers in the existing deployment landscape? If so, their public-keys must be added to the production configuration file.
  • JWT expiration policy has been set correctly in the production configuration file?
  • You have tested your user-access revocation? Jiffy makes provisions for the revocation of user-access based on the user master. If a user is deleted or marked as inactive, even a valid JWT for that user will not permit access.
  • Data migration; have you run real test migrations with the key relationships etc. in place?
  • If you disabled certain database features for migration, have you turned them back on again? Looking at you foreign-keys…
  • User access; users have been assigned to Groups and the create/update/delete end-points have been secured in accordance with the known use-cases?
  • Is a reverse-proxy required and / or is there a need to route traffic based on expected load?
  • Service activations; is there a need to route traffic to specific application instances based on expected load?
  • Is there a documented strategy for scaling horizontally or vertically if required?
  • Backup and recovery strategy is in place and has been tested?