The Frequency Developer Gateway is a suite of microservices designed to simplify interactions with the Frequency blockchain, bridging the gap between Web2 and Web3 development. It provides a familiar REST API interface that abstracts away complex blockchain operations, making it more accessible for traditional web developers. As a decentralized SSO solution, it offers OAuth2-style endpoints and standard flows that mirror traditional providers while leveraging blockchain technology for enhanced security, transparency, and user data sovereignty.
Core Purpose
mindmap
root((Frequency Developer Gateway))
Purpose
Bridge Web2 and Web3
Simplify blockchain interactions
Enable social applications
Abstract complex operations
Provide familiar REST APIs
Value Proposition
Lower adoption barriers
Accelerate development
Promote decentralization
Maintain flexibility
Enable diverse implementations
SSO Capabilities
mindmap
root((Decentralized SSO))
Traditional Integration
OAuth2-Style Endpoints
/authorize endpoint
/token endpoint
Standard SSO Flows
Compatible API Interfaces
Drop-in Replacement
Blockchain Features
Decentralized Authentication
User-Owned Identity
Granular Permissions
Itemized Control
User Data Sovereignty
Audit Trail
Transparent
Immutable
Open Integration Model
mindmap
root((Graph Service))
Core Functionality
Fetch social graphs
Update social connections
Watch graph changes
Manage follows/unfollows
Architecture
API Component
Worker Component
Redis job queue
Graph monitoring
Use Cases
Social network connections
Content discovery
User recommendations
Private vs public graphs
Key Features
Retrieve public and private social connection data
Follow/unfollow users on the network
Monitor changes in social graphs
Support for reconnection services for migrating users
3.3 Content Publishing Service
mindmap
root((Content Publishing Service))
Core Functionality
Asset file uploads
Create broadcasts/posts
Create replies
Create reactions
Update/delete content
Update profiles
Architecture
API Controller
Worker Process
BullMQ Queue
IPFS Integration
Use Cases
Social media posts
Content management
User interactions
Media sharing
Monitor and parse messages on Frequency blockchain
Send content updates to registered webhooks
Filter content by schema and MSA Id
Control scanning operations (start/stop/restart)
Specify custom block ranges for content retrieval
4. Technical Architecture
4.1 Component Interaction
sequenceDiagram
participant Client as Client Application
participant AS as Account Service
participant GS as Graph Service
participant CPS as Content Publishing Service
participant CWS as Content Watcher Service
participant Freq as Frequency Blockchain
Client->>AS: Create/Authenticate User
AS->>Freq: Submit Account Extrinsic
Freq-->>AS: Confirm Account Creation
AS-->>Client: Return Account Details
Client->>GS: Establish Social Connections
GS->>Freq: Update Social Graph
Freq-->>GS: Confirm Graph Update
GS-->>Client: Return Updated Graph
Client->>CPS: Publish New Content
CPS->>IPFS: Store Content Data
IPFS-->>CPS: Return Content URI
CPS->>Freq: Announce Content Publication
Freq-->>CPS: Confirm Publication
CPS-->>Client: Return Content Publication Status
CWS->>Freq: Monitor for New Content
Freq-->>CWS: Send New Content Announcements
CWS->>Client: Deliver Content Updates via Webhook
4.2 Technology Stack
mindmap
root((Technology Stack))
Backend Framework
NestJS
TypeScript
Node.js
Data Management
Redis
BullMQ
Job queues
Blockchain Integration
Polkadot API
DSNP Protocol
Frequency Chain
Storage
IPFS
Testing
Jest
Supertest
E2E Tests
Containerization
Docker
Docker Compose
Documentation
Swagger
OpenAPI
mdBook
5. Setup & Installation
5.1 Prerequisites
Docker and Docker Compose for container management
Node.js for local development
mdBook for building documentation
5.2 Quick Start Guide
git clone git@github.com:ProjectLibertyLabs/gateway.git
cd gateway
./start.sh
flowchart TD
subgraph "User Authentication Flow"
A1[Client App] --> A2[Account Service: Create User]
A2 --> A3[Sign In With Frequency]
A3 --> A4[Return Account & Token]
end
subgraph "Social Connection Flow"
B1[Client App] --> B2[Graph Service: Fetch User's Graph]
B2 --> B3[Follow/Unfollow Users]
B3 --> B4[Return Updated Connections]
end
subgraph "Content Creation Flow"
C1[Client App] --> C2[Content Publishing: Upload Media]
C2 --> C3[Create Post with Media]
C3 --> C4[Return Post Status]
end
subgraph "Content Discovery Flow"
D1[Client Server] --> D2[Content Watcher: Register Webhook]
D2 --> D3[Receive Content Updates]
D3 --> D4[Process & Display to User]
end
6.2 API Usage Examples
Account Service
// Create a user account
POST /api/v1/accounts
{
"handle": "username",
"owner": "0x..."
}
// Retrieve account information
GET /api/v1/accounts/{msaId}
// Add a key to an account
POST /api/v1/accounts/{msaId}/keys
{
"keyType": "...",
"publicKey": "0x..."
}
Graph Service
// Fetch a user's graph
GET /api/v1/graph/{msaId}
// Follow another user
POST /api/v1/graph/{fromMsaId}/connections
{
"toMsaId": 123
}
// Unfollow a user
DELETE /api/v1/graph/{fromMsaId}/connections/{toMsaId}
Content Publishing Service
// Upload an asset
POST /api/v1/assets
[multipart/form-data]
// Create a post
POST /api/v1/broadcasts
{
"fromId": 123,
"content": "Hello world!",
"assets": ["assetId1", "assetId2"]
}
// Create a reply
POST /api/v1/replies
{
"fromId": 123,
"inReplyTo": "urlOfOriginalPost",
"content": "This is a reply"
}
Content Watcher Service
// Register a webhook
POST /api/v1/webhooks
{
"url": "https://example.com/webhook",
"filters": {
"msaIds": [123, 456],
"schemas": ["broadcast", "reply"]
}
}
// Start scanning
POST /api/v1/scanner/start
// Get scanner status
GET /api/v1/scanner/status
7. Development & Testing
7.1 Development Environment
Local Development
Each service can be run locally for development
Supporting services (Redis, Frequency, IPFS) can be run in Docker
Hot-reloading enabled in development mode
Debug configurations available for VSCode
7.2 Testing
Unit Tests
# Run account service tests
npm run test:account
# Run graph service tests
npm run test:graph
# Run content publishing tests
npm run test:content-publishing
# Run content watcher tests
npm run test:content-watcher
E2E Tests
# Run account service E2E tests
make test-e2e-account
# Run graph service E2E tests
npm run test:e2e:graph
# Run content publishing E2E tests
npm run test:e2e:content-publishing
# Run content watcher E2E tests
npm run test:e2e:content-watcher
7.3 Code Quality
# Run linter
npm run lint
# Format code
npm run format