ALGOHUB: a WEBSITE of ALGORITHMS a Project Presented to the Faculty of California State Polytechnic University, Pomona in Partia
Total Page:16
File Type:pdf, Size:1020Kb
ALGOHUB: A WEBSITE OF ALGORITHMS A Project Presented to the Faculty of California State Polytechnic University, Pomona In Partial Fulfillment Of the Requirements for the Degree Master of Science In Computer Science By Liang Zhang 2017 SIGNATURE PAGE PROJECT: ALGOHUB: A WEBSITE OF ALGORITHMS AUTHOR: Liang Zhang DATESUBMITTED: Fall 2017 Computer Science Department Dr. Gilbert S. Young Project Committee Chair Computer Science Dr. Hao Ji Computer Science ii ACKNOWLEDGEMENTS First, I would like to thank my wife, Yatong Liang, for her supporting not only on my study, but also in all aspects of my life. Thanks all the professors I have met in CalPoly Pomona, especially Dr. Young, and Dr. Ji, who taught me knowledge, tutored my research, and encouraged me overcoming the barricades. Last but not the least, thanks all the developers, who are contributing to the open source projects, for building so many wonderful software. Without your works, I couldn’t have finished my project. iii ABSTRACT In this project, a website (AlgoHub) is implemented, which mainly hosts contents of algorithms, such as title, algorithm description, applications, and so on. From the functionality perspective, modules like adding, modifying, searching, fulfills the requirements of different groups of users (students, teachers, software engineers, and etc.) who are interested in algorithms. From the technology perspective, the system architecture of AlgoHub is designed to achieve high performance and scalability according to the nature of this application. During the implementation, rather than building a website from scratch, many practically proved technologies and existing components, such as Jekyll, Jenkins, Git, and so on, are utilized after being carefully evaluated. iv TABLE OF CONTENTS SIGNATURE PAGE .......................................................................................................... ii ACKNOWLEDGEMENTS ............................................................................................... iii ABSTRACT ....................................................................................................................... iv LIST OF FIGURES .......................................................................................................... vii CHAPTER 1: INTRODUCTION ....................................................................................... 1 CHAPTER 2: PRODUCT DESIGN ................................................................................... 3 2.1 Properties of an Algorithm .................................................................................... 3 2.2 Homepage ............................................................................................................. 4 2.3 View Algorithm Page ........................................................................................... 4 2.4 Add Algorithm Page ............................................................................................. 6 2.5 Edit Algorithm Page ............................................................................................. 8 2.6 Search Algorithm Page ......................................................................................... 8 CHAPTER 3: ENGINEERING DESIGN ........................................................................ 10 3.1 Manager .............................................................................................................. 13 3.2 Generator ............................................................................................................. 13 3.3 Searcher ............................................................................................................... 14 3.4 Infrastructure ....................................................................................................... 14 CHAPTER 4: TECHNOLOGIES ..................................................................................... 15 4.1 Event-based Programming .................................................................................. 15 4.2 Container ............................................................................................................. 21 4.3 CI/CD .................................................................................................................. 25 CHAPTER 5: CONCLUSION AND FUTURE WORKS ................................................ 29 REFERENCES ................................................................................................................. 31 v APPENDIX A: QUESTION IN CS530 ONLINE EXAM ............................................... 33 vi LIST OF FIGURES Figure 1:Homepage Mockup .............................................................................................. 4 Figure 2: View Algorithm Mockup .................................................................................... 5 Figure 3: Add Algorithm - Other steps ............................................................................... 6 Figure 4: Add Algorithm - Step 1 ....................................................................................... 6 Figure 5: Markdown editor UI (Simplemde) ...................................................................... 7 Figure 6: Embedded Search ................................................................................................ 9 Figure 7: AlgoHub System Architecture .......................................................................... 12 Figure 8: Blocking Execution ........................................................................................... 15 Figure 9: Non-blocking Execution .................................................................................... 16 Figure 10: A Use Case of Non-blocking ........................................................................... 16 Figure 11: Callback Hell ................................................................................................... 17 Figure 12: Promise in ES6 ................................................................................................ 18 Figure 13: Promise with Branch Statements ..................................................................... 19 Figure 14: Example of Async/Await ................................................................................ 20 Figure 15: Combine Await/Async with Promise .............................................................. 20 Figure 16: Processes of a Container and the Application Inside ...................................... 21 Figure 17: User Container as a Command Line Tool ....................................................... 22 Figure 18: Containers in Development Environment ....................................................... 22 Figure 19: A Simple Dockerfile ........................................................................................ 23 Figure 20: Command to Build an Image ........................................................................... 23 Figure 21: Command to Push an Image ............................................................................ 23 vii Figure 22: Docker Swarm Load Balance .......................................................................... 24 Figure 23: Commands to Control a Service ...................................................................... 25 Figure 24: Jenkinsfile for Manage Module ....................................................................... 26 Figure 25: Screenshot of Jenkins Pipeline Report ............................................................ 27 viii CHAPTER 1: INTRODUCTION In computer science, an algorithm is basically an instance of logic written in software by software developers to be effective for the intended “target” computer(s) to produce output from given (perhaps null) input [1]. People search online for an algorithm for interest more than in textbooks nowadays, thanks to the well-developed websites hosting rich content. Audience: Most people searching an algorithm have different purposes. Educators, such as professors in colleges, may be interested in some novel educating methods to effectively teach algorithms in their classes. Students may look for a course video to help refreshing their knowledge, find sample codes to help finishing their homework, or research on relevant algorithms to the ones learned in their classes to extend the scale of knowledge. Software engineers may look for algorithms to build their applications, or learn the practical implementation in a specific programming language. Why AlgoHub? A lot of websites are providing contents of algorithms, which include personal blogs, search engines and knowledge databases (Wikipedia is one of the most popular). Despite the large number of websites out there, we can still hardly find one specifically designed to fulfill the requirements of all of our audiences. In this project, a website (http://www.algohub.me) was implemented to host contents of algorithms. In the feature perspective, it was designed to satisfy the requirements of the audiences, who use the website for different purposes. In the technology perspective, some modern technologies were leveraged in this project, such as server-less, and event-based programming. Moreover, performance and scalability were also taken into account according to the nature of this application. 1 In the rest of the report, I will go through: product design, which explains the page layouts and interactions; engineering design, which covers the implementation details of the modules; technologies, which