From 67eb5f2a1c477c0b741aebc99fb3e26accf8b40f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 28 Nov 2026 16:44:52 -0600 Subject: [PATCH] Rewrite the README for the template as it is now Drop the Stacks/Dork CLI, the nonexistent npm run deploy, the expired Vercel demo links and the outdated stack versions. Document the scripts, why a fresh copy fails npm test, the agent skills and deployment. --- README.md | 289 +++++++++++++++--------------------------------------- 1 file changed, 79 insertions(+), 210 deletions(-) diff --git a/README.md b/README.md index db47200..97c1130 100644 --- a/README.md +++ b/README.md @@ -1,242 +1,111 @@ # MKStack -**The Complete Framework for Building Nostr Clients with AI** +A template for building Nostr apps with AI agents. It's a working React app with login, relay management, publishing and file uploads already wired up, plus an `AGENTS.md` and a set of skills that teach coding agents how to build on it safely. -MKStack is an AI-powered framework for building Nostr applications with React 18.x, TailwindCSS 3.x, Vite, shadcn/ui, and Nostrify. Build powerful Nostr applications with AI-first development - from social feeds to private messaging, MKStack provides everything you need to create decentralized apps on the Nostr protocol. +## Stack -## ๐Ÿš€ Quick Start +- **React 19** with **TypeScript** +- **Vite 8** for the dev server and build +- **Tailwind CSS 4** and **shadcn/ui** (Radix UI) components +- **Nostrify** and **nostr-tools** for the Nostr protocol +- **TanStack Query** for data fetching and caching +- **React Router 7** +- **Vitest 5** with React Testing Library -Build your Nostr app in 3 simple steps: +## Getting started -### 1. Install & Create ```bash -npm install -g @getstacks/stacks -stacks mkstack +git clone https://gitlab.com/soapbox-pub/mkstack.git my-app +cd my-app +npm run dev ``` -### 2. Build with AI -```bash -stacks agent -# Tell Dork AI what you want: "Build a group chat application" -``` +The dev server runs on [localhost:8080](http://localhost:8080). The `dev`, `build` and `test` scripts install dependencies themselves. -### 3. Deploy Instantly -```bash -npm run deploy -# โœ… App deployed to NostrDeploy.com! -``` +| Command | What it does | +| --------------- | --------------------------------------------------------------- | +| `npm run dev` | Start the dev server | +| `npm run build` | Build to `dist/`, with `404.html` copied from `index.html` | +| `npm test` | Type-check, lint, run the tests, then build | -## โœจ What Makes MKStack Special +### The template fails `npm test` on purpose -- **๐Ÿค– AI-First Development**: Build complete Nostr apps with just one prompt using Dork AI agent -- **โšก 8 Minutes Average**: From idea to deployed application in minutes, not months -- **๐Ÿ”— 50+ NIPs Supported**: Comprehensive Nostr protocol implementation -- **๐ŸŽจ Beautiful UI**: 48+ shadcn/ui components with light/dark theme support -- **๐Ÿ” Built-in Security**: NIP-07 browser signing, NIP-44 encryption, event validation -- **๐Ÿ’ฐ Payments Ready**: Lightning zaps (NIP-57), Cashu wallets (NIP-60), Wallet Connect (NIP-47) -- **๐Ÿ“ฑ Production Ready**: TypeScript, testing, deployment, and responsive design included +A fresh copy fails lint until it's made into a real app. The rules check for things every app needs, so an agent can't finish without them: -## ๐Ÿ›  Technology Stack +- a ``, a meta description and Open Graph tags in `index.html` +- a web manifest at `public/manifest.webmanifest` +- no `FIXME` comments left (the starter page and the font setup have them) -- **React 18.x**: Stable version with hooks, concurrent rendering, and improved performance -- **TailwindCSS 3.x**: Utility-first CSS framework for styling -- **Vite**: Fast build tool and development server -- **shadcn/ui**: 48+ unstyled, accessible UI components built with Radix UI -- **Nostrify**: Nostr protocol framework for Deno and web -- **React Router**: Client-side routing with BrowserRouter -- **TanStack Query**: Data fetching, caching, and state management -- **TypeScript**: Type-safe JavaScript development +## What's included -## ๐ŸŽฏ Real-World Examples +- **Login:** `LoginArea` opens a dialog for signing up, a browser extension (NIP-07), a private key or a remote signer (NIP-46), and becomes an account switcher once logged in. +- **Hooks:** `useCurrentUser`, `useAuthor`, `useNostrPublish`, `useUploadFile` (Blossom), `useLoggedInAccounts`, `useTheme`, `useIsMobile` and others in `src/hooks/`. +- **Relays:** a default relay pool, and the user's NIP-65 relay list loaded on login and published when it changes. +- **NIP-19 routing:** `npub`, `nprofile`, `note`, `nevent` and `naddr` identifiers are routed at the URL root to `src/pages/NIP19Page.tsx`. +- **UI:** about 50 shadcn/ui components in `src/components/ui/`, with light and dark themes. +- **Security defaults:** a strict Content Security Policy in `index.html` and lint rules against inline scripts. -### Built with One Prompt +## Building with an agent -Each of these applications was created with just a single prompt to Dork AI: +`AGENTS.md` is the system prompt for agents working in a project made from this template. It covers the project's conventions, how to design Nostr events, and its security model: private keys live in `localStorage`, so any XSS can steal them. -- **Group Chat Application**: `"Build me a group chat application"` - - [Live Demo](https://groupchat-74z9j26wq-mks-projects-1f1254c4.vercel.app/) +Bigger features come as skills in `.agents/skills/`, which agents load when a task needs them. Several ship ready-made code in a `files/` folder: -- **Decentralized Goodreads**: `"Build a decentralized goodreads alternative. Use OpenLibrary API for book data."` - - [Live Demo](https://bookstr123-87phkwjcy-mks-projects-1f1254c4.vercel.app/) +| Skill | For | +| ----------------------- | ---------------------------------------------------------- | +| `nostr-security` | The full threat model, URL and CSS sanitizing | +| `nip19-routing` | Filling in `NIP19Page` for each identifier type | +| `note-content` | Rendering note text with links, mentions, media and embeds | +| `nostr-comments` | NIP-22 comments on events or any external content | +| `nostr-infinite-scroll` | Paginated feeds | +| `nostr-encryption` | NIP-44 and NIP-04 encryption through the user's signer | +| `nostr-relay-pools` | Querying or publishing to specific relays | +| `relay-management` | A settings UI for the user's relay list | +| `edit-profile` | A profile editing form | +| `file-uploads` | Blossom uploads and NIP-94 `imeta` tags | +| `nip85-stats` | Follower, reaction and zap counts from NIP-85 providers | +| `nwc` | Lightning wallets (NWC, WebLN) and zaps | +| `onchain-bitcoin` | A Bitcoin wallet derived from the user's Nostr key | +| `ai-chat` | Streaming AI chat interfaces | +| `capacitor` | Native iOS and Android apps | +| `lockdown-mode` | What works under Apple's Lockdown Mode | +| `plausible-analytics` | Plausible Analytics | +| `theming` | Fonts, colors and themes | +| `testing` | Writing Vitest tests with the `TestApp` wrapper | -- **Chess Game**: `"Build a chess game with NIP 64"` - - [Live Demo](https://chess-l0d7ms7m3-mks-projects-1f1254c4.vercel.app/chess) +`.mcp.json` (Claude Code) and `opencode.json` (OpenCode) connect agents to the [Nostrbook](https://nostrbook.dev) MCP server, which looks up NIPs and event kinds. -### Production Apps - -Real Nostr applications built using MKStack: - -- **[Chorus](https://chorus.community/)**: Facebook-style groups on Nostr with built-in eCash wallet -- **[Blobbi](https://www.blobbi.pet/)**: Digital pet companions that live forever on the decentralized web -- **[Treasures](https://treasures.to/)**: Decentralized geocaching adventure powered by Nostr - -[Browse more apps made with MKStack โ†’](https://nostrhub.io/apps/t/mkstack/) - -## ๐Ÿ”ง Core Features - -### Authentication & Users -- `LoginArea` component with account switching -- `useCurrentUser` hook for authentication state -- `useAuthor` hook for fetching user profiles -- NIP-07 browser signing support -- Multi-account management - -### Nostr Protocol Support -- **Social Features**: User profiles (NIP-01), follow lists (NIP-02), reactions (NIP-25), reposts (NIP-18) -- **Messaging**: Private DMs (NIP-17), public chat (NIP-28), group chat (NIP-29), encryption (NIP-44) -- **Payments**: Lightning zaps (NIP-57), Cashu wallets (NIP-60), Nutzaps (NIP-61), Wallet Connect (NIP-47) -- **Content**: Long-form articles (NIP-23), file metadata (NIP-94), live events (NIP-53), calendars (NIP-52) - -### Data Management -- `useNostr` hook for querying and publishing -- `useNostrPublish` hook with automatic client tagging -- Event validation and filtering -- Infinite scroll with TanStack Query -- Multi-relay support - -### UI Components -- 48+ shadcn/ui components (buttons, forms, dialogs, etc.) -- `NoteContent` component for rich text rendering -- `EditProfileForm` for profile management -- `RelaySelector` for relay switching -- `CommentsSection` for threaded discussions -- Light/dark theme system - -### Media & Files -- `useUploadFile` hook with Blossom server integration -- NIP-94 compatible file metadata -- Image and video support -- File attachment to events - -### Advanced Features -- NIP-19 identifier routing (`npub1`, `note1`, `nevent1`, `naddr1`) -- Cryptographic operations (encryption/decryption) -- Lightning payments and zaps -- Real-time event subscriptions -- Responsive design with mobile support - -## ๐Ÿค– AI Development with Dork - -MKStack includes Dork, a built-in AI agent that understands your codebase and Nostr protocols: - -### Supported AI Providers - -Configure your AI provider with `stacks configure`: - -- **OpenRouter** ([openrouter.ai](https://openrouter.ai/)): Enter your API key from settings -- **Routstr** ([routstr.com](https://www.routstr.com/)): Use Cashu tokens for payment -- **PayPerQ** ([ppq.ai](https://ppq.ai/)): OpenAI-compatible API - -### How Dork Works - -- **Context-Aware**: Understands your entire codebase and project structure -- **Nostr Expert**: Built-in knowledge of 50+ NIPs and best practices -- **Instant Implementation**: Makes changes directly to your code following React/TypeScript best practices - -Example prompts: -```bash -"Add user profiles with avatars and bio" -"Implement NIP-17 private messaging" -"Add a dark mode toggle" -"Create a marketplace with NIP-15" -``` - -## ๐Ÿ“ Project Structure +## Project structure ``` src/ -โ”œโ”€โ”€ components/ # UI components -โ”‚ โ”œโ”€โ”€ ui/ # shadcn/ui components (48+ available) -โ”‚ โ”œโ”€โ”€ auth/ # Authentication components -โ”‚ โ””โ”€โ”€ comments/ # Comment system components -โ”œโ”€โ”€ hooks/ # Custom React hooks -โ”‚ โ”œโ”€โ”€ useNostr # Core Nostr integration -โ”‚ โ”œโ”€โ”€ useAuthor # User profile data -โ”‚ โ”œโ”€โ”€ useCurrentUser # Authentication state -โ”‚ โ”œโ”€โ”€ useNostrPublish # Event publishing -โ”‚ โ”œโ”€โ”€ useUploadFile # File uploads -โ”‚ โ””โ”€โ”€ useZaps # Lightning payments -โ”œโ”€โ”€ pages/ # Page components -โ”œโ”€โ”€ lib/ # Utility functions -โ”œโ”€โ”€ contexts/ # React context providers -โ””โ”€โ”€ test/ # Testing utilities +โ”œโ”€โ”€ components/ +โ”‚ โ”œโ”€โ”€ ui/ shadcn/ui components +โ”‚ โ””โ”€โ”€ auth/ login dialog and account switcher +โ”œโ”€โ”€ contexts/ app config context +โ”œโ”€โ”€ hooks/ Nostr, account and UI hooks +โ”œโ”€โ”€ lib/ utilities, polyfills, default relays and Blossom servers +โ”œโ”€โ”€ pages/ Index, NIP19Page, NotFound +โ”œโ”€โ”€ test/ TestApp wrapper and test setup +โ”œโ”€โ”€ App.tsx providers +โ””โ”€โ”€ AppRouter.tsx routes +eslint-rules/ the template's custom lint rules +.agents/skills/ skills for agents +AGENTS.md agent instructions ``` -## ๐ŸŽจ UI Components +## Deploying -MKStack includes 48+ shadcn/ui components: +`npm run build` produces a static site in `dist/` that any static host can serve. The app routes on the client, so the host has to serve `index.html` for unknown paths. Hosts that fall back to `404.html`, such as GitHub Pages and nsite gateways, get that from the build. -**Layout**: Card, Separator, Sheet, Sidebar, ScrollArea, Resizable -**Navigation**: Breadcrumb, NavigationMenu, Menubar, Tabs, Pagination -**Forms**: Button, Input, Textarea, Select, Checkbox, RadioGroup, Switch, Slider -**Feedback**: Alert, AlertDialog, Toast, Progress, Skeleton -**Overlay**: Dialog, Popover, HoverCard, Tooltip, ContextMenu, DropdownMenu -**Data Display**: Table, Avatar, Badge, Calendar, Chart, Carousel -**And many more... +## Apps built with MKStack -## ๐Ÿ” Security & Best Practices +- [Chorus](https://chorus.community/): groups on Nostr with a built-in eCash wallet +- [Blobbi](https://www.blobbi.pet/): digital pets that live on Nostr +- [Treasures](https://treasures.to/): geocaching on Nostr -- **Never use `any` type**: Always use proper TypeScript types -- **Event validation**: Filter events through validator functions for custom kinds -- **Efficient queries**: Minimize separate queries to avoid rate limiting -- **Proper error handling**: Graceful handling of invalid NIP-19 identifiers -- **Secure authentication**: Use signer interface, never request private keys directly +[More apps made with MKStack](https://nostrhub.io/apps/t/mkstack/) -## ๐Ÿ“ฑ Responsive Design +## License -- Mobile-first approach with Tailwind breakpoints -- `useIsMobile` hook for responsive behavior -- Touch-friendly interactions -- Optimized for all screen sizes - -## ๐Ÿงช Testing - -- Vitest with jsdom environment -- React Testing Library with jest-dom matchers -- `TestApp` component provides all necessary context providers -- Mocked browser APIs (matchMedia, scrollTo, IntersectionObserver, ResizeObserver) - -## ๐Ÿš€ Deployment - -Built-in deployment to NostrDeploy.com: - -```bash -npm run deploy -``` - -Your app goes live instantly with: -- Automatic builds -- CDN distribution -- HTTPS support -- Custom domains available - -## ๐Ÿ“š Documentation - -For detailed documentation on building Nostr applications with MKStack: - -- [Tutorial](https://soapbox.pub/blog/mkstack-tutorial) -- [Nostr Protocol Documentation](https://nostr.com) -- [shadcn/ui Components](https://ui.shadcn.com) - -## ๐Ÿค Contributing - -MKStack is open source and welcomes contributions. The framework is designed to be: - -- **Extensible**: Easy to add new NIPs and features -- **Maintainable**: Clean architecture with TypeScript -- **Testable**: Comprehensive testing setup included -- **Documented**: Clear patterns and examples - -## ๐Ÿ“„ License - -MKStack is dedicated to the **public domain**. - -To the extent possible under law, the authors have waived all copyright and related or neighboring rights to MKStack. You are free to copy, modify, distribute, and use this software for any purpose, commercial or non-commercial, without asking permission and without attribution. - -Build amazing Nostr applications and help grow the decentralized web! - ---- - -**"Vibed with MKStack"** - [Learn more about MKStack](https://soapbox.pub/mkstack) - -*Build your Nostr app in minutes, not months. Start with AI, deploy instantly.* \ No newline at end of file +MKStack is dedicated to the public domain. To the extent possible under law, the authors have waived all copyright and related or neighboring rights to it.