Architecture
lawallet-web
Current Next.js application in the repo, including the REST API and LUD-16 endpoints.
Overview
The main application in lawallet-nwc serves the frontend, REST API, and LUD-16 lightning address resolution.
Container: lawallet-web
Port: 3000
Storage: Own PostgreSQL database (Prisma ORM)
Responsibilities
- Serve frontend (React + Tailwind/shadcn)
- Expose REST API for cards, card designs, users, settings, JWT auth, and remote connections
- Resolve lightning addresses via
/api/lud16/[username] - Optionally create Alby Hub sub-accounts during user creation
- Serve placeholder landing, admin, and wallet pages
Not implemented in the current repo:
.well-known/lnurlpand.well-known/nostr.json- Redirect-based address resolution
- Webhook management and payment history APIs
- A completed user dashboard UI
Tech Stack
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Frontend: React + Tailwind CSS + shadcn/ui
- Database: PostgreSQL via Prisma ORM
- NWC:
@getalby/sdk - Testing: Vitest + React Testing Library + MSW
- Logging: pino
Directory Structure
| Path | Purpose |
|---|---|
/app | Next.js App Router pages and API routes |
/app/admin | Admin dashboard pages |
/app/wallet | Wallet interface |
/app/api | REST API routes |
/components | Shared React components |
/lib | Shared utilities, types, constants |
/prisma | Database schema, migrations, seeds |
Key Endpoints
Authentication
POST /api/jwt— Exchange a NIP-98 request for a JWTGET /api/jwt— Validate an existing JWTGET /api/jwt/protected— Example protected JWT routePOST /api/jwt/protected— Example protected JWT route
Users and Addresses
GET /api/users/me— Load or create the current userPUT /api/users/:id/lightning-address— Assign or replace a usernamePUT /api/users/:id/nwc— Store an NWC URI for the userGET /api/lightning-addresses— Admin list of lightning addressesGET /api/lightning-addresses/counts— Admin countsGET /api/lightning-addresses/relays— Relay informationGET /api/lud16/:username— LUD-16 payRequest for NWC-backed usersGET /api/lud16/:username/cb— LUD-16 callback
Cards and Card Designs
GET /api/cardsandPOST /api/cards— Card listing and creationGET /api/cards/:idandDELETE /api/cards/:id— Card detail and deletionGET /api/cards/:id/write— Card write payloadGET /api/cards/:id/scan— LNURL-withdraw style card scan responseGET /api/cards/:id/scan/cb— Card scan callbackGET /api/cards/otc/:otc— OTC lookupPOST /api/cards/otc/:otc/activate— OTC activationGET /api/card-designs/list— Card designsGET /api/card-designs/count— Card-design countGET /api/card-designs/get/:id— Card-design detailPOST /api/card-designs/import— Import card designs
Admin and Device Flows
GET /api/settingsandPOST /api/settings— Settings managementGET /api/admin/assignandPOST /api/admin/assign— Admin assignmentGET /api/root/assignandPOST /api/root/assign— Root assignmentGET /api/remote-connections/:externalDeviceKey— Remote connection bootstrapPOST /api/remote-connections/:externalDeviceKey/cards— Remote card initialization
External Integrations
- Alby Hub: Optional REST integration used during user creation when automatic provisioning is enabled
- PostgreSQL: Primary datastore
Planned but not currently wired into this repo:
lncurlcourtesy-wallet provisioninglawallet-listenerpayment listener integration