How leamsigc/magicsync works
Purpose and Entry Points
MagicSync is a Nuxt 4/pnpm monorepo for multi-platform social-media management: business/account connection, media, AI-assisted content, post scheduling, publishing, and analytics. The primary application merge point is packages/site/, started with pnpm site:dev; its Nuxt configuration composes feature packages into one app. A separate optional FastAPI service runs AI/agent capabilities on port 8000.
• packages/site/nuxt.config.ts
• packages/site/app/pages/app/index.vue
• packages/python-backend/app/main.py
Layered Nuxt Feature Modules
Most product domains are independently structured Nuxt layers containing Vue pages/composables plus Nitro server routes. The shared UI layer provides base layouts/components, while site supplies dashboard and admin surfaces. This is a modular monolith at runtime rather than separately deployed frontend applications.
• packages/ui/app/components/BaseSidebarNavigation.vue
• packages/scheduler/nuxt.config.ts
• packages/site/app/pages/app/admin/index.vue
Identity, Tenancy, and Social Connections
Authentication is implemented through Better Auth routes and global middleware. Users operate in business contexts; the Connect module manages businesses, memberships, active business selection, and OAuth/API-key-backed social accounts. These identity and connection records are a boundary between user-facing workflows and third-party platforms.
• packages/auth/server/api/auth/[...all].ts
• packages/auth/server/middleware/001.auth.ts
• packages/connect/server/api/v1/social-accounts/callback/[platform].get.ts
Persistence and Domain Services
packages/db is the central persistence layer, using Drizzle ORM with Turso/libSQL and migrations. Its schemas cover authentication, businesses, posts, social accounts, assets, templates, skills, LLM configuration, and RAG; server services encapsulate database operations for consuming modules. Native vector support enables knowledge retrieval.
• packages/db/db/schema.ts
• packages/db/config/drizzle.config.ts
• packages/db/server/services/post.service.ts
Content Creation, Scheduling, and Publishing
The Scheduler module is the core post lifecycle: create/update/validate posts, render calendar/feed views, and publish through platform-specific plugins. Scheduled execution and token-health work are represented as server tasks; publishing adapters isolate platform APIs and rate limiting from post management. Bulk Scheduler feeds this lifecycle through CSV import or AI batch generation.
• packages/scheduler/server/api/v1/posts/index.post.ts
• packages/scheduler/server/services/AutoPost.service.ts
• packages/scheduler/server/services/plugins/x.plugin.ts
• packages/bulk-scheduler/server/services/bulkScheduler.service.ts
AI, Agent, and Knowledge Boundaries
The TypeScript AI-tools layer exposes chat, LLM configuration, documents, retrieval, skills, tool calls, social generation, and agent streaming to the Nuxt UI. It currently includes an aiToolsFacade service boundary. The Python backend contains the deeper implementation: LLM/Ollama access, agent orchestration/subagents, RAG parsing-chunking-embedding-reranking, PII pipeline, MCP client, tool registry/execution, and harness evaluation. Requests cross an HTTP boundary rather than directly sharing runtime code.
• packages/ai-tools/server/services/aiToolsFacade.service.ts
• packages/ai-tools/server/api/ai-tools/retrieve.post.ts
• packages/python-backend/app/services/agent/orchestrator.py
• packages/python-backend/app/services/rag/embeddings.py
Media, Templates, and External Integrations
Assets are uploaded, stored/served, and optionally imported from Canva, Google Drive, and Pexels. Templates provide reusable variable and chat/post structures. Scheduler and Connect integrate external social networks, Google Business, and provider OAuth; AI workflows can use configured LLMs and web search. Docker Compose files provide local containerized infrastructure.
• packages/assets/server/services/asset.service.ts
• packages/templates/server/api/v1/templates/index.post.ts
• packages/scheduler/server/api/v1/gmb/reviews/sync.post.ts
• docker-compose.yml
Main entry points: nuxt.config.ts Site dashboard · schema.ts Domain database · index.post.ts Post scheduler · [platform].get.ts Business connections
Components 18
Nuxt modular monolith
Feature layers compose into the site runtime.
- Site dashboard · Primary application merge point and dashboard surface.
packages/site/nuxt.config.ts - Shared UI
packages/ui/app/components/BaseSidebarNavigation.vue - Authentication · Better Auth routes and global request middleware.
packages/auth/server/api/auth/[...all].ts
Core domain services
- Business connections · Business tenancy, memberships, and social-account OAuth.
packages/connect/server/api/v1/social-accounts/callback/[platform].get.ts - Domain database · Central schemas and server persistence services.
packages/db/db/schema.ts - Media assets · Asset upload, storage, serving, and imports.
packages/assets/server/services/asset.service.ts - Templates · Reusable variable and post/chat structures.
packages/templates/server/api/v1/templates/index.post.ts - Post scheduler · Post lifecycle, calendar/feed views, validation, and publishing.
packages/scheduler/server/api/v1/posts/index.post.ts - Scheduled post tasks · Executes scheduled publishing and token-health work.
packages/scheduler/server/services/AutoPost.service.ts - Platform publishers · Platform API and rate-limit isolation.
packages/scheduler/server/services/plugins/x.plugin.ts - Bulk scheduling · CSV import and AI batch generation into post lifecycle.
packages/bulk-scheduler/server/services/bulkScheduler.service.ts
AI runtime boundary
Python capabilities are reached over HTTP.
- AI tools facade · TypeScript boundary for chat, retrieval, skills, tools, and streaming.
packages/ai-tools/server/services/aiToolsFacade.service.ts - Python AI API · Optional AI and agent service on port 8000.
packages/python-backend/app/main.py - Agent orchestration · Coordinates agents, subagents, tools, and execution.
packages/python-backend/app/services/agent/orchestrator.py - RAG pipeline · Embedding and retrieval implementation.
packages/python-backend/app/services/rag/embeddings.py
External systems
- Social platforms · OAuth-connected publishing and Google Business services.
- Media providers · Canva, Google Drive, and Pexels imports.
- LLM and web services · Configured LLM, Ollama, and web-search providers.
Connections 24
- Site dashboard → Shared UI: renders shared components
- Site dashboard → Authentication: uses identity middleware
- Site dashboard → Business connections: manages business context
- Site dashboard → Post scheduler: manages posts
- Site dashboard → Media assets: manages media
- Site dashboard → Templates: uses reusable content
- Site dashboard → AI tools facade: invokes AI workflows
- Authentication → Domain database: stores identities
- Business connections → Domain database: stores businesses and accounts
- Business connections → Social platforms: OAuth and account APIs
- Media assets → Domain database: stores asset records
- Media assets → Media providers: imports media
- Templates → Domain database: stores templates
- Post scheduler → Domain database: stores posts
- Bulk scheduling → Post scheduler: creates batch posts
- Scheduled post tasks → Post scheduler: processes scheduled posts
- Scheduled post tasks → Platform publishers: dispatches publishing
- Platform publishers → Social platforms: publishes and syncs
- AI tools facade → Python AI API: HTTP requests
- Python AI API → Agent orchestration: runs agents
- Python AI API → RAG pipeline: runs retrieval
- Agent orchestration → RAG pipeline: uses knowledge retrieval
- Agent orchestration → LLM and web services: calls models and tools
- RAG pipeline → Domain database: uses vector knowledge