Decentralized platform for AI-generated music, powered by NEAR Protocol.
Creators upload AI-generated songs, listeners discover and tip artists — all on-chain via NEAR smart contracts. No middlemen.
Live: https://near.fm
┌─────────────┐ ┌──────────────┐ ┌────────────────┐
│ Next.js │────▶│ Rust/Axum │────▶│ PostgreSQL │
│ Frontend │ │ API Server │ │ (testnet/ │
│ :3847 │ │ :8477 │ │ mainnet) │
└─────────────┘ └──────┬───────┘ └────────────────┘
│
┌──────▼───────┐
│ NEAR Protocol│
│ (RPC + Smart │
│ Contract) │
└──────────────┘
web/— Next.js 14 frontend (App Router, Tailwind CSS)server/— Rust API server (Axum, SQLx, PostgreSQL)contract/— NEAR smart contract (tips, bounties, virtual balances)
- Auth: NEAR wallet signature → server verifies → issues JWT
- Upload: Audio file → FastFS (NEAR storage) → metadata saved to DB
- Tips: User calls smart contract → server verifies tx on-chain → records in DB
- Bounties: Requester deposits NEAR → creators submit songs → requester awards winner on-chain
Two PostgreSQL containers for network isolation:
| Container | Port | Volume | Network |
|---|---|---|---|
postgres |
5499 | pgdata |
testnet |
postgres-mainnet |
5508 | pgdata_mainnet |
mainnet |
Migrations run automatically on server startup (server/migrations/).
users— NEAR accounts, reputation, ban/mute statussongs— uploaded tracks with metadata, votes, play countsvotes— upvotes/downvotes with reputation-weighted scoringtips— on-chain verified tip recordscomments— song comments (require 1 NEAR virtual balance)song_requests— bounty requests with on-chain depositsrequest_submissions— songs submitted to fulfill requestsbookmarks,reports,notifications,categories,languages
Two .env files for network switching:
.env.testnet— testnet config (near-fm.testnet,postgres).env.mainnet— mainnet config (near-fm.near,postgres-mainnet)
Switch networks:
cp .env.mainnet .env # or .env.testnet
docker compose build server web && docker compose up -d server web| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection (points to testnet or mainnet container) |
NEAR_NETWORK |
testnet or mainnet |
CONTRACT_ID |
Smart contract (near-fm.testnet / near-fm.near) |
NEAR_RPC_URL |
NEAR RPC endpoint |
FASTFS_RECEIVER |
FastFS storage contract |
ADMIN_ACCOUNTS |
Comma-separated admin NEAR accounts |
JWT_SECRET |
JWT signing secret |
cd /home/nextjs-user/code/near-fm
docker compose build server web
docker compose up -d server webGit push (deploy key required):
GIT_SSH_COMMAND="ssh -i /home/nextjs-user/.ssh/deploykey_rw -o IdentitiesOnly=yes" git push origin mainnear.fm→ web (:3847)api.near.fm→ server (:8477)upload.near.fm→ separate upload frontend (:3847, same container)
Admin accounts defined in ADMIN_ACCOUNTS env var. Admin panel at /admin with tabs:
- Reports — review flagged songs (hide/dismiss)
- Songs — search, hide, delete songs
- Requests — moderate bounty requests, edit titles
- Comments — hide comments, mute/ban users
- Categories — manage song categories