Skip to main content

Generator - The Pattern

Rocket Generator is a tool built using a 2nd generation pattern on top of AppSeed.

Here are the main improvements that makes the generator superior in most aspects:

Let's say a few words about each one.

Django Generator - UI Components


Slim-Fit Codebase

The AppSeed Generator provides all the features inside the starter and this makes the codebase FAT, sometimes with 500 files or more (up to 1k). From the user perspective, this might not be a problem but during the GitHub upload, the process sometimes gets canceled due to the overuse of GitHub API.

Rocket Generator uses a different pattern where all the features are libraries: UI Kits, and API Generator. The process simply executed the following steps:

  • Collects the user input
  • Injects the configuration for the UI
  • Generates the models using the definitions
  • Activate the API for selected models

With this new pattern, the most complex starter shouldn't have more than 100 files because the actual build happens on the user side during compilation.


UI (External Libraries)

All the UI kist integrated with the generator can be used by anyone outside the service. Here are the links:

When the user selects one kit/dashboard from the above list, the generator executes the same steps on the sample codebase as the ones listed on the README.

For instance, if the user selects Soft Dashboard, here are the steps executed by the generator:

  • Add django-admin-soft-dashboard as a dependency in requirements.txt
  • Update configuration->INSTALLED_APPS section:
    • Add admin_soft.apps.AdminSoftDashboardConfig
  • Update project routing
    • Add path('', include('admin_soft.urls')),

The above steps are executed by a custom parser that knows how to safely update the codebase, apply changes and keep the project compilable once the changes are operated.

Rocket Generator - UI Selector.


API Generator

For each defined model, the user has the option to activate an API node with full CRUD access:

  • GET requests are public (get All items, get item by ID)
  • Mutating Requests (CREATE, UPDATE, DELETE) requires authentication

This feature is provided via Django API Generator, an open-source library built on top of DRF.

Regarding the generator processing, here are the steps performed for models integration:

  • Add django-api-generator as a dependency in requirements.txt
  • Update configuration->INSTALLED_APPS section:
INSTALLED_APPS = [
'django_api_gen', # Django API GENERATOR # <-- NEW
'rest_framework', # Include DRF # <-- NEW
'rest_framework.authtoken', # Include DRF Auth # <-- NEW
]
  • Create new sections in the project settings
API_GENERATOR = {
'MODEL_API_PATH' : "MODEL_DEFINITION_PATH",
}

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
}

The most challenging part is to have a controlled injection for each model because the user can activate the API for a single model, all models, or none.

Rocket Generator - API Generator


Extended User Model

This feature is something that most of the Django Apps require at some point. To cover this point, the generator empowers the user to define a custom user model using a few defaults:

  • name
  • phone
  • bio

Note: The API generator option is not activated in the UI.

Rocket Generator - Extended User Model.


Models Editor

The users can edit and design their database via a simple UI. This is unsupported on AppSeed.

Rocket Generator - Models Editor


Deployment Ready

All starters generated with Docker support can be deployed via DeployPRO service using a simple flow:

  • Authenticate/register into DeployPRO
  • Connect your preferred cloud provider
  • Create a new VPS Server
    • this operation takes ~5min
  • Deploy the GitHub Repositor (needs ownership)

In less than 10 minutes, if the project has an usable Dockerfile, the project goes LIVE with an active Ci/CD flow.

Deployment Ready Starters via DeployPRO.


Resources