How to Make Production Ready Shiny Applications

Estimated time:

What defines a production-ready Shiny application? And more importantly, how do we get there? Shiny is hands down one of the best dev tools available for quick production of Proof of Concepts (PoC). But here in lies a trap. People tend to mislabel Shiny as a poor production tool because they fall for the PoC trap. They make something quickly and then fall short when attempting to finalize the product. <blockquote><strong>Build, style, and scale your Shiny application with <a href="" target="_blank" rel="noopener noreferrer">Appsilon's Shiny Masterclass</a></strong></blockquote> The video presentation below guides you through key steps that Appsilon Software Engineer, Marcin Dubel, takes whether assisting a client or building an award-winning app. Follow along and learn his definition of done and how to get there. <ul><li><a href="#anchor-1" target="_blank" rel="noopener noreferrer">Shepherding Your Shiny App from Proof of Concept to Production</a></li><li><a href="#anchor-2" target="_blank" rel="noopener noreferrer">Abstract</a></li><li><a href="#anchor-3" target="_blank" rel="noopener noreferrer">Lessons Learned</a></li><li><a href="#anchor-4" target="_blank" rel="noopener noreferrer">Need to Speed Up Production?</a></li></ul> <h2 id="anchor-1">Shepherding Your Shiny App from Proof of Concept to Production</h2> <iframe title="YouTube video player" src="" width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen"></iframe> <b><a href="" target="_blank" rel="noopener noreferrer">Marcin Dubel</a>, Software Engineer, </b><a href="" target="_blank" rel="noopener noreferrer"><b>Grand Prize Winner 2021 Shiny Contest</b></a> <h2 id="anchor-2">Abstract</h2> One advantage of Shiny applications is that a proof of concept can be created quickly and easily. It’s a great way for subject matter experts to present their ideas to stakeholders before moving on to production. But making the app production-ready might require help from experienced software developers. You can make more headway by focusing on two areas: user experience and future maintenance. This way, you’ll be sure that the app is scalable, performant, bug-free, extendable, and enjoyable. Close collaboration between engineers and experts paves the way to many successful projects in data science and is Appsilon’s tried-and-true path to production-ready solutions. The very first step should always be building a convenient and (importantly) reproducible workflow, so start by <b>setting up the development environment</b> and <b>organizing the folder structure </b>[renv + docker]. Once completed, engineers should limit the codebase by <b>cleaning the code ( </b>i.e., removing redundant comments, extracting the constants and inline styles [ymls + styler]). Now the real fun begins. Follow the steps below to make the most of it: <ol><li><b>Extract the business logic</b> into separate functions, modules, and classes [packages/R6 + plumber]. Restrict reactivity to a minimum.</li><li><b>Check the logic </b>[<a href="" target="_blank" rel="noopener noreferrer">data.validator</a> + drake].</li><li><b>Add tests </b>[testthat + cypress/shinytest].</li><li>Organize your /www and <b>move actions to the browser </b>[shiny + css/js].</li><li>Finally, <b>style the app </b>[sass/bslib + <a href="" target="_blank" rel="noopener noreferrer">shiny.fluent</a>].</li></ol> And, voila! A world-class Shiny app is ready to onboard users hungry for data-driven insights. <blockquote><strong>Try Marcin's award-winning game <a href="" target="_blank" rel="noopener noreferrer">Shark Attack!</a> and see how his methods make apps rise to the top!</strong></blockquote> <h2 id="anchor-3">Lessons Learned for Production-Ready Shiny Apps:</h2><ol><li>Code Sharing<ul><li>Do not store data files in the repo</li><li>Do not store credentials</li></ul></li><li>Development Environments<ul><li>Projects and relative paths</li><li>renv</li><li>Docker</li></ul></li><li>Code Structuring<ul><li>Use a package</li><li>Extract modules</li><li>R6 classes</li></ul></li><li>External Resources<ul><li>Do not use inline CSS/JS in R code!</li><li>Keep all dependencies in /www</li><li>Minified files</li><li>Extract block of texts to an external file</li></ul></li><li>Tests &amp; Continuous Integrations<ul><li>Start each project with CI and test structure</li><li>Use templates</li><li>Add tests incrementally</li></ul></li><li>Checking Business Logic<ul><li>Check business logic with {drake}</li><li>Check data with {<a href="" target="_blank" rel="noopener noreferrer">data.validator</a>}</li></ul></li><li>App Performance<ul><li>Data<ul><li>Load only the data you need</li><li>Efficient data libraries {fst}, {data.table}, {arrow}</li><li>Build API with {plumber}</li></ul></li><li>Code<ul><li>Keep calculations outside</li><li>Actions in the browser</li></ul></li><li>Deployment<ul><li>Deploy early</li><li>Prepare architecture for a number of concurrent users</li></ul></li></ul></li><li>App Styling and UX<ul><li>User adoption is key!</li><li>UX designer and mockups!</li><li>Collect feedback early and often</li></ul></li></ol> <blockquote><strong>Set your rules, create reproducible reports, and ensure quality <a href="" target="_blank" rel="noopener noreferrer">data validation with the data.validator package</a></strong></blockquote> <h2 id="anchor-4">Need to Speed Up Production?</h2> At Appsilon we have the skills to build world-class enterprise Shiny applications. Our team of software engineers, front-end developers, graphic designers, and business analysts can handle any development needs. From Proof of Concept to launch and maintenance, Appsilon can rapidly deliver R Shiny applications and solve your most challenging problems. <a href="" target="_blank" rel="noopener noreferrer"><img class="aligncenter wp-image-6697 size-medium" src="" alt="Software Quality / Focused Teamwork" width="600" height="450" /></a>

Contact us!
Damian's Avatar
Damian Rodziewicz
Head of Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Have questions or insights?
Engage with experts, share ideas and take your data journey to the next level!
Join Slack
Explore Possibilities

Take Your Business Further with Custom Data Solutions

Unlock the full potential of your enterprise with our data services, tailored to the unique needs of Fortune 500 companies. Elevate your strategy—connect with us today!

Talk to our Experts
shiny dashboards