{"pageProps":{"error":null,"preview":false,"file":{"sha":"","fileRelativePath":"content/tina-cloud/docs/introduction/architecting-with-tina-cloud.md","data":{"frontmatter":{"title":"Architecting with Tina Cloud","id":"/tina-cloud/docs/introduction/architecting-with-tina-cloud","prev":"/tina-cloud/docs/index","next":"/tina-cloud/docs/introduction/tina-cloud-tina-cms"},"excerpt":" When architecting your site with Tina Cloud, the \"MVVM pattern\" (Model, View, View-Model) can be a good way to think of its implementation. Models A content model groups together fields for a given…","markdownBody":"\nWhen architecting your site with Tina Cloud, the \"MVVM pattern\" (Model, View, View-Model) can be a good way to think of its implementation.\n\n## Models\n\nA content model groups together fields for a given entity. In Tina Cloud, your content models are stored in your `.tina/templates` directory.\n\n```yml\n# .tina/front_matter/templates/hero.yml\n---\nlabel: Hero\nfields:\n - name: id\n type: text\n label: Id\n - name: heading\n type: text\n label: Heading\n - name: message\n type: text\n label: Message\n```\n\n## View Models\n\nWhen you request content for a page, you do so by providing a query to the client:\n\n```js\nconst content = await client.requestWithForm(\n gql => gql`\n query ContentQuery($section: String!,\n $relativePath: String!) {\n getDocument(section: $section, relativePath: $relativePath) {\n hero: {\n heading\n message\n }\n }\n }\n `,\n {\n variables: {\n section: 'pages',\n relativePath: 'home.md',\n slug: ['/'],\n },\n }\n)\n\nconst hero = content.getDocument.data.hero\n// ...\n```\n\nIn this example, the \"hero\" object that the client returns can be thought of as your “view-model”, and will contain a subset of fields from your model.\n\n## Views\n\nThe \"view\" is what the user sees when they navigate to your site. Views dictate how your content is rendered on the screen.\n\n```jsx\nexport const Hero = styled(({ heroProps }) => {\n return (\n
{heroProps.message}
\n