*** title: Integration patterns description: How AISquare fits into different application architectures. ------------------------------------------------------------------------ This guide explains how AISquare fits into different application architectures. Depending on your use case, you can integrate AISquare in multiple ways. *** ## Overview AISquare is typically used as a backend service layer that powers: * Content feeds * Personalization * Analytics * AI-driven experiences Most integrations follow this pattern: ``` Frontend → Your backend → AISquare API ``` Your backend acts as the integration layer between your application and AISquare. *** ## Pattern 1: Frontend + backend integration (recommended) This is the most common and recommended setup. ### Architecture ``` Client (Web / Mobile) ↓ Your Backend ↓ AISquare API ``` ### How it works 1. User interacts with your app 2. Your backend calls AISquare APIs 3. Your backend processes the response 4. Frontend renders the data ### Why use this pattern * Keeps API keys secure * Allows custom business logic * Enables caching and transformations * Supports personalization ### Example use case * Displaying AI Studio content feed * Showing personalized recommendations * Building dashboards *** ## Pattern 2: Server-to-server integration Used when AISquare is part of your backend workflows. ### Architecture ``` Your Backend → AISquare API ``` ### How it works * Your backend directly calls AISquare * No frontend involvement required * Runs as part of internal services or pipelines ### Example use case * Syncing user data * Generating reports * Running analytics jobs *** ## Pattern 3: Platform embedding (partner integration) Used when AISquare powers features inside another platform. Example: integrating AISquare into a product like a learning or gaming platform. ### Architecture ``` User → Your Platform → AISquare API ``` ### Key idea Your platform: * Manages users * Handles authentication * Calls AISquare on behalf of users AISquare acts as a **data and intelligence layer**. ### Important considerations * Register users via API * Store API keys securely * Map your user IDs to AISquare users *** ## Choosing the right pattern | Use case | Recommended pattern | | ----------------- | ------------------- | | Web or mobile app | Frontend + backend | | Internal services | Server-to-server | | Partner platform | Platform embedding | *** ## Best practices ### Use a backend layer Never call AISquare directly from the frontend with sensitive credentials. ### Store credentials securely * API keys should be stored on your backend * Never expose them in client-side code ### Handle errors gracefully * Retry failed requests * Handle authentication errors * Validate inputs before sending requests ### Use pagination Avoid fetching large datasets at once. *** ## Putting it together A typical AISquare integration looks like: 1. User opens your app 2. Backend authenticates user 3. Backend fetches AISquare data 4. Frontend renders content 5. User interacts with resources *** ## Related pages * [Authentication](/docs/getting-started/authentication) — set up API keys and tokens * [Build your first integration](/docs/integration-guides/build-your-first-ai-studio-integration) — step-by-step guide * [User onboarding & account lifecycle](/docs/integration-guides/user-onboarding-account-lifecycle) — manage users programmatically * [Token lifecycle & session management](/docs/integration-guides/token-lifecycle-session-management) — manage tokens in production * [Permissions and access control](/docs/data-ux-guides/permissions-and-access-control) — understand access patterns * [Errors](/docs/reference/errors) — handle error responses gracefully