Welcome to the technical documentation for Immune 2.0.
Immune 2.0 is a self-hosted AI platform designed to empower users to build websites, automate content, and deploy intelligent workflows without writing code.
Refer to the README.md in the project root for installation and setup instructions.
Generated: 2026-03-27 22:39:31
| Method | URI | Name | Action | Middleware |
|---|---|---|---|---|
| GET, HEAD | api/user | - | Closure | api, auth:sanctum |
| GET, HEAD | api/scene/agents | api.scene.agents | App\Http\Controllers\Api\SceneController@index | api |
| GET, HEAD | api/scene/messages | api.scene.messages | App\Http\Controllers\Api\SceneController@getSceneMessages | api |
| POST | api/scene/evolution/tick | api.scene.evolution.tick | App\Http\Controllers\Api\SceneController@tick | api |
| GET, HEAD | api/scene/experiment/stats | api.scene.experiment.stats | App\Http\Controllers\Api\SceneController@getExperimentStats | api |
| PATCH | api/scene/agents/{agent} | api.scene.updateAgent | App\Http\Controllers\Api\SceneController@updateAgent | api |
| POST | api/scene/news | api.scene.injectNews | App\Http\Controllers\Api\SceneController@injectNews | api |
| POST | api/scene/agents/{agent}/interact | api.scene.agents.interact | App\Http\Controllers\Api\SceneController@recordInteraction | api |
| GET, HEAD | api/scene/agents/{agent}/memory | api.scene.agents.memory | App\Http\Controllers\Api\SceneController@getMemoryContext | api |
| POST | api/scene/agents/{agent}/learn | api.scene.agents.learn | App\Http\Controllers\Api\SceneController@learnFact | api |
| GET, HEAD | api/scene/relationships | api.scene.relationships | App\Http\Controllers\Api\SceneController@getAllRelationships | api |
| GET, HEAD | api/scene/agents/{agent}/timeline | api.scene.agents.timeline | App\Http\Controllers\Api\SceneController@getTimeline | api |
| GET, HEAD | api/scene/evolution/report | api.scene.evolution.report | App\Http\Controllers\Api\SceneController@getEvolutionReport | api |
| GET, HEAD | api/canvas/generate | api.canvas.generate | App\Http\Controllers\Api\CanvasAIController@generate | api |
| GET, HEAD | api/canvas/status/{id} | api.canvas.status | App\Http\Controllers\Api\CanvasAIController@status | api |
| POST | api/shopify/record | api.shopify.record | App\Http\Controllers\Api\SessionRecordingController@store | api |
| GET, HEAD | api/shopify/config | api.shopify.config | App\Http\Controllers\Client\ClientSettingsController@getConfig | api |
| GET, HEAD | api/agent/tasks | api.agent.tasks | App\Http\Controllers\Api\CanvasAIController@pendingTasks | api |
| POST | api/agent/result | api.agent.result | App\Http\Controllers\Api\CanvasAIController@submitResult | api |
| GET, HEAD | api/agent/queue/list | api.agent.queue.list | App\Http\Controllers\Api\CanvasAIController@listQueue | api |
| POST | api/agent/queue/clear | api.agent.queue.clear | App\Http\Controllers\Api\CanvasAIController@clearQueue | api |
| POST | api/agent/workflow/run/create | api.agent.workflow.create | App\Http\Controllers\WorkflowController@createRun | api |
| POST | api/agent/workflow/run/{run}/event | api.agent.workflow.event | App\Http\Controllers\WorkflowController@logEvent | api |
| POST | api/requests/internal | api.requests.internal | App\Http\Controllers\Api\CanvasAIController@internalRequest | api |
| POST | api/requests/{id}/response | api.requests.update | App\Http\Controllers\Api\CanvasAIController@updateInternalResponse | api |
| POST | api/requests/{id}/progress | api.requests.progress | App\Http\Controllers\Api\CanvasAIController@updateProgress | api |
| POST | api/internal/artisan | api.internal.artisan | App\Http\Controllers\Api\InternalArtisanController@execute | api |
| GET, HEAD | api/chat/workflow/{id} | api.chat.workflow.show | App\Http\Controllers\WorkflowController@showForAgent | api |
| GET, HEAD | api/chat/workflows | api.chat.workflows.list | App\Http\Controllers\WorkflowController@listForChat | api |
| POST | api/agent/{id}/update | api.agent.update | App\Http\Controllers\Api\InternalAgentController@updateState | api |
| POST | api/telegram/webhook | api.telegram.webhook | App\Http\Controllers\Api\TelegramWebhookController@handle | api |
| POST | api/db/{table}/{operation} | api.db.action | App\Http\Controllers\Api\DatabaseActionController@execute | api |
| GET, HEAD | api/extension/config | api.extension.config | App\Http\Controllers\Api\ExtensionController@getConfig | api, web |
| GET, HEAD | api/extension/auth | api.extension.auth | App\Http\Controllers\Api\ExtensionController@checkAuth | api, web, auth:web |
| POST | api/extension/save | api.extension.save | App\Http\Controllers\Api\ExtensionController@saveContent | api, web, auth:web |
| POST | api/extension/chat | api.extension.chat | App\Http\Controllers\Api\ExtensionController@chat | api, web, auth:web |
| GET, HEAD | api/extension/saved | api.extension.saved | App\Http\Controllers\Api\ExtensionController@listSaved | api, web, auth:web |
| DELETE | api/extension/saved/{id} | api.extension.saved.delete | App\Http\Controllers\Api\ExtensionController@deleteSaved | api, web, auth:web |
| POST | api/extension/sync-chat | api.extension.sync-chat | App\Http\Controllers\Api\ExtensionController@syncChat | api, web, auth:web |
| POST | api/upload-audio-chunk | api.audio.uploadChunk | App\Http\Controllers\AudioController@uploadChunk | api |
| POST | api/finalize-audio-chunks | api.audio.finalizeChunks | App\Http\Controllers\AudioController@finalizeChunks | api |
| GET, HEAD | api/articles/{id} | api.articles.show | App\Http\Controllers\Api\ArticleController@show | api |
| PUT | api/articles/{id}/video-path | api.articles.video-path | App\Http\Controllers\Api\ArticleController@updateVideoPath | api |
| GET, HEAD | api/flashcards/words | flashcards.words | App\Http\Controllers\FlashcardController@getWords | web, visit |
The application exposes a mix of RESTful API endpoints (for data), blade routes (for UI), and WebSocket channels (for real-time updates).
routes/api.php)Use php artisan docs:compile --routes to generate an auto-maintained manifest in docs/api-routes-auto.md.
These are the main API endpoints in routes/api.php (prefixed with /api from Laravel's API router):
GET /api/user (auth:sanctum)/api/scene (agents, messages, tick, stats, relationships, etc.)/api/canvas/generate, /api/canvas/status/{id}, /api/agent/tasks, /api/agent/result, /api/agent/queue/*)/api/shopify/record and /api/shopify/config/api/agent/workflow/* and /api/chat/workflows/api/requests/internal, /api/requests/{id}/response, /api/requests/{id}/progress/api/internal/artisan/api/telegram/webhook/api/db/{table}/{operation}/api/extension/* (auth, config, save, chat, sync-chat, saved)/api/upload-audio-chunk, /api/finalize-audio-chunks/api/articles/{id}, /api/articles/{id}/video-pathNote: the sign-in/sign-up flows are implemented in web routes (
routes/web.php) and are documented below in this page for full context.
The application uses Session definitions (Cookie-based) authentication. There are no stateless JWT/API tokens for the main user session.
Cookies Required:
XSRF-TOKEN: CSRF protection token (Standard Laravel).immune_session: Main session identifier.POST /sign-in
application/x-www-form-urlencoded or application/jsonemail: (string) User email.password: (string) User password./ (or HTMX partial update).POST /sign-up
username: (string) Unique username.email: (string) Valid email.password: (string) Min 8 chars.POST /articles/{id}/video/generate
Triggers the AI Video Generation Workflow for a specific article.
Request:
id (integer) - Article ID.?force=true (optional) - Force regeneration if video exists.HX-Request: true (Optional, returns HTML progress bar instead of JSON)Response (JSON):
{
"status": "processing",
"progress": 0,
"stage": "Initializing..."
}
Process:
App\Domains\Intelligence\Models\AiRequest.Article Video Generator workflow to Python slaves.GET /articles/{id}/video/status/{requestId}.POST /api/shopify/record: Ingests rrweb events from Shopify or other sources.GET /admin/visits/video/{sessionId}: Generates/retrieves the session video.GET /admin/visits/replay/{sessionId}: Session replay player interface.GET /video-editor/project/{sessionId}: Load project.POST /video-editor/project/{sessionId}: Save project.POST /video-editor/render/{sessionId}: Trigger video rendering.POST /video-editor/tts/generate: Trigger Text-To-Speech generation.POST /video-editor/clip/regenerate: AI regeneration of a specific clip./api/extension/*)GET /api/extension/config: Get extension configuration.GET /api/extension/auth: Authenticate extension user (returns user data + CSRF token).POST /api/extension/save: Save content from the current page (URL, title, text, HTML).POST /api/extension/chat: Send a chat message with page context for AI analysis.POST /api/extension/sync-chat: Sync chat history for extension.GET /api/extension/saved: List all saved content for authenticated user.DELETE /api/extension/saved/{id}: Delete a specific saved content item.GET /site/{id}/api/{modelSlug}: Headless CMS API for site data.POST /sites/{id}/duplicate: Clone a site.GET /api/chat/workflows: List available chat workflows.GET /api/chat/workflow/{id}: Get workflow details.POST /api/agent/workflow/run/create: Start a workflow run.POST /api/agent/workflow/run/{run}/event: Post workflow events (status updates).POST /api/requests/internal: Agent queue/internal workflow request entrypoint.POST /api/requests/{id}/response: Set internal request response (worker callback).POST /api/requests/{id}/progress: Set internal request progress.GET /api/scene/agents: List scene agents.GET /api/scene/messages: Get recent scene messages.GET /api/scene/agents/{id}: Agent details.PATCH /api/scene/agents/{id}: Update agent state.POST /api/scene/agents/{id}/interact: Record interaction with an agent.GET /api/scene/agents/{id}/memory: Get agent memory context.POST /api/scene/agents/{id}/learn: Teach agent a fact.GET /api/scene/agents/{id}/timeline: Agent event timeline.POST /api/scene/evolution/tick: Advance simulation tick.GET /api/scene/experiment/stats: Get evolution experiment stats.GET /api/scene/relationships: List agent relationships.POST /api/scene/news: Inject news/event into simulation.GET /api/scene/evolution/report: Evolution report.POST /api/agent/{id}/update: Update agent from async worker.GET /chat: Chat interface.POST /chat: Create a new chat conversation.GET /requests/{conversationId}/feed: Conversation message feed.GET /request/{id}: Get single chat request message.POST /requests/empty: Clear conversation messages.The application uses Laravel Reverb for real-time broadcasting.
user.{id}: Private channel for user-specific notifications (job completion, alerts).workflow.{id}: Updates on workflow node execution status.chat.{conversationId}: Real-time AI chat stream.admin.*: Protected routes for the dashboard.public.site.*: Public-facing routes for user-generated sites.video-editor.*: Routes for the video creation tool.The backend is built on Laravel 10, utilizing a Domain-Driven Design (DDD) approach to organize code logically by business context rather than just technical layers.
app/
├── Domains/ # Business logic grouped by domain
├── Http/ # Request handling (Controllers, Middleware)
├── Services/ # Cross-cutting application services
├── Models/ # (Mostly moved to Domains, but some may exist here)
├── Jobs/ # Queueable jobs
└── Console/ # Artisan commands
The application is split into the following primary domains:
Handles content creation and management.
The "Brain" of the system.
E-commerce functionality.
Core site building features.
User management and authentication.
Gamification and interactive elements.
Developer tools and system utilities.
Services in app/Services handle logic that crosses multiple domains or interacts with external systems.
Services in app/Services handle logic that crosses multiple domains or interacts with external systems.
App\Services\AIService)Central interface for LLM operations. Supports fallback strategies (Gemini -> Ollama).
Key Methods:
enhanceArticle(string $title, string $content): array - Improves clarity and SEO.generateArticle(string $topic, string $intent): array - Creates full HTML articles from scratch.auditArticle(string $title, string $content, ?string $keyword): array - Performs SEO audit (E-E-A-T score, missing topics).generateContentStrategy(string $topic): array - Generates a cluster plan with kommercial/transactional intent.translateContent(string $content, string $targetLang): array - Translates HTML while preserving structure and IDs.App\Services\BuilderService)Manages the structure of WebsitePage content JSON. Implements a block-based editor logic.
Block Operations:
addBlock(WebsitePage $page, array $data): Adds a new block (Text, Image, Container).updateBlock(WebsitePage $page, string $blockId, array $data): Updates settings or HTML content.moveBlock(WebsitePage $page, string $blockId, ?string $newParentId, int $newIndex): Handles drag-and-drop reordering.ensureBlockIds(WebsitePage $page): Self-healing method to assign UUIDs to legacy blocks.App\Services\EvolutionService)Runs the simulation for autonomous agents in the 3D Scene.
Core Loop:
tick(): Main simulation step. Updates stats (Hunger, Energy) for all agents.evolve(SceneAgent $agent): Calculates stat changes based on DNA and current state.triggerAgentConversation($initiator, $responder): Dispatches a workflow to start an AI dialogue.mutateDNA($agent, $trait, $amount): Adjusts genetic parameters based on experiences (e.g., positive interactions increase sociability).app/Http/Controllers)Admin
app/Http/Controllers/AdminController.phpapp/Http/Controllers/DashboardController.phpapp/Http/Controllers/SeoManagerController.phpapp/Http/Controllers/DatabaseController.phpapp/Http/Controllers/CommandHistoryController.phpapp/Http/Controllers/ImageUploadController.phpapp/Http/Controllers/MediaController.phpapp/Http/Controllers/SiteSettingController.phpAPI
app/Http/Controllers/Api/Auth/AuthController.phpapp/Http/Controllers/Api/CanvasAIController.phpapp/Http/Controllers/Api/CanvasTemplateController.phpapp/Http/Controllers/Api/CustomModelAPIController.phpapp/Http/Controllers/Api/DatabaseActionController.phpapp/Http/Controllers/Api/FlashcardController.phpapp/Http/Controllers/Api/GameController.phpapp/Http/Controllers/Api/InternalAgentController.phpapp/Http/Controllers/Api/MultiplayerController.phpapp/Http/Controllers/Api/SceneController.phpapp/Http/Controllers/Api/SessionRecordingController.phpapp/Http/Controllers/Api/TelegramWebhookController.phpAuth & HTMX
app/Http/Controllers/Htmx/HTMXArticleController.phpapp/Http/Controllers/Htmx/HTMXEditorController.phpapp/Http/Controllers/Htmx/HTMXHomeController.phpapp/Http/Controllers/Htmx/HTMXSettingsController.phpapp/Http/Controllers/Htmx/HTMXSignInController.phpapp/Http/Controllers/Htmx/HTMXSignUpController.phpapp/Http/Controllers/Htmx/HTMXUserController.phpapp/Http/Controllers/SignInController.phpapp/Http/Controllers/SignUpController.phpFeatures
app/Http/Controllers/ArticleController.php
app/Http/Controllers/ArticleAudioController.php
app/Http/Controllers/ArticleGenerationController.php
app/Http/Controllers/ArticleVideoController.php
app/Http/Controllers/AudioController.php
app/Http/Controllers/Builder/BlockController.php
app/Http/Controllers/Builder/PageController.php
app/Http/Controllers/CartController.php
app/Http/Controllers/ChatController.php
app/Http/Controllers/ChatMessageController.php
app/Http/Controllers/ChatWorkflowController.php
app/Http/Controllers/CheckController.php
app/Http/Controllers/CheckoutController.php
app/Http/Controllers/ConversationController.php
app/Http/Controllers/DropshippingController.php
app/Http/Controllers/DynamicRecordController.php
app/Http/Controllers/EditorController.php
app/Http/Controllers/FlashcardController.php
app/Http/Controllers/GameController.php
app/Http/Controllers/HomeController.php
app/Http/Controllers/NavigationController.php
app/Http/Controllers/OrderController.php
app/Http/Controllers/OrdersController.php
app/Http/Controllers/PaymentController.php
app/Http/Controllers/PaymentSettingsController.php
app/Http/Controllers/ProjectFeaturesController.php
app/Http/Controllers/PublicWebsiteController.php
app/Http/Controllers/SceneController.php
app/Http/Controllers/ScriptController.php
app/Http/Controllers/SeoController.php
app/Http/Controllers/SequenceController.php
app/Http/Controllers/SettingsController.php
app/Http/Controllers/SitesController.php
app/Http/Controllers/SnapshotController.php
app/Http/Controllers/StandaloneWorkflowController.php
app/Http/Controllers/UserController.php
app/Http/Controllers/VideoEditorController.php
app/Http/Controllers/VisitController.php
app/Http/Controllers/WebsiteBuilderController.php
app/Http/Controllers/WebsiteVersionController.php
app/Http/Controllers/WorkflowController.php
app/Services)app/Services/AIService.phpapp/Services/BlockParser.phpapp/Services/BuilderService.phpapp/Services/Canvas/CanvasBuilder.phpapp/Services/Checks/BrowserCheckHandler.phpapp/Services/Checks/ContentCheckHandler.phpapp/Services/Checks/Contracts/CheckHandler.phpapp/Services/Checks/DatabaseCheckHandler.phpapp/Services/Checks/HttpCheckHandler.phpapp/Services/Dropshipping/AliExpressService.phpapp/Services/EvolutionService.phpapp/Services/FormBuilderService.phpapp/Services/LaravelExportService.phpapp/Services/PerformanceCollector.phpapp/Services/SiteGeneratorService.phpapp/Services/StaticExportService.phpapp/Services/StripeService.phpapp/Domains)app/Domains/Arcade/Models/Level.phpapp/Domains/Arcade/Models/LevelWord.phpapp/Domains/Arcade/Models/Room.phpThis section is the starting point for incremental docs maintenance. Add entries here as you complete each stage.
api.md with full endpoint list and usage examplesdatabase.md with table structure and relationshipsfrontend.md with HTMX frame, SPA behavior, and script loading (guest/app bundle details)workflows.md covering: workflow node types, execution flow, logging, error handlingdocs/backend/laravel.md for architecture reference
docs/api.md for API reference
docs/database.md for model schema
docs/frontend.md for UI/asset flow
docs/infrastructure.md for setup + environment
app/Domains/Arcade/Models/RoomPlayer.php
app/Domains/Arcade/Models/UserProgress.php
app/Domains/Arcade/Models/Word.php
app/Domains/Commerce/Models/Attribute.php
app/Domains/Commerce/Models/AttributeValue.php
app/Domains/Commerce/Models/Order.php
app/Domains/Commerce/Models/Payment.php
app/Domains/Commerce/Models/Product.php
app/Domains/Identity/Models/SSOProvider.php
app/Domains/Identity/Models/SessionRecording.php
app/Domains/Identity/Models/User.php
app/Domains/Intelligence/Models/AiRequest.php
app/Domains/Intelligence/Models/CanvasTemplate.php
app/Domains/Intelligence/Models/ChatMessage.php
app/Domains/Intelligence/Models/Conversation.php
app/Domains/Intelligence/Models/SceneAgent.php
app/Domains/Intelligence/Models/SceneObject.php
app/Domains/Intelligence/Models/SceneTrigger.php
app/Domains/Intelligence/Models/Schema.php
app/Domains/Intelligence/Models/Script.php
app/Domains/Intelligence/Models/Sequence.php
app/Domains/Intelligence/Models/Workflow.php
app/Domains/Intelligence/Models/WorkflowNode.php
app/Domains/Intelligence/Models/WorkflowRun.php
app/Domains/Intelligence/Models/WorkflowRunLog.php
app/Domains/Platform/Models/Check.php
app/Domains/Platform/Models/CheckResult.php
app/Domains/Platform/Models/CommandHistory.php
app/Domains/Platform/Models/CustomEntry.php
app/Domains/Platform/Models/CustomModel.php
app/Domains/Platform/Models/DataField.php
app/Domains/Platform/Models/DataModel.php
app/Domains/Platform/Models/DataRecord.php
app/Domains/Platform/Models/ExperimentStats.php
app/Domains/Platform/Models/Form.php
app/Domains/Platform/Models/FormSubmission.php
app/Domains/Platform/Models/PerformanceMetric.php
app/Domains/Platform/Models/SessionRecording.php
app/Domains/Platform/Models/SessionRecordingChunk.php
app/Domains/Platform/Models/Visit.php
app/Domains/Publishing/Models/Article.php
app/Domains/Publishing/Models/ArticleTranslation.php
app/Domains/Publishing/Models/AudioFile.php
app/Domains/Publishing/Models/Comment.php
app/Domains/Publishing/Models/Keyword.php
app/Domains/Publishing/Models/Language.php
app/Domains/Publishing/Models/NavigationItem.php
app/Domains/Publishing/Models/Notebook.php
app/Domains/Publishing/Models/Section.php
app/Domains/Publishing/Models/SiteSetting.php
app/Domains/Publishing/Models/SiteSettingVersion.php
app/Domains/Publishing/Models/SiteText.php
app/Domains/Publishing/Models/Tag.php
app/Domains/Publishing/Models/Theme.php
app/Domains/Publishing/Models/VideoProject.php
app/Domains/Publishing/Models/Website.php
app/Domains/Publishing/Models/WebsitePage.php
app/Domains/Dev/Models/CodeReview.php
app/Domains/Platform/Models/ShakeLog.php
app/Domains/Platform/Models/WebsiteVersion.php
app/Console/Commands)app/Console/Commands/EnhanceArticlesCommand.phpapp/Console/Commands/GenerateArticleFromOllama.phpapp/Console/Commands/GenerateNewsArticlesCommand.phpapp/Console/Commands/GitPullUpdate.phpapp/Console/Commands/ImportTranslations.phpapp/Console/Commands/PruneSessionRecordings.phpapp/Console/Commands/RunChecks.phpapp/Console/Commands/RunScheduledWorkflows.phpapp/Console/Commands/SEOAuditCommand.phpapp/Console/Commands/SEOStrategizeCommand.phpconfig/)config/app.php: Core application settings.config/auth.php: Authentication guards and providers.config/broadcasting.php: WebSocket/Pusher settings.config/cache.php: Cache store configuration.config/checks.php: Custom health check settings.config/cors.php: Cross-Origin Resource Sharing.config/csp.php: Content Security Policy.config/database.php: Database connections (MySQL/Redis).config/filesystems.php: Disk storage (Local, S3).config/gemini.php: Gemini AI API settings.config/hashing.php: Password hashing usage.config/location.php: Geolocation settings.config/logging.php: Log channels (Stack, Daily).config/mail.php: Mailer settings (SMTP).config/queue.php: Queue connections (Redis/Sync).config/reverb.php: Laravel Reverb (WebSocket) settings.config/sanctum.php: API token authentication.config/services.php: Third-party services (Stripe, Socialite).config/session.php: Session driver settings.config/view.php: Blade view paths.routes/)routes/web.php: Standard browser routes.routes/api.php: API endpoints (prefixed with /api).routes/admin.php: Admin routes (prefixed with /admin).routes/channels.php: WebSocket broadcast channels.routes/console.php: Artisan console commands.routes/chat.php: Chat system routes.routes/check.php: Health check routes.routes/editor.php: Editor specific routes.routes/htmx.php: HTMX-only endpoints.routes/lang.php: Translation routes.routes/site_settings.php: Settings management routes.routes/sitemap.php: Sitemap generation.routes/user.php: User dashboard routes.routes/websites.php: Public website routes.To keep API docs in sync automatically:
php artisan docs:compile --check --routesdocs/api-routes-auto.md (generated from routes/api.php).docs/api.md as needed (automation minimizes manual update drift).database/migrations/: Contains 80+ migration files defining the schema history.database/factories/: Model factories for testing.database/seeders/)DatabaseSeeder.php: Main entry point.
ArticleVideoWorkflowSeeder.php
AudioWorkflowSeeder.php
ChatWorkflowSeeder.php
DefaultChatWorkflowSeeder.php
EcommerceSeeder.php
EvolutionWorkflowSeeder.php
GameWorldSeeder.php
HomeArticleSeeder.php
HomePageSeeder.php
MechanicSeeder.php
NewsInjectorWorkflowSeeder.php
NewsSourcesSeeder.php
SceneAgentSeeder.php
SeoSeeder.php
StarterSeeder.php
TelegramTTSWorkflowSeeder.php
ThemeSeeder.php
TourSceneWorkflowSeeder.php
TranslationSeeder.php
WebsiteChatWorkflowSeeder.php
WebsiteSeeder.php
WordGeneratorWorkflowSeeder.php
WordSeeder.php
tests/)Feature Tests
tests/Feature/AdminBulkActionsTest.phptests/Feature/AdminTest.phptests/Feature/ArticleTest.phptests/Feature/ChatMessageTest.phptests/Feature/ConversationTest.phptests/Feature/CustomModelValidationTest.phptests/Feature/ExampleTest.phptests/Feature/ExportVideoTest.phptests/Feature/FeatureToggleTest.phptests/Feature/FlashcardDownloadTest.phptests/Feature/HTMX/EditorTest.phptests/Feature/HTMX/HomeTest.phptests/Feature/HTMX/SocialAuthTest.phptests/Feature/MultiWordTagTest.phptests/Feature/NotebookTest.phptests/Feature/SessionRecordingTest.phptests/Feature/SiteSettingTest.phptests/Feature/TTSGameTest.phptests/Feature/TagFeedTest.phptests/Feature/TranslationTest.phptests/Feature/WebsiteBuilderTest.phptests/Feature/WritingGameTest.phpUnit Tests
tests/Unit/Enums/BlockCategoryTest.phptests/Unit/Enums/BlockTypeTest.phptests/Unit/ExampleTest.phptests/Unit/Services/BuilderServiceTest.phpCore
tests/TestCase.phptests/CreatesApplication.phpThe Python backend operates as a Distributed Worker System, handling computationally intensive and AI-driven tasks that are decoupled from the main Laravel application. It communicates via WebSockets.
main.py): The central WebSocket server that acts as a task router. It receives tasks from Laravel and dispatches them to available workers.run.py / slv/main.py): The slave process that executes the actual tasks. It connects to the Master and listens for incoming jobs.python_backend/
├── main.py # WebSocket Master Server
├── run.py # Worker Entry Point
├── slv/ # Slave Worker Package
│ ├── services/ # Service Implementations
│ │ ├── video/ # Video generation pipeline
│ │ ├── audio.py # TTS and Voice Cloning
│ │ ├── scraping.py # Browser automation (Playwright)
│ │ ├── browser_animation.py # Visuals via browser rendering
│ │ └── session_recorder.py # Session replay logic
│ └── workflow/ # Node execution handlers
slv/services/video/)Composes videos from articles or text.
browser_animation.py for visual assets.moviepy for final assembly.The Python Master (main.py) acts as a WebSocket server handling communication between Clients (frontend/users) and Slaves (Python workers).
Endpoints:
ws://<BIND_ADDRESS>:8765ws://<BIND_ADDRESS>:9001Event Types (Client -> Master):
| Event Type | Description | Payload Structure |
|---|---|---|
user_message |
Standard chat request. | { "data": { "user_query": "...", "conversation_id": "...", "request_id": 123, "user_id": 1 } } |
task_request |
General AI task execution. | { "data": { "type": "...", "params": { ... } } } |
tts_request |
Text-to-Speech generation. | { "data": { "text": "...", "voice_id": "..." } } |
workflow_chat_request |
Agentic Workflow Step. | { "data": { "conversation_id": "...", "input": "..." } } |
Slave Routing:
slaves_idle and slaves_busy.The video service (slv/services/video/) transforms text articles into TikTok-style videos.
Key Components:
generator.py): Orchestrates the pipeline.analysis.py): Uses LLM (gemma3) to extract "viral" highlights.Pipeline Steps:
generate_video_from_article_id(article_id) fetches content from Laravel.analyze_for_highlights() breaks text into segments (Quote, Stats, Timeline, etc.).create_highlight_project() builds a JSON state with tracks (Audio, Video, Overlay, Music).generate_ai_html_only() creates an HTML file from templates (quote.html, etc.) for each segment.render_project():
moviepy.storage/app/public/videos and returns the path.Diagram Types:
Supported visual templates: quote, stats, flowchart, comparison, timeline, infographic, social, definition, quiz, news.
slv/services/audio.py)Handles Text-to-Speech operations.
slv/services/scraping.py)Advanced web scraping.
slv/services/browser_animation.py)Generates high-quality visuals by rendering HTML/CSS/GSAP in a headless browser and capturing screenshots/screencasts. This allows for web-native design tools to create video assets.
slv/services/session_recorder.py)Processes session replay data (rrweb events) to generate video files of user sessions.
python_backend/main.pypython_backend/run.pypython_backend/create_assets.pypython_backend/reproduce_highlight_video.pypython_backend/reproduce_render.pypython_backend/tools_config.pyslv/)python_backend/slv/__init__.pypython_backend/slv/auth.pypython_backend/slv/config.pypython_backend/slv/main.pypython_backend/slv/agents/__init__.pypython_backend/slv/agents/llm.pypython_backend/slv/agents/memory.pypython_backend/slv/core/__init__.pypython_backend/slv/core/database.pypython_backend/slv/core/utils.pyslv/services/)python_backend/slv/services/__init__.pypython_backend/slv/services/animation.pypython_backend/slv/services/audio.pypython_backend/slv/services/browser_animation.pypython_backend/slv/services/enhanced_diagrams.pypython_backend/slv/services/gold_scorer.pypython_backend/slv/services/motion_graphics.pypython_backend/slv/services/scraping.pypython_backend/slv/services/session_recorder.pypython_backend/slv/services/telegram.pypython_backend/slv/services/tools.pypython_backend/slv/services/visual_factory.pypython_backend/slv/services/animation_engine/__init__.pypython_backend/slv/services/animation_engine/scene.pyslv/services/video/)python_backend/slv/services/video/__init__.pypython_backend/slv/services/video/ai_templates.pypython_backend/slv/services/video/analysis.pypython_backend/slv/services/video/compositor.pypython_backend/slv/services/video/config.pypython_backend/slv/services/video/diagrams.pypython_backend/slv/services/video/generator.pypython_backend/slv/services/video/test_fix.pypython_backend/slv/services/video/visuals.pypython_backend/slv/services/video/web_visuals.pyslv/workflow/)python_backend/slv/workflow/__init__.pypython_backend/slv/workflow/engine.pypython_backend/slv/workflow/handlers.pypython_backend/slv/workflow/nodes.pypython_backend/slv/workflow/video_clip_handler.pypython_backend/test_audio_debug.pypython_backend/test_full_flow.pypython_backend/test_template_gen.pypython_backend/test_video_gen.pypython_backend/verify_html_flow.pypython_backend/verify_phase2.pypython_backend/verify_phase3.pypython_backend/verify_phase4.pypython_backend/verify_phase5.pypython_backend/verify_phase6.pypython_backend/verify_story.pypython_backend/verify_telegram.pypython_backend/verify_upload.pypython_backend/verify_video_gen.pyThe database is structured to support a modular Domain-Driven architecture. The table list below is synced from migration file names in database/migrations.
users
id, email, password, username, role.name, bio, image, avatar.provider (google, etc), provider_id.preferences (JSON), chat_workflow_id (FK -> workflows).articles: HasMany Articlefollowers/followings: BelongsToMany Userarticles
id, user_id (FK), section_id (FK), position.is_public (bool): Visibility toggle.type (enum): post, page, product, docs.content_equity_score (int): Calculated value (0-100) combining SEO + Potential.price, sku, inventory.translations: HasMany ArticleTranslation (Content stored here).tags: BelongsToMany Tag.favoritedUsers: BelongsToMany User.article_translations
id, article_id (FK), lang (en, fr, etc).title, slug, content (JSON/HTML), description, seo_score.sections
id, name, notebook_id (FK).websites: Sites created by the builder.website_pages: Individual pages within sites.website_versions: History/snapshots of site configuration.themes: Visual themes for sites.site_settings: Global configuration.shake_logs: Client-side error reporting and context logs.workflows: Definitions of workflow graphs.workflow_runs: Execution history.ai_requests: Log of LLM interactions.notebooks, sections: Knowledge organization.chat_messages, conversations: AI chat history.saved_contents: User-saved page content from the browser extension (URL, title, text, HTML).products: E-commerce items.orders: Transaction records.payments: Payment processing logs.attributes, attribute_values: Dynamic product properties.words, levels: Game data for word games.user_progress: Tracking player advancement.rooms, room_players: Multiplayer game state.session_recordings: Session replay data (Shopify integration).video_projects: Video editor project files.custom_models, data_fields, data_records: User-defined database schemas (Headless CMS features).code_reviews: Historical code analyses and AI code reviews.The table list is generated from database/migrations/*_create_*.php and other schema migrations.
users + auth support: password_reset_tokens, personal_access_tokens, sessions (via Laravel sessions if used)session_recordings, session_recording_chunksnotebooks, sectionsuser_followerarticles, article_translations, article_tag, article_favorite, comments, tagssymbols, ohlvcs, signals, orders, trades, payments (renamed)visits, command_histories, performance_metrics, shake_logsschemas, conversations, chat_messages, ai_requests, canvas_templates, workflow_runs, workflows, scene_agents, scene_triggers, scene_objects, experiment_statsthemes, site_settings, site_setting_versions, site_texts, custom_models, data_models, data_fields, data_records, forms, form_submissions, website_versionsproducts, attributes, attribute_valueswords, levels, room_players, user_progress (and related arcade models)sso_providers, clientschecks, check_resultssaved_contentsphp artisan migrate:status and ls database/migrations.php artisan docs:compile --check --routesThe Immune 2.0 frontend uses a hybrid approach to deliver a fast, dynamic user experience without the complexity of a full SPA (Single Page Application) framework everywhere.
resources/js/scene/)The 3D environment is built on Three.js and manages a persistent world state synchronized via WebSockets.
SceneManager.js)PlayerController (physics/movement).EntityManager (agents, NPCs).TerrainChunkManager (infinite terrain generation).gltf assets and simple mesh entities.resources/js/builder/)A visual node graph editor for designing Agent Workflows.
GraphManager.js)nodes, connections, panX, panY, and scale.workflow_generated event) allows users to prompt an AI agent to dynamically generate workflow nodes and connections on the canvas.The frontend includes a custom recording script (based on rrweb) for capturing user sessions, particularly for the Shopify integration.
A specialized frontend interface for the video generation workflow.
resources/views/video-editor (inferred).resources/js)Core & Immune
resources/js/app.js
resources/js/bootstrap.js
resources/js/chat-app.js
resources/js/fraud-detector.js
resources/js/guest.js
resources/js/inline-toolbar.js
resources/js/scene.js
resources/js/word-game.js
resources/js/word-match-game.js
resources/js/immune/Core.js
resources/js/immune/config.js
resources/js/immune/runtime.js
resources/js/immune/debug/Logger.js
resources/js/immune/events/Bus.js
resources/js/immune/network/SocketClient.js
resources/js/immune/ui/ChatManager.js
resources/js/immune/utils/ColorUtils.js
Canvas Engine
resources/js/immune/canvas/Engine.jsresources/js/immune/canvas/Input.jsresources/js/immune/canvas/Transformer.jsresources/js/immune/canvas/history/Stack.jsresources/js/immune/canvas/math/Matrix3.jsresources/js/immune/canvas/math/Vector2.jsresources/js/immune/canvas/nodes/BaseNode.jsresources/js/immune/canvas/nodes/ImageNode.jsresources/js/immune/canvas/nodes/LineNode.jsresources/js/immune/canvas/nodes/ShapeNode.jsresources/js/immune/canvas/nodes/TextNode.jsBuilder
resources/js/builder/GraphManager.jsresources/js/builder/NodeRenderer.jsresources/js/builder/SocketHandler.jsresources/js/builder/Templates.jsresources/js/agent-builder.js3D Engine (scene)
resources/js/scene/Decorations.jsresources/js/scene/PlayerBot.jsresources/js/scene/PlayerController.jsresources/js/scene/WorldBuilder.jsresources/js/scene/index.jsresources/js/scene/animals/Bear.jsresources/js/scene/animals/Deer.jsresources/js/scene/animals/Raccoon.jsresources/js/scene/animals/index.jsresources/js/scene/buildings/Structures.jsresources/js/scene/buildings/index.jsresources/js/scene/core/InputManager.jsresources/js/scene/core/SceneManager.jsresources/js/scene/environment/BiomeManager.jsresources/js/scene/environment/Particles.jsresources/js/scene/environment/Terrain.jsresources/js/scene/environment/TerrainChunk.jsresources/js/scene/environment/TerrainChunkManager.jsresources/js/scene/environment/Vegetation.jsresources/js/scene/environment/index.jsresources/js/scene/lighting/Atmosphere.jsresources/js/scene/lighting/index.jsresources/js/scene/managers/EntityManager.jsresources/js/scene/managers/SimulationManager.jsresources/js/scene/network/NetworkManager.jsresources/js/scene/ui/UIManager.jsresources/js/scene/utils/FurShader.jsresources/js/scene/utils/SeededRandom.jsEditors
resources/js/editor/easy-form.jsresources/js/video-editor/Canvas.jsresources/js/video-editor/Storyboard.jsresources/js/video-editor/Timeline.jsresources/js/video-editor/index.jsresources/js/visual-editor/blocks/DesignBlock.jsresources/js/visual-editor/blocks/StyleBlock.jsresources/js/visual-editor/index.jsresources/views)Auth
resources/views/auth/sign-in/index.blade.phpresources/views/auth/sign-in/partials/form-fields.blade.phpresources/views/auth/sign-in/partials/index.blade.phpresources/views/auth/sign-up/index.blade.phpresources/views/auth/sign-up/partials/form-fields.blade.phpresources/views/auth/sign-up/partials/index.blade.phpresources/views/auth/verify-email-notice.blade.phpAdmin
resources/views/administration/activity.blade.phpresources/views/administration/agents.blade.phpresources/views/administration/appearance/index.blade.phpresources/views/administration/articles/edit.blade.phpresources/views/administration/articles/write.blade.phpresources/views/administration/create.blade.phpresources/views/administration/edit.blade.phpresources/views/administration/features/index.blade.phpresources/views/administration/index.blade.phpresources/views/administration/list.blade.phpresources/views/administration/media/index.blade.phpresources/views/administration/navigation/index.blade.phpresources/views/administration/pages/index.blade.phpresources/views/administration/partials/model-stats.blade.phpresources/views/administration/partials/sidebar.blade.phpresources/views/administration/products/index.blade.phpresources/views/administration/seo-manager/ideas.blade.phpresources/views/administration/seo-manager/index.blade.phpresources/views/administration/seo-manager/keywords.blade.phpresources/views/administration/seo/index.blade.phpresources/views/administration/snapshots/index.blade.phpresources/views/administration/stat.blade.phpBuilder
resources/views/builder/canvas.blade.phpresources/views/builder/database/entries.blade.phpresources/views/builder/database/entry-form.blade.phpresources/views/builder/database/index.blade.phpresources/views/builder/database/schema.blade.phpresources/views/builder/edit.blade.phpresources/views/builder/flow.blade.phpresources/views/builder/partials/block-settings.blade.phpresources/views/builder/partials/block.blade.phpresources/views/builder/partials/component-renderer.blade.phpresources/views/builder/partials/navbar.blade.phpresources/views/builder/partials/page-list.blade.phpresources/views/builder/partials/settings-form.blade.phpresources/views/builder/partials/sidebar-left.blade.phpresources/views/builder/preview.blade.phpresources/views/builder/workflows/editor.blade.phpresources/views/builder/workflows/index.blade.phpComponents
resources/views/components/ad-slot.blade.phpresources/views/components/article/layout.blade.phpresources/views/components/article/scripts.blade.phpresources/views/components/article/styles.blade.phpresources/views/components/article/tip.blade.phpresources/views/components/block-renderer.blade.phpresources/views/components/blocks/accordion.blade.phpresources/views/components/blocks/audio.blade.phpresources/views/components/blocks/blockquote.blade.phpresources/views/components/blocks/blog-list.blade.phpresources/views/components/blocks/button.blade.phpresources/views/components/blocks/card.blade.phpresources/views/components/blocks/cart-view.blade.phpresources/views/components/blocks/chart.blade.phpresources/views/components/blocks/chat-bubble.blade.phpresources/views/components/blocks/code.blade.phpresources/views/components/blocks/columns.blade.phpresources/views/components/blocks/container.blade.phpresources/views/components/blocks/data-list.blade.phpresources/views/components/blocks/design.blade.phpresources/views/components/blocks/faq.blade.phpresources/views/components/blocks/feed.blade.phpresources/views/components/blocks/footnote.blade.phpresources/views/components/blocks/gauge.blade.phpresources/views/components/blocks/grid.blade.phpresources/views/components/blocks/h1.blade.phpresources/views/components/blocks/h2.blade.phpresources/views/components/blocks/h3.blade.phpresources/views/components/blocks/header.blade.phpresources/views/components/blocks/heading.blade.phpresources/views/components/blocks/image.blade.phpresources/views/components/blocks/list.blade.phpresources/views/components/blocks/paragraph.blade.phpresources/views/components/blocks/pricing-table.blade.phpresources/views/components/blocks/progress-bar.blade.phpresources/views/components/blocks/section.blade.phpresources/views/components/blocks/shop-grid.blade.phpresources/views/components/blocks/style.blade.phpresources/views/components/blocks/subheading.blade.phpresources/views/components/blocks/table.blade.phpresources/views/components/blocks/tabs.blade.phpresources/views/components/blocks/testimonials.blade.phpresources/views/components/blocks/text.blade.phpresources/views/components/blocks/timeline.blade.phpresources/views/components/blocks/tip.blade.phpresources/views/components/blocks/video.blade.phpresources/views/components/blocks/widgets.blade.phpresources/views/components/builder-navbar.blade.phpresources/views/components/builder/block.blade.phpresources/views/components/editor/loader.blade.phpresources/views/components/editor/script.blade.phpresources/views/components/flashcard-game.blade.phpresources/views/components/form-error-message.blade.phpresources/views/components/form-success-message.blade.phpresources/views/components/htmx/head.blade.phpresources/views/components/main-navbar-tailwind.blade.phpresources/views/components/main-navbar.blade.phpresources/views/components/navbar-items.blade.phpresources/views/components/navbar.blade.phpresources/views/components/redirect.blade.phpresources/views/components/rrweb.blade.phpresources/views/components/table.blade.phpresources/views/components/word-game.blade.phpresources/views/components/word-match-game.blade.phpresources/views/components/writing-game.blade.phpOther Views
resources/views/articles/builder.blade.php
resources/views/articles/detail.blade.php
resources/views/articles/partials/... (see directories)
resources/views/chat/...
resources/views/checks/...
resources/views/command_history/index.blade.php
resources/views/dashboard/index.blade.php
resources/views/database/...
resources/views/docs/show.blade.php
resources/views/editor/...
resources/views/errors/...
resources/views/flashcards/index.blade.php
resources/views/home/index.blade.php
resources/views/home/partials/...
resources/views/layouts/...
resources/views/pages/show.blade.php
resources/views/payment/...
resources/views/products/show.blade.php
resources/views/scene/...
resources/views/settings/...
resources/views/shop/index.blade.php
resources/views/site_settings/...
resources/views/site_texts/...
resources/views/sitemap.blade.php
resources/views/sites/...
resources/views/users/...
resources/views/vendor/pagination/...
resources/views/visits/...
resources/views/websites/...
resources/views/workflows/...
The application runs as three distinct services that must operate simultaneously:
php artisan serve (Dev) or Nginx/PHP-FPM (Prod)..env (Database, Redis, Mail settings)./python_backendpython main.py
8765.python_backend/requirements.txt (implied).php artisan queue:work --tries=3For production, use supervisord to manage processes.
[program:immune-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/immune/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=2
[program:immune-python]
command=python3 /var/www/immune/python_backend/run.py
directory=/var/www/immune/python_backend
autostart=true
autorestart=true
stderr_logfile=/var/log/immune-python.err.log
stdout_logfile=/var/log/immune-python.out.log
Assets are compiled using Vite.
npm install
npm run build
Generates assets in public/build/.
composer install --optimize-autoloader --no-dev
php artisan optimize
composer.json, composer.lock: PHP usage dependencies.package.json, package-lock.json: Node.js dependencies.docker-compose.yml (when available): local container setup.app/Console/Commands/DocsCommand.php supports --routes to generate an up-to-date API manifest (docs/api-routes-auto.md).
php artisan docs:compile --check --routes should be part of CI.
Use php artisan migrate:status for database state check, and php artisan queue:work + python_backend/main.py for runtime stack.
vite.config.js: Vite build configuration.
tailwind.config.js: Tailwind CSS configuration.
postcss.config.js: PostCSS configuration.
phpunit.xml: PHPUnit testing configuration.
supervisord.conf: Supervisor process manager config.
docker-compose.yml (if present): Docker setup.
.env: Environment variables..env.example: Template for environment variables..gitignore: Git exclusion rules..editorconfig: Editor coding style rules..gitattributes: Git attribute settings.artisan: Laravel CLI entry point.translations.json: Translation strings.words.json: Default word list.Beyond standard Laravel .env entries, the following are required:
| Variable | Description | Required |
|---|---|---|
INTERNAL_SERVICE_TOKEN |
Token for service-to-service auth | Yes |
OPENAI_API_KEY |
OpenAI API key for AI features | Yes (for AI) |
OLLAMA_ENABLED |
Enable Ollama as LLM fallback | No (default: true) |
OLLAMA_BASE_URL |
Ollama server URL | No (default: localhost:11434) |
OLLAMA_MODEL |
Ollama model name | No (default: gemma3:latest) |
NTFY_ENABLED |
Enable ntfy.sh notifications (fallback; configurable in Admin → Notifications) | No (default: false) |
NTFY_CHANNEL |
ntfy.sh channel name (fallback; configurable in Admin → Notifications) | No |
This document outlines the known limitations of the platform, features that are currently experimental or non-functional, and the technical security measures in place.
/scene) uses Three.js with high-fidelity PBR materials and dynamic lighting.<canvas> (unless explicitly handled), WebGL contexts, or cross-origin iframes./install route) is currently in dev mode and requires manual partner account setup.EnsureFrontendRequestsAreStateful middleware in the API group, allowing the browser extension to use cookie-based auth with credentials: 'include'.POST, PUT, DELETE) are protected by Laravel's VerifyCsrfToken middleware. The $except array is empty — no routes are excluded.CheckRole middleware ensures admin routes are protected.INTERNAL_SERVICE_TOKEN) via config('services.immune.internal_token'). No hardcoded secrets exist in the codebase.config() over env(): All application code uses config() to read environment values. Direct env() calls are only permitted inside config/*.php files. This ensures compatibility with php artisan config:cache..env variables: INTERNAL_SERVICE_TOKEN, OPENAI_API_KEY, NTFY_CHANNEL (if notifications enabled), NTFY_ENABLED.HstsMiddleware is enabled, forcing HTTPS on all connections.CoopMiddleware (Cross-Origin Opener Policy) is active to isolate the browsing context, protecting against Spectre/Meltdown class side-channel attacks.HandleCors is configured to allow * origins for the API (necessary for the recorder to work on any merchant site), but critical admin endpoints are session-protected.ThrottleRequests is applied to API routes (agent-api group) to prevent abuse./upload-image, /wysiwyg/upload) require authentication./generate-article) require authentication./wysiwyg/*) are protected by auth middleware.ScriptController::execute, SequenceController::run) have been removed. No shell_exec or exec of user-provided code exists.FormRequest classes ensures strict type checking.This document details the architecture, installation, and operation of the Immune Session Recorder for Shopify.
The Immune Session Recorder is a Shopify Theme App Extension. This means it integrates directly into the merchant's Onlin Store theme without modifying their code files manually. It allows merchants to enable/disable the recorder via the Shopify Theme Editor (App Embeds).
shopify_extension/shopify_extension/
├── package.json # Dependencies (@shopify/app, @shopify/cli)
├── shopify.app.toml # Main app configuration (Keys, Scopes)
└── extensions/
└── immune-session-recorder/
├── shopify.extension.toml # Extension metadata
├── assets/
│ └── shopify-recorder.js # The core recording logic (compresses & sends events)
└── blocks/
└── recorder_embed.liquid # The Liquid integration logic (Consent handling)
Navigate to the extension directory:
cd shopify_extension
npm install
Deploy to Shopify:
npm run deploy
Follow the CLI prompts to select your Organization and App.
Enable on Development Store:
recorder_embed.liquid)We strictly adhere to Shopify's Privacy requirements. The recorder does not start until the user has granted Analytics Consent.
Shopify.customerPrivacy.getTrackingConsent().Shopify.customerPrivacy.subscribe('consentChanged', ...) to detect when a user accepts the cookie banner.shopify-recorder.js script is dynamically injected (document.createElement('script')) only when consent.analytics === true.shopify-recorder.js)rrweb for DOM Mutation Observation.POST /api/session/record on your self-hosted instance.To work on the extension locally:
cd shopify_extension
npm run dev
This will start a local tunnel (Cloudflare) and allow you to preview changes in your Development Store in real-time.
Shopify store owners can view their session recordings through a dedicated client portal.
https://gabriel0.com/client/loginTo create a new client account, run:
php artisan tinker
Then:
\App\Models\Client::create([
'shop_domain' => 'your-store.myshopify.com',
'email' => 'owner@yourstore.com',
'name' => 'Store Owner Name',
'password' => bcrypt('secure-password-here'),
]);
This document outlines the technical architecture, data flow, and feature specifications for the functionality of the Immune Session Replay recorder on Shopify stores.
rrweb-based Javascript recorder injected into the Shopify store via Script Tag or Theme File.ntfy.sh external service.Table: session_recordings
| Column | Type | Default | Description |
|---|---|---|---|
id |
BIGINT |
PK | Auto-increment ID. |
session_id |
UUID |
- | Unique identifier for the viewing session (generated by frontend). |
shop_domain |
STRING |
- | Shopify store domain (e.g., shop.myshopify.com). |
events |
LONGTEXT |
NULL |
Raw JSON array of rrweb events. Merged on updates. |
duration |
INT |
0 | Duration of the session in seconds. |
device_type |
STRING |
desktop |
Derived from User-Agent (mobile, tablet, desktop, robot). |
country |
STRING |
NULL |
2-letter ISO country code (via GeoIP or Header). |
notification_level |
INT |
0 | Sync state for notifications (0=None, 1=10s sent, 2=60s sent). |
video_status |
STRING |
NULL |
Status of MP4 export (pending, processing, completed, failed). |
video_path |
STRING |
NULL |
Relative path to the generated MP4 file. |
last_activity_at |
TIMESTAMP |
NULL |
Timestamp of the last event. |
created_at |
TIMESTAMP |
NOW |
Session start time. |
updated_at |
TIMESTAMP |
NOW |
Last sync time. |
shopify-recorder.js) uses rrweb to capture DOM mutations, mouse movements, and inputs.POST /api/shopify/record.store method uses firstOrNew on session_id. Incoming events are appended (array_merge) to the existing events JSON array.blade template (visits.replay) initializes a new rrweb.Replayer with the stored JSON events.CF-IPCountry header (Cloudflare).Stevebauman\Location (GeoIP database lookup).User-Agent string using Jenssegers\Agent.mobile, tablet, desktop, robot.The system sends alerts to ntfy.sh based on session duration thresholds. To prevent spam, it uses a state machine tracked by notification_level.
duration > 10 AND notification_level < 1.https://ntfy.sh.notification_level = 1.duration > 60 AND notification_level < 2.https://ntfy.sh.notification_level = 2.VisitController@exportVideo sets video_status to pending.AiRequest task (session_video_generation) is created.python_backend/main.py) detects task and dispatches to Worker.python_backend/main.py) launches headless browser, replays session, and captures screen to MP4 (using ffmpeg).video_path is updated and video_status set to completed.Endpoint: POST /api/shopify/record
Payload:
{
"session_id": "uuid-v4-string",
"shop": "shop-domain.com",
"events": [
{ "type": 1, "timestamp": 1700000000, "data": {...} },
...
]
}
Response:
{ "success": true }
We have migrated to a Shopify Theme App Extension, which is the modern standard for injecting scripts into Shopify stores. This allows merchants to enable/disabe the recorder via the Theme Editor without touching code.
cd shopify_extension
npm install
npm run deploy
Deprecated. Use the App Extension method above.
To manually enable the session recorder, add the following snippet to your theme's layout/theme.liquid file, just before the closing </head> tag:
<!-- Immune Session Recorder -->
<script>
window.immuneConfig = {
endpoint: "https://gabriel0.com/api/shopify/record",
shop: "{{ shop.permanent_domain }}"
};
</script>
<script src="https://gabriel0.com/js/shopify-recorder.js" async></script>