Skip to content

Architecture ​

SUDIGITAL runs on a single backend monorepo — sudi.engine — that serves all three products through one API, one database, and one authentication system.

System Overview ​

┌───────────────────────────────────────────────────────────────────┐
│                          FRONTENDS                                │
│                                                                   │
│  sudigital.com (unified shell)   neptu.sudigital.com   pasar.sudigital.com
│  apps/web  — unified dashboard   apps/neptu            apps/pasar      │
│  (React/Vite)                    (React/Vite)          (React/Vite)    │
│                                                                   │
└──────────────┬────────────────┬──────────────────┬────────────────┘
               │                │                  │
               ▼                ▼                  ▼
┌─────────────────────────────────────────────────────────────────┐
│                      sudi.engine API                            │
│                       (Elysia)                                  │
│                                                                 │
│  /hub/*       /neptu/*       /pasar/*       /v1/*               │
│  missions     ai             strategies     auth                │
│  nft          subscriptions  bots           users               │
│  chat         referrals      alerts         health              │
│  blockchain   payments       markets                            │
│  xp           api-platform   automation                         │
│                                                                 │
├─────────────────────────────────────────────────────────────────┤
│                       SERVICES                                  │
│                                                                 │
│  Privy Auth    Drizzle ORM    OpenAI/Vertex   ccxt/Jupiter      │
│  (JWT)         (PostgreSQL)   (LLM)           (Exchange)        │
│                                                                 │
└──────────┬────────────────────────────────────┬─────────────────┘
           │                                    │
           ▼                                    ▼
┌──────────────────────┐              ┌──────────────────────┐
│     PostgreSQL       │              │      Worker          │
│   (single DB)        │              │   (background jobs)  │
│                      │              │   (cron tasks)       │
│   users              │              └──────────────────────┘
│   member_* tables    │
│   neptu_* tables     │              ┌──────────────────────┐
│   pasar_* tables     │              │    Telegram Bot      │
│   shared tables      │              │   (raw Bot API)      │
│                      │              └──────────────────────┘
└──────────────────────┘

Monorepo Structure ​

sudi.engine/
├── apps/
│   ├── api/          — Elysia REST API
│   ├── web/          — Unified member dashboard + main site
│   ├── neptu/        — Neptu frontend
│   ├── pasar/        — ThePasar frontend
│   ├── worker/       — Background jobs & cron
│   └── cli/          — Terminal dashboard
│
├── packages/
│   ├── shared/       — Types, constants, configs, errors
│   ├── contracts/    — Blockchain config, chain/token constants
│   ├── db/           — Drizzle ORM (PostgreSQL, 40+ schemas)
│   ├── ai/           — AI providers (OpenAI, Google Vertex; DeepSeek opt-in)
│   ├── auth/         — Privy auth (hooks, context, cross-subdomain SSO)
│   ├── solana/       — Solana client (programs, token, signing)
│   ├── evm/          — EVM chain client (contracts, ABIs, signing)
│   ├── nft/          — NFT, claim, tokenomics constants
│   ├── missions/     — Mission & chat constants
│   ├── integrations/ — Telegram bot + integration catalog
│   ├── logger/       — Pino structured logging
│   ├── ui/           — Shared UI components (React + TailwindCSS v4)
│   ├── neptu/        — Balinese calendar engine
│   ├── pasar/        — Pasar trading shared code
│   ├── graphify/     — Knowledge graph (graphology)
│   ├── miro-fish/    — Multi-agent prediction engine
│   ├── decision/     — System One (Laya) decision client
│   └── sanity/       — Sanity CMS client
│
└── docs/             — This documentation site

Dependency Order ​

shared -> logger -> db -> ai -> neptu -> graphify -> miro-fish -> apps

Authentication ​

All products share one auth system via Privy on a single root domain:

  • Users authenticate with wallet (Phantom, MetaMask) or social login
  • Privy issues ES256/EdDSA JWTs; sudi.engine validates them on every request
  • Privy stores its session in a first-party HttpOnly cookie scoped to .sudigital.com, so the session is shared across every product subdomain
  • One user account works across all products — no separate registration per product
  • neptu.day and thepasar.com are legacy aliases that redirect to their *.sudigital.com subdomains, so the shared cookie always applies
  • The frontend never mirrors the JWT into a JS-readable cookie

Database Design ​

Single PostgreSQL database with domain-organized schemas:

Core (cross-cutting):

  • users — Unified user table (Privy auth, wallet address)
  • audit_log — System-wide audit trail
  • job_queue — Worker job queue
  • market_data — Shared market data

Missions, NFTs & engagement tables:

  • nft_collections, nft_traits — NFT system
  • missions, mission_participants — Mission system
  • chat_sessions, chat_messages — Chat
  • xp_accounts, stake_accounts — XP and staking

Neptu tables:

  • people — Public figures for astrology analysis
  • subscriptions, payments — Billing
  • referrals — Referral system
  • ai_usage — AI reading quota

ThePasar tables:

  • trading_connections, trading_balances — Exchange connections
  • strategies, strategy_versions, bots — Trading strategies
  • alerts, automation_tasks — Automation

API Design ​

Routes are organized by product domain:

GET  /v1/auth/me              — Current user (shared)
GET  /v1/health               — System health (shared)

POST /hub/missions             — Create mission
GET  /hub/nft/collections      — List NFT collections
GET  /hub/xp/balance           — XP balance

GET  /v1/ai/daily/:birthDate   — Daily AI insight
POST /neptu/subscriptions      — Create subscription
GET  /neptu/calendar/wuku      — Wuku calendar data

GET  /pasar/strategies         — List strategies
POST /pasar/bots               — Create trading bot
GET  /pasar/markets            — Market data

Unified Member Dashboard ​

Authenticated member dashboards are unified in the web app (apps/web) behind a single shell. Members navigate the whole ecosystem without being redirected to a product subdomain; subdomains remain the home for public landing pages and deep product features.

The shell follows the standard Web2/Web3 split of two independent controls:

ControlScopeSource
Product switcherEcosystem context (Neptu / Pasar / platform)Sanity siteSettings.products
Workspace switcherSection scope (Dashboard / Admin / Developer)App teams + role gating

Terminology: an app switcher ("waffle") launches between distinct apps and leaves the shell (Google Workspace, Microsoft 365); a product switcher swaps product context inside a persistent shell (Notion, Linear, Vercel); a workspace/org switcher changes the data/tenant scope. sudi.engine uses the in-shell product switcher plus a separate workspace switcher — never two competing controls.

Routing ​

  • The shared shell lives in packages/ui (AppSidebar, TeamSwitcher, lib/workspace.ts, lib/workspace-preference.ts) and is prop-driven.
  • Product dashboard entry points render in-app at /neptu and /pasar in apps/web, backed by the shared cross-product API client.
  • productRoutes maps a product id to its in-app route, so selecting a product stays on the web origin. When no in-app route exists the switcher falls back to the product's external URL. apps/web supplies routes for Neptu and Pasar and derives the active ecosystem from the first path segment via detectEcosystem (packages/ui/src/lib/workspace.ts).
  • The last-selected workspace is persisted (sudi:last-workspace) and resumed on root visits.
  • Each product subdomain's /dashboard redirects to the unified dashboard when VITE_WEB_URL is set; landing and deep routes stay on the subdomain until they are migrated.

Next Steps ​

  • Products — detailed look at each product
  • Tokenomics — how $SUDIGITAL connects the ecosystem

One backend. Three products. One token.