Complete monorepo for the Muse AI Art Marketplace. Includes React frontend, Node.js backend, and Rust smart contracts for decentralized art commerce.
- Node.js >= 18.0.0
- npm >= 9.0.0
- MongoDB (local, Docker, or MongoDB Atlas)
- Redis (optional, for caching)
git clone https://github.com/Muse-AI-Generated-Art-Marketplace/muse-fullstack-dapp.git
cd muse-fullstack-dappnpm installThis is the most important step! The application requires environment configuration for database, API keys, and blockchain settings.
# Copy environment templates
cp .env.example .env
cp apps/backend/.env.example apps/backend/.env
cp apps/frontend/.env.example apps/frontend/.env
# Edit files with your configuration
nano apps/backend/.env # or use your preferred editor
nano apps/frontend/.envnpm run validate-envnpm run devThis starts:
- Frontend: http://localhost:3000
- Backend: http://localhost:3001
- MongoDB: Required at
mongodb://localhost:27017/muse
The application requires environment variables in three main areas:
# Server
PORT=3001
NODE_ENV=development
# Database
MONGODB_URI=mongodb://localhost:27017/muse
# Authentication
JWT_SECRET=your_secure_secret_here_min_32_chars
# Blockchain
STELLAR_NETWORK=testnet
STELLAR_RPC_URL=https://soroban-testnet.stellar.org
STELLAR_CONTRACT_ID=CA...
# AI Services
OPENAI_API_KEY=sk-...
STABILITY_API_KEY=sk-...VITE_API_URL=http://localhost:3001
VITE_ENVIRONMENT=development- MongoDB: Database for user and artwork data
- Redis (optional): Caching layer (falls back to in-memory)
# MongoDB
docker run -d -p 27017:27017 --name mongo mongo:6
# Redis (optional)
docker run -d -p 6379:6379 --name redis redis:7For detailed environment setup instructions, see ENVIRONMENT_SETUP.md
muse-fullstack-dapp/
βββ apps/
β βββ backend/ # Express.js REST API
β βββ frontend/ # React + TypeScript + Vite
β βββ web/ # Secondary web app
βββ packages/
β βββ contracts/ # Stellar Soroban smart contracts
βββ scripts/
β βββ validate-env.js # Environment validator
βββ ENVIRONMENT_SETUP.md # Detailed environment guide
βββ package.json # Root workspace config
- Express.js REST API server
- MongoDB database integration
- JWT authentication
- Stellar blockchain integration
- AI service integration (OpenAI, Stability AI)
- Redis caching layer
- React 18 with TypeScript
- Vite build tool
- Tailwind CSS styling
- Stellar wallet integration (Freighter)
- Artwork gallery and minting interface
- Stellar Soroban smart contracts (Rust)
- NFT minting functionality
- Marketplace smart contract logic
# Start all services in development mode
npm run dev
# Start individual services
npm run dev:backend
npm run dev:frontend
npm run dev:web
# Build for production
npm run build
npm run build:backend
npm run build:frontend
# Run tests
npm run test
# Run linter
npm run lint
# Validate environment configuration
npm run validate-env
# Clean all dependencies
npm run clean# Run all tests
npm run test
# Run specific workspace tests
npm run test --workspace=muse-backend
npm run test --workspace=muse-frontendcd apps/backend
npm run dev # Start development server
npm run test # Run tests with .env.test
npm run build # Build for productioncd apps/frontend
npm run dev # Start Vite dev server
npm run build # Build for production
npm run preview # Preview production buildThe Muse DApp implements comprehensive security headers using Helmet middleware to protect against common web vulnerabilities:
- Purpose: Prevents Cross-Site Scripting (XSS) attacks and data injection
- Configuration: Environment-specific policies
- Development: Report-only mode with
unsafe-inlineandunsafe-evalfor debugging - Production: Strict enforcement with minimal permissions
- Development: Report-only mode with
// CSP Directives
default-src 'self' // Default policy for all resources
script-src 'self' // Scripts from same origin only
style-src 'self' 'unsafe-inline' // Styles allow inline for CSS frameworks
img-src 'self' data: https: // Images with data URIs and HTTPS
font-src 'self' // Fonts from same origin
connect-src 'self' <api-domains> // API connections
frame-ancestors 'none' // Prevent clickjacking
object-src 'none' // Block plugins- X-Frame-Options:
DENY- Prevents clickjacking attacks - frame-ancestors:
'none'- Modern CSP equivalent
- X-Content-Type-Options:
nosniff- Prevents MIME sniffing attacks - Content-Type: Enforced for all responses
- Strict-Transport-Security (HSTS): Production only
max-age=31536000(1 year)includeSubDomainspreload
- upgradeInsecureRequests: Enforces HTTPS in production
- Cross-Origin-Opener-Policy:
same-origin- Isolates browsing contexts - Cross-Origin-Resource-Policy:
cross-origin- Controls resource sharing - Cross-Origin-Embedder-Policy:
require-corp(production) - Requires explicit CORS
- Referrer-Policy:
strict-origin-when-cross-origin- Controls referrer information - Permissions-Policy: Disables unnecessary browser features:
- Geolocation, camera, microphone
- Payment handlers, USB access
- VR/AR displays, clipboard access
- X-XSS-Protection:
1; mode=block- Legacy XSS protection - X-DNS-Prefetch-Control: Disabled to prevent information leakage
.env files to version control
.envfiles are already in.gitignore- Each environment (dev, staging, prod) should have unique secrets
- Rotate secrets regularly in production
- Use strong random values for
JWT_SECRET
The security headers are thoroughly tested in src/tests/securityHeaders.test.ts:
# Run security tests
npm run test -- src/tests/securityHeaders.test.ts
# Test coverage includes:
- All security headers presence and values
- Environment-specific configurations
- CSP directive validation
- Integration with existing middleware# Generate JWT secret (min 32 characters)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"- Development:
.envfile (not committed) - Staging/Production: Use platform-specific secrets:
- GitHub Actions: Secrets tab
- Vercel/Netlify: Environment variables
- AWS: Secrets Manager or Parameter Store
- HashiCorp Vault: For enterprise
- Regular Updates: Keep dependencies updated for security patches
- Environment Isolation: Different secrets per environment
- Monitoring: Monitor security header violations via CSP reports
- Testing: Run security tests in CI/CD pipeline
- Audit: Regular security audits and penetration testing
# macOS
brew install mongod
# Linux (Ubuntu)
sudo apt-get install mongodb
# Start service
mongoddocker run -d -p 27017:27017 \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=password \
--name mongo mongo:6- Create free account at https://www.mongodb.com/cloud/atlas
- Create cluster and database
- Get connection string
- Update
MONGODB_URIin.env
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/muse?retryWrites=true&w=majorityThe application uses Stellar Soroban for smart contracts.
STELLAR_NETWORK=testnet
STELLAR_RPC_URL=https://soroban-testnet.stellar.org- Create Stellar testnet account: https://laboratory.stellar.org
- Request testnet XLM from faucet
- Deploy contract to testnet
- Add contract address to
STELLAR_CONTRACT_ID
- Sign up: https://platform.openai.com
- Get API key: https://platform.openai.com/api-keys
- Set spending limits
- Add to
.env:OPENAI_API_KEY=sk-...
- Sign up: https://api.stability.ai
- Get API key
- Add to
.env:STABILITY_API_KEY=sk-...
Backend API documentation is available at:
- Development: http://localhost:3001/api/docs (if Swagger configured)
- Health Check: http://localhost:3001/health
# Health check
curl http://localhost:3001/health
# Authentication
curl -X POST http://localhost:3001/auth/login
# Artworks
curl http://localhost:3001/api/artworks
# Minting
curl -X POST http://localhost:3001/api/mint1. "Cannot find module" or dependencies error
rm -rf node_modules package-lock.json
npm install2. "MongoDB connection refused"
# Check MongoDB is running
mongosh
# Or start with Docker
docker run -d -p 27017:27017 mongo:6
# Update .env
MONGODB_URI=mongodb://localhost:27017/muse3. "JWT_SECRET undefined"
# Generate secure secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Add to apps/backend/.env
JWT_SECRET=<generated-value>4. "Port already in use"
# Change in .env
PORT=3002 # or another available port
# Kill process on port
lsof -i :3001
kill -9 <PID>5. CORS errors - frontend can't reach backend
- Check
VITE_API_URLmatches backend URL - Check
FRONTEND_URLin backend .env for CORS origin - Check backend is running on correct port
See ENVIRONMENT_SETUP.md#troubleshooting for more solutions.
- ENVIRONMENT_SETUP.md - Comprehensive environment configuration guide
- CACHING_STRATEGY.md - Caching implementation details
- HEALTH_CHECK_IMPLEMENTATION.md - Health check endpoints
- DATABASE_INDEXING_STRATEGY.md - Database optimization
- ERROR_HANDLING.md - Error handling patterns
- Fork the repository
- Create feature branch:
git checkout -b feature/name - Make changes and test:
npm run validate-env && npm run test - Commit with descriptive message
- Push and create Pull Request
MIT License - See LICENSE file for details
For issues and questions:
- Check Documentation: ENVIRONMENT_SETUP.md
- GitHub Issues: Report issues
- Discussions: Ask questions
Built with:
Last Updated: March 27, 2026