A minimal, open-source "social internet" MVP where users create a self-owned cryptographic identity, post signed messages, and view a global feed over a relay-based network. This is the first working slice of the Foundation Protocol: universal messages + sovereign identity + pluggable network layer.
- Self-Sovereign Identity: Generate and manage cryptographic keypairs locally in your browser
- Signed Messages: All messages are cryptographically signed and immutable
- Global Feed: View messages from all users in reverse chronological order
- Threading: Reply to messages and view conversation threads
- AI Summarization: Optional AI-powered feed summarization (mock or real provider)
- Admin Logs: View system logs with admin authentication
- No Accounts: No email, no passwords, just cryptographic keys
- Next.js 14 - Full-stack React framework
- TypeScript - Type-safe development
- SQLite - Simple database for messages and logs
- Web Crypto API - Cryptographic operations
- React - UI framework
- Node.js 18+
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd TheUnitedNationsofTheEarth- Install dependencies:
npm install- Create a
.envfile (copy from.env.example):
PORT=3000
NODE_ENV=development
ADMIN_TOKEN=your-secure-random-token-here
ENABLE_AI_SUMMARY=true- Seed the database (optional):
npm run db:seed- Start the development server:
npm run dev- Open http://localhost:3000 in your browser
- Navigate to
/identity - Click "Create Identity"
- A cryptographic keypair will be generated and stored locally in your browser
- You can edit your display name at any time
- Navigate to
/feed - Type your message in the composer
- Optionally add tags (comma-separated)
- Click "Post"
- Click "View thread" on any message
- See the root message and all replies
- Reply directly from the thread page
- On the feed page, click "Summarize Feed (AI)"
- The last 20 messages will be summarized
- Works with mock provider (default) or real AI API (if configured)
- Navigate to
/admin/logs - Enter your admin token (set in
ADMIN_TOKENenv var) - View system logs with filtering options
Publish a new message.
Request:
{
"message": {
"id": "string",
"authorPublicKey": "string",
"timestamp": 1234567890,
"contentType": "text",
"contentBody": "string",
"references": [],
"tags": [],
"signature": "string"
}
}List messages.
Query Parameters:
limit(optional, default: 50, max: 200)before(optional, timestamp for pagination)
Get a specific message by ID.
Get all replies to a message.
Get system logs (requires admin token).
Headers:
X-Admin-Token: Admin authentication token
Query Parameters:
level(optional: "info" | "error")source(optional: "api" | "worker")limit(optional, default: 100)before(optional, timestamp for pagination)
Summarize a list of messages.
Request:
{
"messages": [...],
"maxWords": 100
}PORT- Server port (default: 3000)NODE_ENV- Environment mode (development | production)ADMIN_TOKEN- Admin authentication token (required)AI_API_KEY- Optional AI provider API keyAI_API_URL- Optional AI provider URL (default: https://api.openai.com/v1)ENABLE_AI_SUMMARY- Enable/disable AI summarization (default: true)DATABASE_PATH- Path to SQLite database (default: ./data/foundation.db)
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ ├── identity/ # Identity page
│ ├── feed/ # Feed page
│ ├── message/[id]/ # Thread page
│ └── admin/logs/ # Admin logs page
├── components/ # React components
├── lib/ # Utility libraries
│ ├── crypto.ts # Cryptographic functions
│ ├── db.ts # Database layer
│ ├── identity.ts # Identity management
│ ├── message.ts # Message utilities
│ ├── ai-provider.ts # AI summarization
│ └── logger.ts # Logging utilities
├── types/ # TypeScript type definitions
└── scripts/ # Utility scripts
- Private keys are stored only in browser localStorage (never sent to server)
- All messages are cryptographically signed and verified
- Message IDs are computed from content (immutable)
- Admin endpoints require token authentication
- HTTPS should be used in production
The project includes acceptance criteria defined in the spec. Manual testing should verify:
- Identity creation and persistence
- Message posting and verification
- Feed loading and display
- Thread viewing and replies
- AI summarization (mock and real)
- Admin log access control
- Error handling
The SQLite database is created automatically on first run. To reset:
- Delete
data/foundation.db - Restart the server
Future iterations may include:
- Real P2P networking to replace/complement relay
- Constitutional constraints
- Reputation layer (Bayesian legitimacy scores)
- Multi-device identity sync via encrypted backup
- Richer content types (JSON payloads, attachments)
Open source - see LICENSE file for details.
Contributions welcome! Please read the spec document for full requirements and architecture details.