Official Content

FestivalTickets is a Web application that allows participants to register for events. 

A key characteristic of this system is that it must be able to handle massive numbers of users, scaling properly for 1 user as well as for millions of users. In addition, this system must be deployed in the Cloud, using the Cloud services provided for maximum scalability at the lowest possible cost. 

BigBearFestival

In this example, you can see an application with an architecture that involves multiple components, the GeneXus model to generate those software elements, and the code that was written to create the infrastructure on which the application runs.

The architecture of the application obtained has the following components:

  • Single-page application (SPA) hosted on a serverless environment (Amazon S3/Azure Storage)
  • Functions running on a serverless, event-driven compute service (AWS Lambda/Azure Functions), served through an API gateway (Amazon API Gateway/Azure API Management)
  • Message Queues on a serverless service bus (Amazon SQS/Azure Storage Queue)
  • Data stored depending on its nature and purpose in a:
    • Key-value NoSQL database service (Amazon DynamoDB/Azure CosmosDB)
    • Serverless object storage service (Amazon S3/Azure Storage)
    • Relational database service (MySQL on Amazon RDS/Azure SQL Server)

In this first version of the sample, the SPA was generated with Angular, and the rest using the Java Generator; everything runs on Amazon WebServices (AWS) and Azure.

Live demo, etc.

Demo: https://youtu.be/D2kk6bItomM (Spanish audio)
KB Tour: https://youtu.be/zN-zDWkKzAk (Spanish audio)
AWS step by step setup: https://youtu.be/ad3miX9pd84 
Azure step by step setup: https://youtu.be/oE2s2tLXiJI

Angular App
Amazon AWS: https://d3fleuy2n9drfh.cloudfront.net
Azure: https://devftcdnendpoint.azureedge.net

Note: FestivalTicketsHome is the Main Object for Angular. BOHome is the Main Object of the backoffice.

Architecture

Since it is a highly scalable application, it was decided to use a serverless solution similar to the one used in the “Coronavirus UY” app.

Amazon AWS

image_202272914238_1_png

Microsoft Azure

festivaltickets-azure-arq_png

Why Serverless?

Because it allows us to scale the computation indefinitely through the AWS Lambda or Azure Functions, paying only for what is used. If there are no requests, the cost is 0. It also allows us to use services managed by the cloud, which don't require intervention from our team.

The solution has the following features:

  • Frontend (HTML/JS/CSS)
    • Generated in Angular and stored cloud storage ( AWS Amazon S3/Azure Storage). 
  • Frontend services backend
    • Angular App services are hosted on AWS (Lambda using API Gateway as API Mediator) or Azure (Azure Functions and API Management). Generated using Java technology. 

Data reading is performed against a non-relational database (Amazon DynamoDB/Azure Cosmos DB)

Why cloud non-relational database?

Because it allows us to scale indefinitely in terms of data storage. 

As for writing, when a ticket is created, it is sent to a message queue ( Amazon SQS/Azure Srorage Queue), and in this way the response is immediate. This message queue will be automatically processed by a function (AWS Lambda or Azure Function) called "ProcessTicketQueue." It will store the tickets in non-relational db and MySQL.

The draw is performed by another function (AWS Lambda or Azure Function) function called "ProcessTicketRaffle" of timer type that checks periodically if there is a closed event. When it finds a closed event, it performs the ticket drawing, assigns the winning tickets, and ends the event.

The services used for storage, queue, backend and process and non-relational database services are serverless by definition. For this reason, it is not necessary to manage servers and the application will have a predictable performance, for any number of users.

Source code and requirements

Design

Small: https://share.goabstract.com/b154a720-265a-43c2-8f56-192fc19ef3a7
Large: https://share.goabstract.com/6e222c39-755f-497c-af22-d397c5ea25d6

Sketch file: It is the 'ScalabilitySample_gxsketch' File object in the KB.

KB

GXServer: http://samples.genexusserver.com/beta
KB: FestivalTicketsKB
License: Apache License 2.0

Requirements

GeneXus 18 Upgrade 3

Angular Generator requirements.

Amazon AWS

Microsoft Azure

Steps to run the application

  • Create KB from Server
  • In Frontend, select Angular in Main Platform and set "FestivalTicketsHome" as main object
  • Create the necessary infrastructure in AWS/Azure (described below) and set the following properties in the KB
  • Rebuild All

Infrastructure as Code (IaC)

To make it easier to build the necessary infrastructure in production, the infrastructure is created from code (IaC).

GitHub repository: https://github.com/genexuslabs/FestivalTickets

In the repository, you can find the requirements and steps needed to create the infrastructure. At the end of this process, the necessary data will be returned to fully configure the KB.

Amazon AWS

For AWS, an AWS CDK project was created to handle this task, generating and executing a CloudFormation Stack.

Notes:

  • Endpoint and credentials for database access
    • To do so, access Secrets Manager in the AWS console
       There you will find the generated user and password
  • DynamoDB datastore user ID and password
    • This is returned after the infrastructure is created
    • If using other aws region than us-east-1, please add "Additional connection string attributes": region=us-west-1
  • AWS SQS Queue Connection Information
    • Set EnvironmentVariable: GX_FESTIVALTICKETS_QUEUEURL with the QueueURL provided by the CDK. Or just change it in Procedure: 'BusinessLogic.SQSUrlGet'. 

The deployment will be performed as follows with each deployment unit:

  • ProcessTicketQueue
    • Target: AWS Lambda Functions
    • Trigger Type: Queue
  • TicketRaffle
    • Target: AWS Lambda Functions
    • Trigger Type: Timer
  • App
    • Target: Static Front end
  • App
    • Target: AWS Serverless Deploy (backend services)
  • Backoffice
    • It will be possible to select Beanstalk or another such as Docker or EC2 instance

Azure

For Azure, the infrastructure is created using Terraform.

The deployment will be performed as follows with each deployment unit:

  • ProcessTicketQueue
    • Target: MicrosoftAzureFunctions
    • Trigger Type: Queue
  • TicketRaffle
    • Target: MicrosoftAzureFunctions
    • Trigger Type: Timer
  • App
    • Target: Static Front end
  • App
    • Target: Microsoft Azure Serverless (backend services)
  • Backoffice
    • It will be possible to select WebApp or Docker

Development process

Several features and criteria of the development process are highlighted below.

Import from Sketch

The design was made in Sketch and then imported into the GeneXus KB through the Design Import option.

Once imported from Sketch, some minor adjustments were made to the layouts to achieve maximum consistency in each layout.
The import from Sketch functionality allowed the development process to be more focused on the business logic.

Development with a coding standard

It was originally developed in GeneXus 17 Beta following the GeneXus Development Guide to create consistent, high-quality code.

StoneFramework Community

The StoneFramework Community Edition module, developed by Daniel Monza, was included because it provides procedures, user controls, and data patterns commonly used in systems.

Unit testing

The example has unit tests to certify the drawing. They can be reviewed in the “MakeWinnersUnitTest” object.

UI tests

A UI test called "FrontendTest" was developed to test the entire ticket creation cycle. It runs through the registration and status check for the created ticket.


Subscribe to KB feed
KnowledgeBase
GeneXus Server URL here
No news available on this feed
Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant