How afk-alignedfamkernel/afk_monorepo works
This monorepo project is a decentralized social network that uniquely integrates Nostr (a censorship-resistant social protocol) with Starknet account abstraction via smart contracts (written in Cairo and even Solidity in some parts) to build a social layer where users can tip and interact using either the “WalletConnect” or “SocialPay” mechanisms. The overall purpose is to build a decentralized social network (“AFK Community”) that aligns web3 users and their identities, letting them interact, send tips, and participate in social actions through both on-chain and off-chain systems.
Main Components
• Frontend Applications:
• Mobile App (located in apps/mobile) built with React Native & Expo.
• Website / PWA (located in apps/website, apps/pwa) built likely with Next.js.
• Backend Services:
• Data backend (apps/data-backend) written in (likely) Node/TypeScript.
• Several backend implementations including pixel-backend and Go-based backend (found under “backend”).
• Indexers & Relayers:
• Several indexer components (e.g., apps/indexer, apps/nestjs-indexer) that collect blockchain events.
• Onchain / Smart Contracts:
• Onchain folder contains Starknet smart contracts in Cairo, as well as Solidity contracts.
• Separate contract components for account abstraction and token/tip deposit contracts.
• Packages / SDKs:
• Common utilities and SDKs (packages/common, packages/afk_nostr_sdk, packages/afk_react_sdk, etc.) to allow integration with the Nostr protocol and blockchain.
• Scripts & Tools:
• A variety of scripts for deployment and testing of Cairo code, along with Turborepo config (turbo.json) to orchestrate the monorepo.
Relationships and Interactions
• Users interact via either the Mobile App or Website. Both frontends communicate with backend services via REST APIs or GraphQL.
• The backend services handle social actions such as posting, sending tips, and interacting with user profiles. They also interface with the blockchain:
• For tip flows: a user (e.g., “Alice”) approves a token transfer to a Deposit/Transfer smart contract and then submits a deposit/claim transaction via the backend.
• Indexers continuously pull and process blockchain events (using Apibara or NestJS indexers) to update the social data or trigger notifications.
• The onchain layer (the smart contracts) is the ultimate source of truth regarding tip deposits, account abstraction, and token transfers – these receive instructions from both the backend and indexers.
• The SDK packages support communication between frontend apps and the blockchain or Nostr servers, abstracting protocol details.
Architectural Patterns and Technologies
• The system uses a monorepo structure (managed by Turborepo) where apps and packages are separated but interconnected.
• Microservice and layered architectures are in play: frontends opt for separation of concerns (mobile vs. web), backends are split into specialized services (data backend, pixel-backend, indexers), and onchain smart contracts form an independent trust layer.
• Key technologies include React Native/Expo (mobile), Next.js (website), Go and NestJS for backend services, TypeScript for the Nostr relayer and SDKs, and Cairo (plus supporting tools like Scarb and SnForge) for smart contracts on Starknet.