This project is to illustrate mvvm architecture in various frontend frameworks.
Run the following command:
npx create-turbo@latestThis Turborepo includes the following packages/apps:
docs: a Next.js appweb: another Next.js appmvvm-angular: an Angular app demonstrating MVVMmvvm-react: a React app demonstrating MVVMmvvm-vue: a Vue.js app demonstrating MVVM@repo/ui: a stub React component library shared by bothwebanddocsapplications@repo/eslint-config:eslintconfigurations (includeseslint-config-nextandeslint-config-prettier)@repo/typescript-config:tsconfig.jsons used throughout the monorepopackages/models: contains the data models for the applicationspackages/view-models: contains the view models for the applications
Each package/app is 100% TypeScript.
This project utilizes the Model-View-ViewModel (MVVM) architecture to structure its frontend applications. This architectural pattern helps in separating the user interface (View) from the business logic and data (Model) through an intermediary layer called the ViewModel.
- Model: Represents the data and business logic of the application. In this project, the data models are located in the
packages/modelsdirectory. - View: Represents the UI elements that the user interacts with. The
mvvm-angular,mvvm-react, andmvvm-vueapps contain the Views for their respective frameworks. - ViewModel: Acts as a bridge between the View and the Model. It prepares data from the Model in a way that is easily consumable by the View and handles user interactions from the View. The ViewModels are located in the
packages/view-modelsdirectory.
This separation of concerns offers several benefits:
- Improved Code Organization: Code is more structured and easier to understand.
- Enhanced Testability: Business logic in the ViewModel can be tested independently of the UI.
- Better Reusability: Models and ViewModels can potentially be shared across different Views or even different UI frameworks.
This architecture is leveraged by the following applications in this monorepo:
apps/mvvm-angularapps/mvvm-reactapps/mvvm-vue
These applications demonstrate how common Models and ViewModels can be used to provide data and state management to different frontend technologies.
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
To build all apps and packages, run the following command:
cd my-turborepo
pnpm build
To develop all apps and packages, run the following command:
cd my-turborepo
pnpm dev
Tip
Vercel Remote Cache is free for all plans. Get started today at vercel.com.
Turborepo can use a technique known as Remote Caching to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can create one, then enter the following commands:
cd my-turborepo
npx turbo login
This will authenticate the Turborepo CLI with your Vercel account.
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
npx turbo link
Learn more about the power of Turborepo: