Skip to content
/ AudiFi Public
generated from github/spark-template

AudiFi is a next-generation music IP platform where independent artists mint 1/1 master recordings as NFTs, retain full ownership, and earn perpetual royalties through programmable smart contracts.

License

Notifications You must be signed in to change notification settings

cywf/AudiFi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

109 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AudiFi (NFT Tracks)

AudiFi is a Web3 platform for independent music artists to mint their tracks as NFTs, retain full ownership, and earn perpetual royalties through the innovative "Mover Advantage" system.

๐ŸŽต Overview

AudiFi empowers artists to:

  • Upload music tracks and artwork
  • Configure release metadata (genre, BPM, mood, description)
  • Mint tracks as NFTs with fractional ownership (Master IPO)
  • Earn automatic royalties on all secondary market resales
  • Engage fans through V Studio interactive sessions

This repository contains:

  • Frontend: React + TypeScript SPA in /src (deployed to Vercel)
  • Backend: Node.js/Express API in /server (deployed to Fly.io)
  • Database: Drizzle ORM schemas in /db (Neon PostgreSQL)
  • Infrastructure: Docker/Kubernetes configs in /deploy

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                              INTERNET                                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ”‚                               โ”‚
                    โ–ผ                               โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚     Vercel (Frontend)      โ”‚   โ”‚       Fly.io (Backend API)        โ”‚
    โ”‚     https://audifi.io      โ”‚   โ”‚   https://audifi-api.fly.dev      โ”‚
    โ”‚                            โ”‚   โ”‚                                   โ”‚
    โ”‚  โ€ข React + Vite            โ”‚   โ”‚  โ€ข Node.js + Express              โ”‚
    โ”‚  โ€ข Static assets           โ”‚   โ”‚  โ€ข REST API                       โ”‚
    โ”‚  โ€ข Client-side only        โ”‚โ”€โ”€โ–ถโ”‚  โ€ข Authentication                 โ”‚
    โ”‚  โ€ข NO database access      โ”‚   โ”‚  โ€ข Business logic                 โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                    โ”‚
                                                    โ–ผ
                                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                    โ”‚      Neon (PostgreSQL)            โ”‚
                                    โ”‚   host.neon.tech:5432             โ”‚
                                    โ”‚                                   โ”‚
                                    โ”‚  โ€ข Serverless Postgres            โ”‚
                                    โ”‚  โ€ข Auto-scaling                   โ”‚
                                    โ”‚  โ€ข SSL required                   โ”‚
                                    โ”‚  โ€ข Drizzle ORM                    โ”‚
                                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Separation Points

  1. Frontend (Vercel): Static React app, no database access
  2. Backend (Fly.io): Express API, sole database accessor
  3. Database (Neon): PostgreSQL with SSL, accessed only by backend

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 20+
  • Neon PostgreSQL database (https://neon.tech)
  • Docker (optional, for containerized deployment)

Frontend Setup

npm install
npm run dev

The app will be available at http://localhost:5173.

Backend Setup

cd server
npm install
npm run dev

The API will be available at http://localhost:3001.

Environment Variables

Copy the example env files and configure:

# Root (frontend)
cp .env.example .env

# Server (backend)
cp server/.env.example server/.env

Frontend environment variables: (.env)

  • VITE_API_URL - Backend API URL (e.g., http://localhost:3001)
  • VITE_WS_URL - WebSocket URL for real-time features

Backend environment variables: (server/.env)

  • DATABASE_URL - Neon PostgreSQL connection string (required)
  • JWT_SECRET - Secret for JWT token signing (min 32 chars)
  • SENDGRID_API_KEY - For magic link emails (optional in development)

โš ๏ธ Important: DATABASE_URL should NEVER be set in the frontend environment.

Database Setup (Neon)

  1. Create a free database at Neon
  2. Copy your connection string from the Neon dashboard
  3. Set DATABASE_URL in server/.env
cd server

# Generate migrations from schema
npm run db:generate

# Apply migrations to database
npm run db:migrate

# Or push schema directly (development)
npm run db:push

๐Ÿ“ Project Structure

โ”œโ”€โ”€ src/                       # Frontend React application (Vercel)
โ”‚   โ”œโ”€โ”€ api/                   # API client layer (calls Fly.io backend)
โ”‚   โ”œโ”€โ”€ components/            # React components
โ”‚   โ”œโ”€โ”€ pages/                 # Route pages
โ”‚   โ””โ”€โ”€ types/                 # TypeScript types
โ”œโ”€โ”€ server/                    # Backend Node.js/Express API (Fly.io)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ config/            # Configuration + env validation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ index.ts       # Main config
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ env.ts         # Environment variable handling
โ”‚   โ”‚   โ”œโ”€โ”€ db/                # Database client (Neon) & schema
โ”‚   โ”‚   โ”œโ”€โ”€ middleware/        # Express middleware
โ”‚   โ”‚   โ”œโ”€โ”€ routes/            # API routes
โ”‚   โ”‚   โ””โ”€โ”€ services/          # Business logic
โ”‚   โ”œโ”€โ”€ Dockerfile             # Backend container image
โ”‚   โ”œโ”€โ”€ fly.toml               # Fly.io deployment config
โ”‚   โ””โ”€โ”€ drizzle.config.ts      # Drizzle Kit configuration
โ”œโ”€โ”€ db/                        # Shared database schemas (Neon)
โ”‚   โ””โ”€โ”€ schema/                # Drizzle ORM table definitions
โ”œโ”€โ”€ deploy/                    # Infrastructure configs
โ”‚   โ”œโ”€โ”€ docker-compose.yml.example
โ”‚   โ””โ”€โ”€ Caddyfile.example
โ”œโ”€โ”€ .github/workflows/         # CI/CD pipelines
โ”‚   โ”œโ”€โ”€ backend.yml            # Backend tests + Fly.io deployment
โ”‚   โ””โ”€โ”€ frontend.yml           # Frontend tests + Vercel deployment
โ””โ”€โ”€ docs/                      # Documentation

๐Ÿ” Authentication

AudiFi uses JWT-based authentication with magic link passwordless login:

  1. User requests magic link via email
  2. Token is stored in database with 15-minute expiry
  3. User clicks link, token is verified and consumed
  4. JWT access token (short-lived) + refresh token (30 days) issued
  5. Optional 2FA via TOTP (Google Authenticator compatible)

Wallet Linking

Users can link Web3 wallets with signature verification:

POST /api/v1/auth/wallet
{
  "address": "0x...",
  "chain": "ethereum",
  "signature": "0x...",
  "message": "Sign this message to link your wallet"
}

๐ŸŽฏ Key Features

Master IPO

  • Artists can create "Masters" (tracks/albums) and launch IPOs
  • Configurable supply (1 to 1,000,000 NFTs)
  • "Mover Advantage" system rewards early minters with perpetual royalties

V Studio

  • Interactive fan sessions during creative process
  • Decision points where fans vote on creative choices
  • Eligibility rules (NFT holders, coin holders, subscribers)

Multi-Chain Support

  • Ethereum, Polygon, Base networks supported
  • Chain selection per IPO
  • Wallet linking per chain

๐Ÿงช Development

Running Tests

# Frontend
npm test

# Backend
cd server
npm test

Type Checking

# Frontend
npm run type-check

# Backend
cd server
npm run type-check

Linting

# Frontend
npm run lint

# Backend
cd server
npm run lint

๐Ÿš€ Deployment

Production Architecture

Component Platform URL
Frontend Vercel https://audifi.io
Backend API Fly.io https://audifi-api.fly.dev
Database Neon (internal connection)

Backend Deployment (Fly.io)

The backend API is deployed to Fly.io via GitHub Actions.

Required GitHub Secrets:

  • DATABASE_URL - Neon PostgreSQL connection string
  • FLY_API_TOKEN - Fly.io API token
  • FLY_APP_STAGING - Staging app name
  • FLY_APP_PRODUCTION - Production app name

Manual deployment:

cd server
flyctl deploy

Required Fly.io secrets:

flyctl secrets set DATABASE_URL=postgresql://...@host.neon.tech:5432/db
flyctl secrets set JWT_SECRET=your-jwt-secret
flyctl secrets set SENDGRID_API_KEY=your-sendgrid-key

Frontend Deployment (Vercel)

The frontend is automatically deployed via Vercel Git integration.

Environment Variables (Vercel Dashboard):

  • VITE_API_URL - Backend API URL (e.g., https://api.audifi.io)
  • VITE_WS_URL - WebSocket URL

Local Development (Docker Compose)

For local development with Docker:

cp deploy/docker-compose.yml.example deploy/docker-compose.yml
cp deploy/.env.example deploy/.env
cd deploy
docker compose up -d

๐Ÿ“ API Documentation

See docs/api/overview.md for full API reference.

Key Endpoints

Endpoint Method Description
/api/v1/health GET Health check with dependency status
/api/v1/auth/magic-link POST Request magic link
/api/v1/auth/verify-magic-link POST Verify and get tokens
/api/v1/auth/refresh POST Refresh access token
/api/v1/masters GET/POST List/create masters
/api/v1/masters/:id/ipo POST Create IPO for master

๐Ÿ”ฎ Tech Stack

Frontend

  • React 19 + TypeScript
  • React Router v7
  • Tailwind CSS v4
  • shadcn/ui components

Backend

  • Node.js 20 + TypeScript
  • Express.js
  • Drizzle ORM + Neon PostgreSQL
  • JWT authentication
  • ethers.js for Web3

Infrastructure

  • Frontend: Vercel
  • Backend API: Fly.io
  • Database: Neon (PostgreSQL)
  • Local Dev: Docker Compose

๐Ÿ“„ License

The Spark Template files and resources from GitHub are licensed under the terms of the MIT license, Copyright GitHub, Inc.

About

AudiFi is a next-generation music IP platform where independent artists mint 1/1 master recordings as NFTs, retain full ownership, and earn perpetual royalties through programmable smart contracts.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages