tpt-decentralized-social
JavaScriptOpen-source privacy-first decentralized social network — IPFS content storage, end-to-end encryption, self-sovereign identity, DID support, blockchain integration & zero data harvesting. Node.js. MIT.
Languages
TPT Decentralized Social Network
A privacy-focused, decentralized social networking platform built with pure Node.js, PostgreSQL, and modern web technologies.
🚀 Features
- Decentralized Architecture: User-controlled data with IPFS integration
- End-to-End Encryption: Cryptographic key management for secure communications
- Self-Sovereign Identity: Users own their digital identity and data
- Privacy-First Design: No data harvesting, transparent data practices
- Modern UI: Responsive design with Tailwind CSS
- SaaS Model: Subscription tiers with add-on services
- RBAC System: Comprehensive role-based access control
- API-First: RESTful API for third-party integrations
🛠 Tech Stack
- Backend: Pure Node.js (no frameworks)
- Database: PostgreSQL
- Frontend: Vanilla JavaScript + Tailwind CSS
- Decentralization: IPFS, Web3.js
- Authentication: JWT with cryptographic keys
- Payments: Stripe, PayPal, Paddle integration
- Email: Node.js mail with Mailgun fallback
📋 Prerequisites
- Node.js 18+
- PostgreSQL 13+
- IPFS daemon (optional, for full decentralization)
- Git
🚀 Quick Start
-
Clone the repository
git clone https://github.com/yourusername/tpt-social.git cd tpt-social -
Install dependencies
npm install -
Set up PostgreSQL database
CREATE DATABASE tpt_social; CREATE USER tpt_user WITH PASSWORD 'your_password'; GRANT ALL PRIVILEGES ON DATABASE tpt_social TO tpt_user; -
Configure environment variables
cp .env.example .env # Edit .env with your configuration -
Start the server
npm start -
Open your browser
http://localhost:3000
⚙️ Configuration
Environment Variables
Create a .env file in the root directory:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=tpt_social
DB_USER=postgres
DB_PASSWORD=your_password
# JWT Secret
JWT_SECRET=your-super-secret-jwt-key
# Email Configuration
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-email-password
# Stripe Configuration
STRIPE_SECRET_KEY=sk_test_your-stripe-secret-key
STRIPE_PUBLISHABLE_KEY=pk_test_your-stripe-publishable-key
# Mailgun Configuration
MAILGUN_API_KEY=your-mailgun-api-key
MAILGUN_DOMAIN=your-mailgun-domain.com
# Server Configuration
PORT=3000
NODE_ENV=development
# IPFS Configuration
IPFS_HOST=localhost
IPFS_PORT=5001
IPFS_PROTOCOL=http
# Web3 Configuration
WEB3_PROVIDER_URL=https://mainnet.infura.io/v3/your-infura-project-id
📁 Project Structure
tpt-social/
├── server.js # Main server file
├── package.json # Dependencies and scripts
├── .env # Environment configuration
├── views/ # HTML templates
│ └── index.html # Homepage
├── static/ # Static assets
│ ├── css/
│ │ └── styles.css # Styles with Tailwind
│ └── js/
│ └── app.js # Frontend JavaScript
├── business_case.md # Business documentation
├── rbac_roles.md # RBAC documentation
├── todo.md # Development checklist
└── README.md # This file
🔐 Authentication & Security
User Registration
- Email verification required
- Cryptographic key pair generation
- Password hashing with bcrypt
- JWT token issuance
Data Encryption
- Client-side encryption before transmission
- Server-side encryption at rest
- User-controlled private keys
- End-to-end encrypted messaging
Access Control
- Role-Based Access Control (RBAC)
- Permission-based API endpoints
- Session management with automatic logout
- Multi-factor authentication support
💰 Subscription & Payments
Pricing Tiers
| Plan | Price | Features | |------|-------|----------| | Basic | $9.99/mo | Up to 100 posts, basic encryption | | Pro | $19.99/mo | Unlimited posts, advanced features | | Enterprise | Custom | All features, white-label options |
Payment Integration
- Stripe: Primary payment processor
- PayPal: Alternative payment method
- Paddle: Additional gateway support
- Webhook handling for subscription events
- Automatic billing and dunning management
🌐 Decentralization Features
IPFS Integration
- Decentralized file storage
- Content addressing with hashes
- Peer-to-peer content distribution
- Immutable content history
Self-Sovereign Identity
- DID (Decentralized Identifier) support
- Verifiable credentials
- User-controlled identity data
- Cross-platform identity portability
Blockchain Integration
- Smart contract interactions
- On-chain reputation systems
- Decentralized governance
- Cryptocurrency payments
📊 API Documentation
Authentication Endpoints
POST /api/auth/register
Register a new user account.
Request Body:
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword"
}
Response:
{
"token": "jwt_token_here",
"userId": 123,
"publicKey": "rsa_public_key"
}
POST /api/auth/login
Authenticate an existing user.
Request Body:
{
"email": "john@example.com",
"password": "securepassword"
}
Response:
{
"token": "jwt_token_here",
"userId": 123,
"publicKey": "rsa_public_key"
}
Content Endpoints
GET /api/posts
Retrieve user posts (authenticated).
POST /api/posts
Create a new post (authenticated).
Request Body:
{
"content": "Hello, decentralized world!",
"isPublic": true,
"tags": ["decentralization", "privacy"]
}
🧪 Testing
Unit Tests
npm test
Integration Tests
npm run test:integration
End-to-End Tests
npm run test:e2e
🚀 Deployment
Development
npm run dev
Production
NODE_ENV=production npm start
Docker Deployment
docker build -t tpt-social .
docker run -p 3000:3000 tpt-social
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
- Documentation: docs.tptsocial.com
- Email Support: support@tptsocial.com
- Community Forum: forum.tptsocial.com
- FAQ: help.tptsocial.com
🗺 Roadmap
Phase 1 (Current)
- ✅ Basic user authentication
- ✅ PostgreSQL integration
- ✅ Frontend UI with Tailwind CSS
- ✅ RBAC system foundation
- 🔄 IPFS integration
- 🔄 Payment processing
Phase 2 (Next 3 months)
- 🔄 End-to-end encryption
- 🔄 Decentralized identity
- 🔄 Mobile app development
- 🔄 Advanced analytics
- 🔄 Enterprise features
Phase 3 (6+ months)
- 🔄 Blockchain integration
- 🔄 Decentralized governance
- 🔄 Global scaling
- 🔄 AI-powered features
📞 Contact
TPT Social Team
- Website: tptsocial.com
- Email: hello@tptsocial.com
- Twitter: @TPTSocial
Built with ❤️ for privacy and decentralization