Learn how repositories isolate Prisma access and preserve portal boundaries.
SaaS Foundation uses the repository pattern for database access. Route handlers
and services call repository functions instead of writing Prisma queries
directly.
Repository per entity
A repository usually represents one entity or closely related set of queries.
Examples include user, organization, member, invitation, and API key
repositories.
Repositories keep Prisma details in one layer. A route can focus on the request
and business rules without also owning filtering, sorting, pagination, or
database query construction.
Preserve portal boundaries
Admin and customer repositories remain separate even when two functions happen
to look similar.
Admin repositories may perform platform-wide queries without implicit
organization scoping.
Customer repositories query data within the authenticated organization.
Auth repositories support authentication and invitation flows outside a
portal request.
This duplication is intentional. Combining an admin query and customer query
because they currently use similar Prisma code creates an easy path for
platform-wide access to leak into customer code later.
Scope customer queries
Customer repository functions that access organization-owned data receive the
authenticated organization ID. They include it in the database filter alongside
the requested record ID or other filters.
The withCustomer route wrapper reads the active organization from the session,
verifies the user’s membership, and passes the trusted organizationId into the
handler. The route then passes it to customer repositories.
Do not accept the tenant boundary from an untrusted request body. Use the
organization ID established by the authenticated customer context.
Keep responsibilities clear
Repositories perform data access. Route handlers remain responsible for request
validation, authorization, existence checks, and business rules unless a more
complex rule is deliberately extracted into a service or validator.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SaaS Foundation","colors":{"primary":"#00BBA7","light":"#2DD4BF","dark":"#009688"},"logo":{"light":"https://mintcdn.com/saas-foundation/dJicxZ4jiDWRUj6J/logo/light.svg?fit=max\u0026auto=format\u0026n=dJicxZ4jiDWRUj6J\u0026q=85\u0026s=1d07f7580933c97856f4f24b713ae15a","dark":"https://mintcdn.com/saas-foundation/dJicxZ4jiDWRUj6J/logo/dark.svg?fit=max\u0026auto=format\u0026n=dJicxZ4jiDWRUj6J\u0026q=85\u0026s=d81bdad74bb7ec594311b33ba8cd7919"},"favicon":"https://mintcdn.com/saas-foundation/JhKr0GZw0BQfPdTz/favicon.svg?fit=max\u0026auto=format\u0026n=JhKr0GZw0BQfPdTz\u0026q=85\u0026s=f547f5de13ee903bcd91294b02060cfa","navbar":{"links":[{"href":"https://saasfoundation.dev","label":"Website"},{"href":"/demo","label":"Live Demo"}],"primary":{"type":"button","label":"Github","href":"https://github.com/smaameri/saas-foundation"}},"footer":{"socials":{"website":"https://saasfoundation.dev","github":"https://github.com/smaameri/saas-foundation"}},"contextual":{"options":["copy"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"saas-foundation","hasAudioNarration":false,"actualSubdomain":"saas-foundation","customDomains":["docs.saasfoundation.dev"],"gitSource":{"type":"github","owner":"smaameri","repo":"saas-foundation-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ae95e058e1cea2a2a52a7eb:success","clientVersion":"0.0.4177","searchFilterCounts":[{"language":"default","tag":"Architecture","count":6},{"language":"default","tag":"Core concepts","count":4},{"language":"default","tag":"API","count":3},{"language":"default","tag":"Getting Started","count":3},{"language":"default","tag":"Configuration","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"autopilot-knowledge-base","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"architecture-repositories","slug":"/architecture-repositories","pageMetadata":{"title":"Repositories","description":"Learn how repositories isolate Prisma access and preserve portal boundaries.","href":"/architecture-repositories"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Learn how repositories isolate Prisma access and preserve portal boundaries.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`SaaS Foundation uses the repository pattern for database access. Route handlers\nand services call repository functions instead of writing Prisma queries\ndirectly.`}),`\n`,_jsx(Heading,{level:`2`,id:`repository-per-entity`,children:`Repository per entity`}),`\n`,_jsx(_components.p,{children:`A repository usually represents one entity or closely related set of queries.\nExamples include user, organization, member, invitation, and API key\nrepositories.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`13`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`src/repositories/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── admin/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├── organizationRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├── memberRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ └── userRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── customers/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├── organizationRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ ├── memberRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`│ └── userRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└── auth/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` ├── invitationRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └── userRepository.ts`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Repositories keep Prisma details in one layer. A route can focus on the request\nand business rules without also owning filtering, sorting, pagination, or\ndatabase query construction.`}),`\n`,_jsx(Heading,{level:`2`,id:`preserve-portal-boundaries`,children:`Preserve portal boundaries`}),`\n`,_jsx(_components.p,{children:`Admin and customer repositories remain separate even when two functions happen\nto look similar.`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Admin repositories`}),` may perform platform-wide queries without implicit\norganization scoping.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Customer repositories`}),` query data within the authenticated organization.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Auth repositories`}),` support authentication and invitation flows outside a\nportal request.`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`This duplication is intentional. Combining an admin query and customer query\nbecause they currently use similar Prisma code creates an easy path for\nplatform-wide access to leak into customer code later.`}),`\n`,_jsx(Heading,{level:`2`,id:`scope-customer-queries`,children:`Scope customer queries`}),`\n`,_jsx(_components.p,{children:`Customer repository functions that access organization-owned data receive the\nauthenticated organization ID. They include it in the database filter alongside\nthe requested record ID or other filters.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`listOrganizationMembers(organizationId, options)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`findOrganizationMember(organizationId, memberId)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`findOrganizationMemberByEmail(organizationId, email)`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`withCustomer`}),` route wrapper reads the active organization from the session,\nverifies the user’s membership, and passes the trusted `,_jsx(_components.code,{children:`organizationId`}),` into the\nhandler. The route then passes it to customer repositories.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Do not accept the tenant boundary from an untrusted request body. Use the\norganization ID established by the authenticated customer context.`})}),`\n`,_jsx(Heading,{level:`2`,id:`keep-responsibilities-clear`,children:`Keep responsibilities clear`}),`\n`,_jsx(_components.p,{children:`Repositories perform data access. Route handlers remain responsible for request\nvalidation, authorization, existence checks, and business rules unless a more\ncomplex rule is deliberately extracted into a service or validator.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Repositories","description":"Learn how repositories isolate Prisma access and preserve portal boundaries.","href":"/architecture-repositories"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Repository per entity","slug":"repository-per-entity","depth":2,"children":[]},{"title":"Preserve portal boundaries","slug":"preserve-portal-boundaries","depth":2,"children":[]},{"title":"Scope customer queries","slug":"scope-customer-queries","depth":2,"children":[]},{"title":"Keep responsibilities clear","slug":"keep-responsibilities-clear","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"saas-foundation","siteName":"SaaS Foundation","title":"Repositories - SaaS Foundation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-31T11:54:06.353Z","originalFileLocation":"architecture-repositories.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Learn how repositories isolate Prisma access and preserve portal boundaries.\">\u003cmeta data-mint-head name=\"application-name\" content=\"SaaS Foundation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Repositories - SaaS Foundation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Learn how repositories isolate Prisma access and preserve portal boundaries.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SaaS Foundation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.saasfoundation.dev/architecture-repositories\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://saas-foundation.mintlify.site/_mintlify/api/og/v2?division=Architecture\u0026amp;title=Repositories\u0026amp;description=Learn+how+repositories+isolate+Prisma+access+and+preserve+portal+boundaries.\u0026amp;theme=3f576feb8edadb8a1a156963\u0026amp;signature=1ad30dad9ae64b20c62624664563c1c7a7e5eaa4853d2656cd7299dd24a9cbea\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Repositories - SaaS Foundation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Learn how repositories isolate Prisma access and preserve portal boundaries.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://saas-foundation.mintlify.site/_mintlify/api/og/v2?division=Architecture\u0026amp;title=Repositories\u0026amp;description=Learn+how+repositories+isolate+Prisma+access+and+preserve+portal+boundaries.\u0026amp;theme=3f576feb8edadb8a1a156963\u0026amp;signature=1ad30dad9ae64b20c62624664563c1c7a7e5eaa4853d2656cd7299dd24a9cbea\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/saas-foundation/kJiezMLQHKGLE83m/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SaaS Foundation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#00BBA7\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.saasfoundation.dev/architecture-repositories\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/architecture-repositories.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.saasfoundation.dev/#organization\",\"name\":\"SaaS Foundation\",\"url\":\"https://docs.saasfoundation.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/saas-foundation/dJicxZ4jiDWRUj6J/logo/light.svg?fit=max\u0026auto=format\u0026n=dJicxZ4jiDWRUj6J\u0026q=85\u0026s=1d07f7580933c97856f4f24b713ae15a\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.saasfoundation.dev#website\",\"name\":\"SaaS Foundation\",\"url\":\"https://docs.saasfoundation.dev\",\"publisher\":{\"@id\":\"https://docs.saasfoundation.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.saasfoundation.dev/architecture-repositories#webpage\",\"url\":\"https://docs.saasfoundation.dev/architecture-repositories\",\"name\":\"Repositories\",\"description\":\"Learn how repositories isolate Prisma access and preserve portal boundaries.\",\"dateModified\":\"2026-07-31T11:54:06.353Z\",\"isPartOf\":{\"@id\":\"https://docs.saasfoundation.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.saasfoundation.dev/architecture-repositories#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.saasfoundation.dev/architecture-repositories#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Architecture\",\"item\":\"https://docs.saasfoundation.dev/architecture\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Repositories\",\"item\":\"https://docs.saasfoundation.dev/architecture-repositories\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.saasfoundation.dev/architecture-repositories#article\",\"headline\":\"Repositories\",\"name\":\"Repositories\",\"description\":\"Learn how repositories isolate Prisma access and preserve portal boundaries.\",\"url\":\"https://docs.saasfoundation.dev/architecture-repositories\",\"mainEntityOfPage\":{\"@id\":\"https://docs.saasfoundation.dev/architecture-repositories#webpage\"},\"dateModified\":\"2026-07-31T11:54:06.353Z\",\"publisher\":{\"@id\":\"https://docs.saasfoundation.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.saasfoundation.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SaaS Foundation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SaaS Foundation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/architecture-repositories.md","siteName":"SaaS Foundation","nav":{"global":null,"pages":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/index"},{"title":"Quickstart","href":"/quickstart"},{"title":"Live Demo","href":"/demo"}]},{"group":"Core concepts","pages":[{"title":"Portals","href":"/portals"},{"title":"Roles and permissions","href":"/roles-and-permissions"},{"title":"Authentication","href":"/authentication"},{"title":"Schema","href":"/schema"}]},{"group":"Architecture","pages":[{"title":"Architecture","description":"Understand the boundaries and request lifecycle used throughout SaaS Foundation.","href":"/architecture"},{"title":"Repositories","href":"/architecture-repositories"},{"title":"Validation","description":"Learn how SaaS Foundation validates requests and shares Zod schemas.","href":"/architecture-validation"},{"title":"Serialization","href":"/architecture-serialization"},{"title":"Coding agents","href":"/ai-assistance"},{"title":"Code quality","href":"/code-quality"}]},{"group":"API","pages":[{"title":"API architecture","href":"/architecture-api"},{"title":"Request handling","href":"/api-request-handling"},{"title":"API format","href":"/api-format"}]},{"group":"Configuration","pages":[{"title":"Email","href":"/email"}]}]},"basePath":"","title":"Repositories - SaaS Foundation","deploymentId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","buildId":"dpl_HhUetB7eHHDAmK9T1Teip38TgFx9","dynamics":[],"chunks":[]}