A content management and scheduling tool for the Nostr protocol.
Shipyard uses SQLite with Prisma ORM for database management. Follow these steps to set up and work with the database:
-
Install dependencies:
bun install
-
Generate Prisma client:
bun run db:generate
-
Create new .env file:
sudo nano .env
enter computer password paste the following:
DATABASE_URL="file:./dev.db" JWT_SECRET="super-secret-long-random-string"replace super-secret-long-random-string: generate one by running
openssl rand -base64 32 -
Run migrations to create the database:
bun run db:migrate
-
Seed the database with initial data:
bun run db:seed
-
View database: Open Prisma Studio to view and edit the database:
bun run db:studio
-
Reset database: Delete all data and reseed:
bun run db:reset
-
Create new migration: After changing the schema in
prisma/schema.prisma:bun run db:migrate -- --name <migration-name>
Run the development server:
bun run devOpen http://localhost:3000 with your browser to see the result.
The database is structured around these key entities:
- Users: Nostr identities that can access the system
- Accounts: Nostr identities that own content
- Posts: Nostr events (notes, articles, etc.)
- Queues: Organize content within an account
- Schedules: Associate posts with queues and define when they should be published
- Subscriptions: Track subscription status of accounts
- Payments: Track payment transactions
For more details, see the ARCHITECTURE.md and SPEC.md files.
The application provides several API routes for interacting with the database:
- GET /api/accounts?pubkey=: Get all accounts a user has access to
- POST /api/accounts: Create a new account
- GET /api/queues?accountPubkey=: Get all queues for an account
- POST /api/queues: Create a new queue
- DELETE /api/queues?id=: Delete a queue
The database is accessed through a service layer that provides a clean API for interacting with the database:
import { UserService, AccountService, PostService, QueueService, ScheduleService } from '@/lib/services';
// Example: Create a user
const user = await UserService.create('user-pubkey');
// Example: Get all queues for an account
const queues = await QueueService.getByAccount('account-pubkey');