Poll is a web application that presents site visitors with a simple single question survey.
The software in this repository was used to quickly build and release an application with just enough features for a Minimum Viable Product (MVP).
I used it to run a short-lived survey for a small virtual monthly public speaking meeting I co-host called Beyond Soft Talk (BSG).
When a user initially visits the site, they are presented with the following "Welcome" page:
After making their selections and hitting the submit button (not pictured) users are redirected to the following "Thank You" page:
The core design constraint of this project requires that the system be Cloud/Deployment environment agnostic.
Anyone could easily fork this code and deploy it to an on-premises or cloud environment without having to redesign or rewrite the application.
I also wanted to avoid introducing extra third-party dependencies on popular No-Code Form Builders such as SurveyMonkey, Cognito Forms, and Google Forms.
- Java 17
- Modern Vanilla JavaScript - runs in any ES6+ web browser
- Spring Boot 3.0+
- ThymeLeaf Java template engine
- MDBootstrap
- MongoDB Atlas NoSQL document database - to store survey results
- Gradle 7.6
This section of the guide is written for a developer interested in cloning this repository to modify it or deploy it as-is to their own environment. To use it, a basic knowledge of MongoDB Cloud Atlas db administration is required
- Setting up an account
- Creating the required database (answers0)
- Extracting the correct connection string to use from Spring
If you are interested in additional details on these prereqs ask -- I'm happy to provide them.
Any cloud provider can be used (AWS, Azure, Heroku, GCP).
For its ease of use and ability to scale from 0 to n instances as needed on demand I chose Google Cloud Platform App Engine.
The following steps can be run from a Unix-based Terminal. I'm using bash
as my shell in the samples below.
Following these steps, keeps development costs down, as we essentially assemble the binary artifacts GCP requires for execution in an APP ENGINE environment ahead of time (on a local development or build server). It also allows the application to be spun up only when users clicked a link shared with them via email.
- Create a GCP cloud account
- Follow Google's online guide to download + install the
gcloud
CLI
ℹ️ Note: Make sure you have the recommended version of Python installed locally as outlined in the docs - Use git to clone this repositories main branch
- Change directories to the top-level directory of the poll project
cd $projectDir
- Set the APP_MONGODB_CONN environment variable to the value consistent with your MONGODB Cloud Atlas cluster
- Use the Gradle wrapper to run the bootJar task
./gradlew bootJar
ℹ️ Note: An executable jar file will be assembled and generated to$projectDir/build/libs
- Use the Gradle wrapper to run the custom generateAppYaml task
./gradlew generateAppYaml
ℹ️ Note: An updatedapp.yaml
that contains the value ofAPP_MONGODB_CONN
will be generated to$projectDir/build/libs
cd $projectDir/build/libs
- Run
gcloud app deploy ./poll-0.0.3-SNAPSHOT.jar --appyaml=./app.yaml
ℹ️ Note: If deployment succeeds, GCP App Engine will share the URL of your running application with you in the console
-
At this time, it is a heavy lift to design, add or display alternate questions. To make this single-question poll survey reusable in other contexts, a configurable question provider would be a great feature to have.
ℹ️ Note: See GitHub issue #2 for further details. -
Deployment instructions (for additional cloud platforms) and automated steps to provision any required infrastructure (including the MongoDB Atlas database) would also be a nice-to-have.
-
The survey works best on desktop/laptop systems or tablets with larger screen sizes. On Mobile, we do use some of MDBootstraps built-in breakpoints to adjust positioning of text boxes (based on screen size), but the available dates table uses the "table-responsive" CSS class. This allows the content to be viewable using a horizontal scrollbar. An alternate UX design optimized for smaller screen sizes that avoids scrolling would be a future nice-to-have.
Creating new opportunities for innovation and collaboration is what make open source software special.
If you would like to use this code in a derived work of your own, please fork the repository.
If you have any changes you would like to potentially contribute back simply create a pull request.
Thanks!
Copyright (c) 2023 Tony Castrogiovanni