How nstealth/black-bull-herd-card works
Purpose and entry points
Black Bull Herd Card is a SvelteKit campaign app for $ANSEM holders: connect a Phantom wallet, read its Solana token balance without signing, derive a tier, generate/share a card, and submit a public X link for an airdrop workflow. The user-facing entry is src/routes/+page.svelte; campaign rules are at src/routes/rules/+page.svelte; global document/layout concerns live in src/routes/+layout.svelte and src/app.html.
Client application and interaction flow
The main page orchestrates wallet connection, verification, card presentation, sharing, and submission through composable Svelte components. src/lib/components/molecules/WalletConnect.svelte is the wallet boundary, while src/lib/components/molecules/CardPreview.svelte, src/lib/components/molecules/SubmitModal.svelte, and src/lib/components/molecules/SuccessModal.svelte represent the result/submission UX. Shared styling and responsive visual system originate in src/app.css.
Wallet verification API
src/routes/api/check/[wallet]/+server.ts exposes a server-side wallet-check endpoint. It is the key trust boundary: clients provide a public wallet address, while server code fetches eligibility data from Solana rather than accepting balance claims. The blockchain integration is isolated in src/lib/solana.ts, with RPC concurrency/rate handling in src/lib/rpcQueue.ts; cache support is separated in src/lib/redis.ts.
Solana and eligibility domain
The application uses Solana Web3 read-only token-account queries against the configured mainnet RPC endpoint (Helius recommended). src/lib/solana.ts obtains $ANSEM holdings; src/lib/tiers.ts maps balances to the five campaign tiers and calculates supply-related statistics. This separation ensures eligibility rules are independent of API transport and UI rendering. No transaction construction, signing, token approval, or wallet credential persistence is part of this architecture.
Card generation and assets
src/lib/cardGenerator.ts renders a personalized 1024×1024 Canvas card from wallet, balance, percentage, and tier data. Tier-specific artwork is served as static assets under static/cards/common, static/cards/rare, static/cards/epic, static/cards/legendary, and static/cards/mythic. The generated card is a client-side presentation/share artifact, not an on-chain NFT minting pipeline.
Submission and anti-duplicate persistence
src/routes/api/submit/+server.ts accepts the wallet identity and public tweet/X URL after the sharing step. It persists campaign entries through Drizzle database access in src/lib/db/index.ts, governed by the schema in src/lib/db/schema.ts. The database is Neon Postgres; the one-wallet-one-entry constraint is the principal anti-cheat control. Redis/Upstash is optional caching infrastructure rather than the system of record.
Runtime and deployment boundaries
The runtime is TypeScript/SvelteKit 2 with Vite and Tailwind, configured by svelte.config.js, vite.config.ts, and tailwind.config.js. Server API routes require Solana RPC and Neon DATABASE_URL; optional Upstash Redis uses REDIS_URL/REDIS_TOKEN. Drizzle migration/schema deployment is configured in drizzle.config.ts. Production hosting targets Vercel via vercel.json, with client-visible site URL supplied through VITE_SITE_URL.
Main entry points: [wallet]/+server.ts Wallet check API · +page.svelte Campaign page · submit/+server.ts Entry submission API · vercel.json Vercel deployment
Components 18
SvelteKit client
- App shell and styles · Global document, layout, and responsive styling.
src/routes/+layout.svelte - Campaign page · Orchestrates connection, verification, card sharing, and entry submission.
src/routes/+page.svelte - Campaign rules
src/routes/rules/+page.svelte - Wallet connection · Phantom wallet boundary; no signing flow.
src/lib/components/molecules/WalletConnect.svelte - Card and submission UX · Preview, submit modal, and success modal.
- Card generator · Creates a client-side 1024×1024 share card.
src/lib/cardGenerator.ts - Tier artwork · Common through mythic card backgrounds.
static/cards/common
Server and domain
- Wallet check API · Trust boundary for public wallet eligibility checks.
src/routes/api/check/[wallet]/+server.ts - Solana holdings reader · Read-only $ANSEM token-account queries.
src/lib/solana.ts - RPC queue · Controls RPC concurrency and rate handling.
src/lib/rpcQueue.ts - Eligibility tiers · Maps balances to five tiers and supply statistics.
src/lib/tiers.ts - Entry submission API · Accepts wallet identity and public X URL.
src/routes/api/submit/+server.ts
Data and runtime
- Drizzle database access
src/lib/db/index.ts - Campaign entry schema · Enforces one wallet entry.
src/lib/db/schema.ts - Neon Postgres · Stores airdrop workflow entries.
- Optional Redis cache · Upstash-backed optional cache, not the system of record.
src/lib/redis.ts - Solana mainnet RPC · Configured RPC endpoint, with Helius recommended.
- Vercel deployment · Production SvelteKit hosting.
vercel.json
Connections 20
- App shell and styles → Campaign page: renders
- Campaign page → Campaign rules: links to
- Campaign page → Wallet connection: connects
- Wallet connection → Wallet check API: public wallet address
- Wallet check API → Solana holdings reader: verifies holdings
- Solana holdings reader → RPC queue: queues requests
- RPC queue → Solana mainnet RPC: read-only queries
- Wallet check API → Eligibility tiers: derives tier
- Campaign page → Card and submission UX: presents result
- Card and submission UX → Card generator: generates share card
- Card generator → Tier artwork: uses tier art
- Card and submission UX → Entry submission API: wallet and X URL
- Entry submission API → Drizzle database access: persists entry
- Drizzle database access → Campaign entry schema: uses
- Drizzle database access → Neon Postgres: stores entries
- Wallet check API → Optional Redis cache: optional cache
- Entry submission API → Optional Redis cache: optional cache
- Vercel deployment → App shell and styles: hosts
- Vercel deployment → Wallet check API: runs
- Vercel deployment → Entry submission API: runs