Skip to content

About

A crypto wallet MVP with multi-currency support (BTC, ETH) and transaction management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CryptoWallet MVP

A full-stack cryptocurrency wallet application featuring multi-currency support, wallet management, token swapping, and real-time portfolio tracking.

✨ Features

Wallet Management

  • πŸ” Create Wallets: Generate new wallets with BIP39 12-word seed phrases
  • πŸ“₯ Multi-Currency Support: BTC, ETH, USDT, USDC, BNB, SOL, XRP, ADA, DOGE, DOT
  • πŸ’Ό Multiple Wallets: Manage multiple wallets per account
  • πŸ“Š Portfolio Overview: Real-time total portfolio value across all assets

Transactions

  • πŸ’Έ Send Crypto: Send transactions to any address
  • πŸ”„ Token Swapping: Exchange between cryptocurrencies with 0.5% fee
  • πŸ“ˆ Transaction History: View complete transaction history per wallet
  • ⏱️ Real-time Updates: Live transaction status tracking

User Experience

  • πŸ’± Live Price Data: Real-time cryptocurrency prices with 24h changes
  • 🎨 Modern UI: Clean, responsive interface with reusable components
  • πŸ”’ Secure Authentication: JWT-based auth with HttpOnly cookies
  • πŸ“± Mobile-Friendly: Responsive design for all screen sizes
  • πŸ”” Toast Notifications: User-friendly feedback for all actions
  • ⚑ Loading States: Skeleton loaders and spinners for better UX
  • πŸ›‘οΈ Error Boundaries: Graceful error handling with recovery options
  • 🌐 Localization Ready: Centralized string management for i18n support

πŸš€ Quick Start

Prerequisites

  • Node.js (v18+)
  • PostgreSQL (v12+)
  • npm or yarn

Installation

# 1. Clone and install
git clone <repository-url>
cd crypto-wallet-mvp
npm install

# 2. Setup environment
cp src/config/.env.example .env
# Edit .env with your PostgreSQL credentials

# 3. Setup database with test data (one command!)
npm run setup:db

# 4. Start the application
npm run dev

That's it!

Open http://localhost:3000 and login with:

  • Email: admin@test.com
  • Password: admin123

πŸ“œ Available Scripts

Development

Script Command Description
dev npm run dev Starts both client and server in development mode concurrently
dev:client npm run dev:client Starts the webpack dev server for the React frontend (port 3000)
dev:server npm run dev:server Starts the Express server with nodemon for hot reloading (port 5000)

Build & Production

Script Command Description
build npm run build Builds the client for production using webpack
build:client npm run build:client Alias for build - builds the React frontend
start npm start Starts the production server
start:server npm run start:server Alias for start - runs the Express server

Database Setup

Script Command Description
setup:db npm run setup:db All-in-one database setup (drop, recreate, migrate, seed)
init:db npm run init:db Initializes the database schema
reset:db npm run reset:db Drops and recreates all database tables (destructive)
seed npm run seed Seeds the database with a test user
test:db npm run test:db Tests the database connection

Database Migrations

Script Command Description
migrate npm run migrate Runs pending database migrations
migrate:up npm run migrate:up Applies all pending migrations
migrate:down npm run migrate:down Reverts the last migration
migrate:status npm run migrate:status Shows the status of all migrations
migrate:dry npm run migrate:dry Dry run - shows what migrations would be applied
migrate:create npm run migrate:create Creates a new migration file
migrate:mark npm run migrate:mark Marks a migration as complete without running it

Testing

Script Command Description
test npm test Runs all tests using Jest
test:watch npm run test:watch Runs tests in watch mode (re-runs on file changes)
test:coverage npm run test:coverage Runs tests and generates a coverage report
test:unit npm run test:unit Runs only unit tests (tests/unit directory)
test:api npm run test:api Runs only API integration tests (tests/api directory)

Code Quality

Script Command Description
lint npm run lint Runs ESLint on the src directory
lint:fix npm run lint:fix Runs ESLint and automatically fixes fixable issues
format npm run format Formats code using Prettier
format:check npm run format:check Checks if code is properly formatted
type-check npm run type-check Runs TypeScript type checking without emitting files

πŸ—οΈ Tech Stack

Frontend

  • React 19 - UI library
  • Redux Toolkit - State management
  • TypeScript - Type safety
  • Webpack 5 - Module bundler
  • Axios - HTTP client

Backend

  • Node.js - Runtime
  • Express 5 - Web framework
  • PostgreSQL - Database
  • JWT - Authentication (HttpOnly cookies)
  • bcryptjs - Password hashing
  • Joi - Schema validation
  • express-rate-limit - API rate limiting
  • morgan - HTTP request logging

Testing

  • Jest - Test framework
  • Supertest - HTTP assertions
  • ts-jest - TypeScript support

Crypto Libraries

  • ethers.js - Ethereum wallet operations
  • bitcoinjs-lib - Bitcoin wallet operations
  • bip39 - Mnemonic generation
  • bip32 - HD wallet derivation

πŸ“ Project Structure

crypto-wallet-mvp/
β”œβ”€β”€ api/                     # Vercel Serverless Functions
β”‚   β”œβ”€β”€ _lib/               # Shared utilities (auth, db, rate-limit)
β”‚   β”œβ”€β”€ auth/               # Authentication endpoints
β”‚   β”œβ”€β”€ wallets/            # Wallet endpoints
β”‚   β”œβ”€β”€ transactions/       # Transaction endpoints
β”‚   β”œβ”€β”€ prices/             # Price endpoints
β”‚   └── health.js           # Health check
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ client/              # Frontend React application
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/         # Reusable UI (Button, Card, Modal, Toast, etc.)
β”‚   β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ context/        # React context providers
β”‚   β”‚   β”œβ”€β”€ redux/          # Redux store & slices
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”‚   β”œβ”€β”€ utils/          # Client utilities
β”‚   β”‚   β”œβ”€β”€ locales/        # Localization strings
β”‚   β”‚   └── index.tsx       # App entry point
β”‚   β”‚
β”‚   β”œβ”€β”€ common/              # Shared code
β”‚   β”‚   β”œβ”€β”€ types/          # TypeScript interfaces
β”‚   β”‚   └── constants/      # Shared constants
β”‚   β”‚
β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”‚   β”œβ”€β”€ environments/   # Environment-specific configs
β”‚   β”‚   β”œβ”€β”€ .env.example    # Environment template
β”‚   β”‚   β”œβ”€β”€ jest.config.js  # Jest configuration
β”‚   β”‚   β”œβ”€β”€ webpack.config.js # Webpack configuration
β”‚   β”‚   └── migrate.config.js # Migration configuration
β”‚   β”‚
β”‚   └── server/              # Backend Express API (local dev)
β”‚       β”œβ”€β”€ controllers/    # Route handlers
β”‚       β”œβ”€β”€ middleware/     # Auth, validation, rate limiting
β”‚       β”œβ”€β”€ schemas/        # Joi validation schemas
β”‚       β”œβ”€β”€ services/       # Business logic
β”‚       β”œβ”€β”€ utils/          # Server utilities
β”‚       β”œβ”€β”€ queries/        # SQL queries
β”‚       β”œβ”€β”€ scripts/        # Database scripts
β”‚       β”œβ”€β”€ locales/        # Server-side strings
β”‚       β”œβ”€β”€ config/         # Server config
β”‚       └── index.js        # Server entry point
β”‚
β”œβ”€β”€ tests/                   # Test suite
β”‚   β”œβ”€β”€ api/                # API integration tests
β”‚   β”œβ”€β”€ unit/               # Unit tests
β”‚   β”œβ”€β”€ mocks/              # Test mocks
β”‚   β”œβ”€β”€ setup.js            # Test configuration
β”‚   └── helpers.js          # Test utilities
β”œβ”€β”€ migrations/              # Database migrations
β”œβ”€β”€ docs/                    # Documentation
└── public/                  # Static assets

πŸ—„οΈ Database Schema

Tables

  • users - User accounts with authentication
  • wallets - User wallets with encrypted mnemonics
  • wallet_addresses - Multi-currency addresses per wallet
  • transactions - Transaction history
  • price_cache - Cryptocurrency price data

πŸ” Security Features

  • βœ… Password Hashing: bcrypt with salt rounds
  • βœ… HttpOnly Cookies: JWT stored in secure HttpOnly cookies (not localStorage)
  • βœ… Rate Limiting: Upstash Redis-based rate limiting (5 req/min auth, 30 req/min API)
  • βœ… Input Validation: Joi schemas for all API endpoints + client-side validation
  • βœ… SQL Injection Prevention: Parameterized queries throughout
  • βœ… Environment Variables: Sensitive data in .env (JWT_SECRET required)
  • βœ… Error Boundaries: Graceful error handling without exposing internals
  • βœ… CORS Configuration: Proper cross-origin resource sharing setup
  • βœ… Security Headers: X-Frame-Options, X-Content-Type-Options via Vercel

⚠️ Note: This is an MVP for demonstration. For production, additionally consider:

  • Add 2FA authentication
  • Use hardware security modules for key storage
  • Implement proper key encryption at rest
  • Add request logging and monitoring

πŸš€ Deployment

The application is deployed on:

  • Frontend/API: Vercel (serverless functions)
  • Database: Neon (serverless PostgreSQL)

Live Demo

Deploy Your Own

1. Database Setup (Neon)

# Create account at https://neon.tech
# Create a new project
# Copy the connection string from dashboard

2. Vercel Deployment

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

# Set environment variables in Vercel dashboard:
# - DATABASE_URL (from Neon)
# - JWT_SECRET (generate secure key)
# - UPSTASH_REDIS_REST_URL (optional, for rate limiting)
# - UPSTASH_REDIS_REST_TOKEN (optional, for rate limiting)

3. Rate Limiting (Optional)

# Create account at https://upstash.com
# Create a Redis database
# Add UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN to Vercel

Environment Variables

Variable Required Description
DATABASE_URL Yes Neon PostgreSQL connection string
JWT_SECRET Yes Secret key for JWT signing
UPSTASH_REDIS_REST_URL No Upstash Redis URL for rate limiting
UPSTASH_REDIS_REST_TOKEN No Upstash Redis token

🎯 Code Quality & Architecture

Testing

  • βœ… 78 Tests: Comprehensive test suite covering unit and API tests
  • βœ… API Tests: Wallet creation, transactions, authentication
  • βœ… Unit Tests: Calculations, crypto utilities, validation
  • βœ… Mock Database: Isolated testing without PostgreSQL dependency

Architecture Improvements

  • βœ… Barrel Exports: Clean imports via index files
  • βœ… Localization: Centralized strings for easy i18n
  • βœ… Error Boundaries: React error handling with recovery
  • βœ… Toast System: Context-based notification system
  • βœ… Form Validation: Reusable validation hook
  • βœ… Database Migrations: Version-controlled schema changes

Code Organization

  • βœ… Configuration: Centralized constants and config
  • βœ… API Responses: Reusable error/success handlers
  • βœ… Storage Service: Centralized localStorage operations
  • βœ… Calculations: Safe number parsing and asset value calculations
  • βœ… Business Logic: Extracted swap service from controllers

Benefits

  • πŸ”„ Reduced code duplication
  • πŸ“¦ Better separation of concerns
  • πŸ§ͺ Fully testable codebase
  • πŸ›‘οΈ Safer number handling (prevents NaN errors)
  • πŸ“– Consistent patterns across codebase
  • 🌐 Ready for internationalization

πŸ§ͺ Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run with coverage report
npm run test:coverage

# Run only unit tests
npm run test:unit

# Run only API tests
npm run test:api

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Run tests to ensure everything works (npm test)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

πŸ“ Test Credentials

After running npm run setup:db, use these credentials:

Sample Data Includes:

  • 2 wallets (Main Wallet & Trading Wallet)
  • Multiple cryptocurrencies with balances
  • Sample transaction history
  • Live price data for 10 tokens

πŸ“„ License

MIT License - This is a demonstration project for educational purposes.

About

A crypto wallet MVP with multi-currency support (BTC, ETH) and transaction management

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages