Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Veil — Private by Design

A modern, privacy-first messaging and crypto wallet application built with end-to-end encryption, 2FA authentication, and integrated blockchain wallet support.

TypeScript React Fastify PostgreSQL License

Features

🔐 Security & Privacy

  • End-to-End Encryption: All messages encrypted with libsodium before transmission
  • Two-Factor Authentication (2FA): TOTP-based authentication with recovery codes
  • Password Hashing: Argon2 for secure password storage
  • JWT Authentication: Stateless session management with secure tokens

💬 Messaging

  • Real-time messaging with WebSocket support
  • Message reactions and threaded replies
  • Read receipts
  • Friend system with request management
  • Message editing and deletion

💳 Wallet & Crypto

  • Integrated blockchain wallet (Base network support)
  • USDC token transfers
  • Transaction history
  • Wallet import/creation
  • Balance tracking

✨ Premium Features

  • Premium subscriptions with multiple tiers (Monthly, Yearly, Early Adopter)
  • Custom usernames for premium members
  • Premium badges and status
  • Crypto payments via USDC (Base network)
  • Flexible pricing configuration

🎨 UI/UX

  • Modern React 19 frontend with TypeScript
  • Vite build tool for fast development
  • Tailwind CSS for responsive design
  • Radix UI components for accessibility
  • Dark mode support with next-themes
  • Smooth animations with Framer Motion

Tech Stack

Backend

  • Runtime: Node.js 22+
  • Framework: Fastify 5.0
  • Database: PostgreSQL with Prisma ORM
  • Security:
    • Argon2 (password hashing)
    • libsodium-wrappers (E2E encryption)
    • JWT (authentication)
  • Blockchain: ethers.js, viem (Base network)
  • Additional: WebSocket support, CORS, 2FA with OTP

Frontend

  • Framework: React 19 + Vite 7
  • UI Library: Radix UI + Tailwind CSS
  • HTTP Client: Axios
  • Routing: Wouter
  • Form Management: React Hook Form + Zod validation
  • Charts: Recharts
  • Notifications: Sonner

Project Structure

Veil/
├── frontend/                    # React + Vite frontend
│   ├── client/                 # React components and pages
│   ├── server/                 # Express server for production
│   ├── shared/                 # Shared utilities and types
│   ├── public/                 # Static assets
│   ├── package.json
│   └── vite.config.ts
├── backend/                     # Fastify backend server
│   ├── src/
│   │   ├── index.ts            # Server entry point
│   │   ├── routes/             # API endpoints
│   │   │   ├── auth.ts        # Authentication endpoints
│   │   │   ├── chat.ts        # Messaging endpoints
│   │   │   ├── user.ts        # User management
│   │   │   ├── wallet.ts      # Wallet operations
│   │   │   └── premium.ts     # Premium/subscription handling
│   │   ├── services/           # Business logic
│   │   └── plugins/            # Fastify plugins
│   ├── prisma/
│   │   └── schema.prisma       # Database schema
│   └── package.json
├── .env.example                 # Environment variables template
└── DEPLOYMENT_GUIDE.md         # Detailed deployment instructions

Quick Start

Prerequisites

  • Node.js 18+ (22+ recommended)
  • PostgreSQL 12+
  • pnpm 10+

Local Development Setup

  1. Clone the repository

    git clone https://github.com/basetrackxyz/Veil.git
    cd Veil
  2. Install dependencies

    # Backend
    cd backend
    pnpm install
    
    # Frontend (in new terminal)
    cd frontend
    pnpm install
  3. Setup environment variables

    # Copy .env.example and configure
    cp .env.example .env

    Backend .env essentials:

    DATABASE_URL=postgresql://user:password@localhost:5432/veil
    PORT=4000
    JWT_SECRET=generate-a-strong-secret-key
    CORS_ORIGIN=http://localhost:3000
    ENCRYPTION_KEY=generate-a-strong-encryption-key

    Frontend .env essentials:

    VITE_API_URL=http://localhost:4000
    VITE_APP_NAME=Veil
    VITE_APP_TITLE=Veil - Your Messages, Your Privacy
  4. Setup database

    cd backend
    npx prisma migrate deploy
    npx prisma generate
  5. Start development servers

    # Terminal 1: Backend
    cd backend
    pnpm dev
    # Runs on http://localhost:4000
    
    # Terminal 2: Frontend
    cd frontend
    pnpm dev
    # Runs on http://localhost:3000

API Endpoints

Authentication

  • POST /api/auth/register - Create account
  • POST /api/auth/login - Login
  • POST /api/auth/logout - Logout
  • POST /api/auth/2fa/setup - Setup 2FA
  • POST /api/auth/2fa/verify - Verify 2FA code

Users

  • GET /api/users/search?q=query - Search users
  • GET /api/users/:id - Get user profile
  • PUT /api/users/:id - Update profile

Chat & Messaging

  • GET /api/chat - Get chat list
  • GET /api/chat/:chatId/messages - Get messages (encrypted)
  • POST /api/chat/:chatId/messages - Send message
  • PUT /api/chat/messages/:messageId - Edit message
  • DELETE /api/chat/messages/:messageId - Delete message

Wallet

  • POST /api/wallet/create - Create new wallet
  • POST /api/wallet/import - Import existing wallet
  • GET /api/wallet/balance - Get wallet balance (USDC)
  • POST /api/wallet/send - Send USDC to another user
  • GET /api/wallet/transactions - Get transaction history

Premium

  • GET /api/premium/config - Get pricing configuration
  • POST /api/premium/subscribe - Start premium subscription
  • GET /api/premium/status - Get premium status
  • POST /api/premium/cancel - Cancel subscription

Database Schema

Core Models

  • User: User accounts with authentication and crypto wallet integration
  • Session: Secure session tokens for authentication
  • Message: Encrypted messages with E2E support
  • Friend: Friend relationships between users
  • FriendRequest: Pending friend requests

Premium & Subscription

  • PremiumSubscription: Subscription records with payment tracking
  • PremiumConfig: Configuration for pricing and premium features
  • ReservedUsername: Reserved usernames for system/admin use

Security Features

Encryption: End-to-end encryption using libsodium
Authentication: JWT tokens with secure secrets
Password Security: Argon2 hashing with configurable parameters
2FA: TOTP with recovery codes
CORS: Configurable cross-origin policies
Rate Limiting: API rate limiting (configurable)
Input Validation: Zod schema validation on all inputs
SQL Injection Prevention: Prisma ORM parameterized queries

Production Deployment

Quick Deploy Options

  1. Railway.app (Recommended for both frontend & backend)

    • Connect GitHub repo
    • Set environment variables
    • Auto-deploys on push
    • See DEPLOYMENT_GUIDE.md for details
  2. Vercel (Frontend only)

    cd frontend
    npm i -g vercel
    vercel
  3. Docker (Self-hosted)

    • Dockerfiles provided in DEPLOYMENT_GUIDE.md
    • Docker Compose for local deployment

Environment Setup

See DEPLOYMENT_GUIDE.md for:

  • Database setup (Neon PostgreSQL)
  • Environment variables
  • Security checklist
  • SSL/HTTPS configuration
  • Monitoring and logging

Performance

  • Caching: Browser caching for static assets
  • Compression: gzip compression on responses
  • Database: Connection pooling with Prisma
  • Frontend: Code splitting and lazy loading with Vite
  • CDN Ready: Static assets optimized for CDN delivery

Monitoring & Logging

  • Fastify built-in request logging
  • Error tracking ready for Sentry integration
  • Database query monitoring
  • WebSocket connection tracking
  • Premium subscription lifecycle logging

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Security Report

If you discover a security vulnerability, please email security@basetrack.xyz instead of using the issue tracker. All security vulnerabilities will be promptly addressed.

Troubleshooting

"Failed to fetch" errors

  • Ensure backend is running on port 4000
  • Check VITE_API_URL matches backend URL
  • Verify CORS_ORIGIN in backend .env

Database connection errors

  • Verify DATABASE_URL format
  • Check PostgreSQL is running
  • Ensure database exists and user has permissions

Build errors

# Clear and reinstall
rm -rf node_modules pnpm-lock.yaml
pnpm install

# Regenerate Prisma client
npx prisma generate

License

MIT License — see LICENSE file for details

Support

  • 📚 Check DEPLOYMENT_GUIDE.md for detailed setup
  • 🐛 Open an issue on GitHub
  • 💬 Join our community discussions
  • 📧 Contact the development team

Veil — Your Messages, Your Privacy. Built with security and user privacy as first-class concerns.

About

Veil — Private by Design.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages