📋 What Is DSL? (Dynamic Scripting Language)

Understanding how this application is built


The Big Picture

This application works in a simple cycle:

1. Define Your Data Model
         ↓
   (How should data be organized?)
         ↓
2. Application is Built Automatically
         ↓
   (Code is generated from the definition)
         ↓
3. You Get a Complete Web Application
         ↓
   (Tables, forms, navigation, everything)

DSL is the language used in step 1.


What Is DSL?

DSL = Dynamic Scripting Language

It's a simple text format for describing how your data should be organized.

Instead of writing complicated code, you describe: - What data you want to collect - What pieces of information each record has - How records connect to each other

Example DSL (simple format):

Table: Company
  - id (primary key)
  - name (text)
  - founded_date (date)

Table: Employee
  - id (primary key)
  - name (text)
  - email (email)
  - company_id (foreign key → Company)

Translation: "We have companies and employees. Each employee works for one company."


How It Works

1. Someone Defines the Data Model

A developer or administrator writes DSL that describes your data:

Table: Product
  - id
  - name
  - price
  - stock

Table: Order
  - id
  - product_id
  - quantity
  - customer_name

2. The Application Generator Reads It

A tool reads the DSL and understands:

✓ We need a "Product" table with 4 fields
✓ We need an "Order" table with 4 fields
✓ Orders are connected to Products

3. It Generates Everything

The tool automatically creates:

  • Database structure (where data is stored)
  • Models (Python code that represents the data)
  • Forms (where users enter data)
  • Tables (where data is displayed)
  • Navigation (menu to access everything)

4. You Get a Working Application

You now have a complete web application with:

  • ✅ Ability to add records
  • ✅ Ability to edit records
  • ✅ Ability to delete records
  • ✅ Ability to view all records
  • ✅ Ability to search records
  • ✅ Forms that validate your input
  • ✅ Navigation showing relationships

All from a simple text description.


Why Is This Useful?

Without DSL (Traditional Way)

A developer would need to write: - Database setup code - Python models - Web forms - HTML templates - Navigation code - Validation rules - Error handling

Weeks of work

With DSL (This Way)

You write: - A text description of your data

Minutes of work

The application is built automatically.


What's in a DSL Definition?

Tables

A table is a collection of related records.

Table: Customer

This says: "We want to store customers."

Fields

Fields are pieces of information about each record.

Table: Customer
  - id (number, uniquely identifies each customer)
  - name (text, the customer's name)
  - email (email address)
  - phone (phone number)
  - created_date (when the customer was added)

Each customer has these 5 pieces of information.

Field Types

Different types of information need different field types:

  • Text — Names, descriptions, anything written
  • Number — Quantities, prices, ages
  • Date — When something happened
  • Email — Email addresses (automatically validated)
  • Boolean — Yes/no, true/false
  • Foreign Key — Connection to another table

Relationships

Records in different tables can be connected.

Table: Order
  - id
  - product_id (foreign key → Product)
  - customer_id (foreign key → Customer)

Translation: "Each order is connected to a product and a customer."

This creates the hierarchical navigation you saw earlier:

Customer (parent)
  └─ Order (child)
      └─ Product (grandchild)

Example: Building a Simple App

Step 1: Define the Data

Table: Book
  - id (primary key)
  - title (text)
  - author (text)
  - isbn (text, unique)
  - published_date (date)

Table: Review
  - id (primary key)
  - book_id (foreign key → Book)
  - reviewer_name (text)
  - rating (number 1-5)
  - review_text (long text)

Meaning: "We have books. People can write reviews for books. Each review is connected to one book."


Step 2: Generator Creates Application

The tool automatically creates:

  • ✅ Book table in database
  • ✅ Review table in database
  • ✅ Form to add books
  • ✅ Form to add reviews (connected to a book)
  • ✅ Table showing all books
  • ✅ Table showing reviews for each book
  • ✅ Search functionality
  • ✅ Edit and delete actions (via each table's ☰ Actions menu)

Step 3: You Get This Application

When you open the app, you see:

  • Menu with options to view Books or Reviews
  • Click a book → see all reviews for that book
  • Click "Add Review" → new review connects to that book
  • Click "Edit" → update book information
  • Click "Delete" → remove book (reviews automatically handled)

All without writing any code.


The Magic: Automatic Generation

Once DSL is defined, the tool generates:

1. Database Schema

CREATE TABLE Book (
  id INTEGER PRIMARY KEY,
  title TEXT,
  author TEXT,
  isbn TEXT UNIQUE,
  published_date DATE
);

CREATE TABLE Review (
  id INTEGER PRIMARY KEY,
  book_id INTEGER FOREIGN KEY,
  reviewer_name TEXT,
  rating INTEGER,
  review_text TEXT
);

2. Python Models

class Book:
  id
  title
  author
  isbn
  published_date

class Review:
  id
  book_id
  reviewer_name
  rating
  review_text

3. Web Forms

Add Book Form:
  Title: [_____]
  Author: [_____]
  ISBN: [_____]
  Published Date: [📅____]
  [Save] [Cancel]

4. HTML Tables

Books:
  ID | Title | Author | ISBN | Date
  1  | Book1 | Auth1  | 123  | 2020
  2  | Book2 | Auth2  | 456  | 2021

5. Navigation Menu

- Books
- Reviews

Key Concepts

Primary Key

A field that uniquely identifies each record (no two records can have the same ID)

Foreign Key

A field that connects to another table (says which parent this child belongs to)

Unique

A field where every value must be different (like ISBN for books)

Required vs. Optional

Some fields must have a value, others can be empty

Data Type

What kind of information goes in the field (text, number, date, etc.)

What You Need to Know

As an end user, you don't need to understand DSL. You just need to know:

  • Tables organize different types of data
  • Fields are pieces of information
  • Relationships connect records from different tables
  • Hierarchies show which records belong to which

The application was built from a DSL definition, but you just use it like any other web application.


Next Steps


Key Takeaway: DSL is a simple way to describe data. The application automatically builds everything from that description. You don't write code—you just describe what you need.