Malagu is a third-party development tool, for which Tencent Cloud cannot provide official support at the moment. If you have any questions or feedback, you are welcome to visit the Malagu Community to discuss or contribute to the community through issues.
What is Malagu?
Aka the M framework, Malagu is a serverless-first, componentized, platform-independent progressive application framework based on TypeScript. It uses the same programming language and IoC design to develop frontend, backend, and frontend/backend integrated applications. It combines object-oriented programming (OOP), aspect-oriented programming (AOP), and other elements and draws on many design ideas of Spring Boot.
On the backend, Malagu abstracts a set of APIs to facilitate adaptation to any platforms (SCF, AWS Lambda, Vercel, etc.) and basic frameworks (Express, Koa, Fastify, etc.). It is an upper-layer framework independent of such platforms and basic frameworks.
In serverless scenarios, Malagu is used to develop projects by application. An application generally includes multiple APIs. If the application is large, it should be split into small microapplications or microservices. Just like the principle of granularity breakdown in the microservice architecture, reasonable granularity breakdown enables better application management. The framework will guarantee the execution performance of one application in one function.
Serverless is a new-generation cloud computing engine. It is developed to replace the traditional cloud service framework. The core idea of serverless is to enable developers to focus on the business code with no need to care about servers.
Serverless status quo
Currently, all cloud vendors and communities are vigorously promoting and preaching the Serverless concept. Through Serverless, business solutions can be implemented quickly, at a low cost and high quality. The industry generally believes that Serverless = FaaS + BaaS, and in the future, it may take other forms. Regardless of how the form changes, the core concept of Serverless remains the same. The key to the development experience of Serverless lies in the development experience of FaaS. However, the current development experience of FaaS is not ideal and has many pain points. Some of these pain points may be difficult to solve in the short term at the FaaS base level, while others may be more reasonable to solve at the tool and framework level. For example, cold start, CICD, microservices, database access, local development debugging and running, platform non-locking, etc. In the future, there will be more and more Serverless First development frameworks, not just resource orchestration operation and maintenance tools. These will be combined with Serverless First development frameworks to provide more advanced Serverless development platforms or low-code platforms.
How do we address these challenges?
We can take a different approach and try to solve these problems from the development framework level (as it turns out, these problems can be solved through the development framework). So, the new choice is whether to adopt a traditional framework or need a completely new one? If we choose to create a new framework, should we choose a specific programming language or a general-purpose one?
Why a new framework?
While developers can generally accept the development experience of traditional frameworks that have been used for many years, applications developed with traditional frameworks often encounter various difficult problems when migrating to a Serverless environment. These problems are often closely related to the underlying design of the framework. Although some issues can be resolved or mitigated through the framework's extension capabilities, the practical result is that the threshold for framework modification is high, the effect is not ideal, and it requires hacking, which is not elegant.
When you use a traditional framework in Serverless, you may feel that although the application can run, you may have concerns when it is truly applied to the production level. Of course, with the continuous development of the underlying technology of the Serverless platform, the situation of traditional frameworks in Serverless scenarios will also be greatly improved. To achieve the best state, unilateral changes are often not enough, and the framework also needs to reasonably adapt to Serverless scenarios. Just like the frontend UI framework needs Mobile First, the browser provides responsive support, and the frontend UI framework provides relevant adaptation. Therefore, we need a brand new, Serverless First development framework to greatly leverage the advantages of Serverless and make the Serverless development experience inherit and even surpass the traditional development experience.
Why a specific programming language?
Currently, there are many language-independent Serverless tools or frameworks in the open-source community, such as Funcraft, Serverless Cloud Framework, Vercel, etc. These general-purpose language Serverless tools can indeed provide a good experience at the operational level and can form universal standards. However, the development experience in application code development, debugging, and running may not be ideal. Each programming language has its unique aspects in development, debugging, and running, and it is difficult for general-purpose language Serverless tools to achieve a unified development experience while still being very good. Only by choosing a specific programming language can the experience of development, debugging, and running be maximized.
Why TypeScript?
Serverless makes it much easier to get started with backend development and greatly reduces the learning costs for frontend developers to develop backend applications based on serverless. In the future, more and more frontend developers will become full-stack developers. TypeScript can be used to develop both frontend and backend applications, so it is very friendly to frontend and full-stack developers.
Frontend architecture is a kind of Serverless architecture. For instance, the frontend browser needs to load frontend code for execution, and the Serverless scenario also needs to load user code for execution. Therefore, many frontend solutions are naturally suitable for Serverless scenarios. For example, the frontend reduces code volume and decreases code deployment and cold start time through packaging, compression, and Tree Shaking. Similarly, this optimization solution is also applicable to Serverless scenarios. Therefore, choosing TypeScript is equivalent to directly owning ready-made solutions that have been polished by countless real scenarios.
In addition, TypeScript is very close to Java, so Java developers can easily switch to the TypeScript technology stack.
Value of Malagu
Malagu is a serverless-first, extensible, componentized progressive application framework based on TypeScript. It shields the underlying details of different serverless platforms and most of the challenges in serverless scenarios. It is developed and improved based on real business scenarios and provides solutions usable at the production level. Moreover, it offers multi-cloud vendor-independent solutions.
How to Use Malagu
The Malagu framework consists of a series of components, each of which is a node module. You can choose the appropriate components according to your business scenario. You can also develop your own components based on the component mechanism. For the convenience of fast development, Malagu provides a command line tool that has built-in out-of-the-box templates for different use cases. You can quickly create your applications through the command line tool.
1. Run the following command to install the command line tool.
npm install -g @malagu/cli
2. Initialize a project.
malagu init project-name
cd project-name # Enter the root directory of the project
3. Run tests locally.
malagu serve # Start the application, default port is 3000
4. Open a browser and access http://localhost:3000/.