Skip to content

Full-stack digital wallet simulator with Node.js/Express backend and vanilla JavaScript frontend. Features authentication, sessions, MongoDB integration and secure balance operations.

Notifications You must be signed in to change notification settings

Phosky71/WalletSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’³ WalletSimulator

πŸ“‹ Overview

WalletSimulator is a comprehensive cryptocurrency wallet application that enables users to manage digital assets, perform transactions, and exchange cryptocurrencies. Built with modern web technologies, this full-stack application demonstrates secure user authentication, real-time cryptocurrency price integration via CoinRanking API, and peer-to-peer cryptocurrency transfers.

πŸ› οΈ Technologies Used

Backend

  • Node.js (v14+) - JavaScript runtime environment
  • Express.js - Web application framework
  • MongoDB - NoSQL database for data persistence
  • Mongoose - MongoDB object modeling
  • bcryptjs - Password hashing and encryption
  • JWT (jsonwebtoken) - Secure authentication tokens
  • express-session - Session management
  • cors - Cross-Origin Resource Sharing
  • axios - HTTP client for CoinRanking API integration

Frontend

  • Vanilla JavaScript - Client-side logic
  • HTML5 - Markup structure
  • CSS3 - Styling and responsive design

External APIs

  • CoinRanking API - Real-time cryptocurrency prices and data

✨ Features

  • πŸ” User Authentication: Secure registration and login with encrypted passwords and JWT tokens
  • πŸ‘€ User Profile Management: Each user has a unique public address for receiving cryptocurrencies
  • πŸ’° Crypto Portfolio: Add and manage multiple cryptocurrencies in your personal wallet
  • πŸ’Έ P2P Transfers: Send cryptocurrencies to other users using their public address
  • πŸ”„ Crypto Exchange: Convert between different cryptocurrencies using real-time exchange rates
  • πŸ“Š Transaction History: Complete tracking of all transactions (sends, exchanges) with hash generation
  • πŸ” Advanced Filtering: Filter transactions by hash, user addresses, symbols, amounts, and dates
  • πŸ“ˆ Real-time Prices: Integration with CoinRanking API for up-to-date cryptocurrency prices
  • πŸ—„οΈ MongoDB Integration: Reliable data storage and retrieval
  • πŸ”’ Security: Password encryption, JWT authentication, and protected API routes
  • πŸ“± Responsive Design: Works on desktop and mobile devices

πŸ“ Project Structure

WalletSimulator/
β”œβ”€β”€ src/
β”‚   └── backend/
β”‚       β”œβ”€β”€ config/          # Database and app configuration
β”‚       β”œβ”€β”€ controllers/     # Request handlers
β”‚       β”œβ”€β”€ middlewares/     # Authentication and validation
β”‚       β”œβ”€β”€ models/          # MongoDB schemas
β”‚       β”‚   β”œβ”€β”€ Cripto.js    # Cryptocurrency holdings model
β”‚       β”‚   β”œβ”€β”€ Transaction.js # Transaction records model
β”‚       β”‚   └── Users.js     # User accounts model
β”‚       └── routes/          # API endpoints
β”‚           β”œβ”€β”€ authRoutes.js       # Authentication routes
β”‚           β”œβ”€β”€ cryptoRoutes.js     # Crypto portfolio management
β”‚           β”œβ”€β”€ settingsRoutes.js   # User settings
β”‚           β”œβ”€β”€ transactionRoutes.js # Transactions & transfers
β”‚           └── userRoutes.js       # User management
β”œβ”€β”€ public/
β”‚   └── frontend/
β”‚       β”œβ”€β”€ css/            # Stylesheets
β”‚       β”œβ”€β”€ html/           # HTML pages
β”‚       β”‚   β”œβ”€β”€ login.html     # Login/Register page
β”‚       β”‚   └── portfolio.html # Main portfolio dashboard
β”‚       └── js/             # Client-side JavaScript
β”œβ”€β”€ config/                 # Configuration files
└── package.json           # Dependencies and scripts

πŸš€ Installation

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB (local or cloud instance)
  • npm or yarn package manager
  • CoinRanking API Key (get one at coinranking.com)

Setup Instructions

  1. Clone the repository
git clone https://github.com/Phosky71/WalletSimulator.git
cd WalletSimulator
  1. Install dependencies
cd src/backend
npm install
  1. Configure environment variables Create a .env file in the src/backend directory:
PORT=3000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key
SESSION_SECRET=your_session_secret
COINRANKING_API_KEY=your_coinranking_api_key
  1. Start MongoDB Make sure your MongoDB instance is running.

  2. Run the application

npm start
  1. Access the application Open your browser and navigate to http://localhost:3000

πŸ”Œ API Endpoints

Authentication Routes

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • DELETE /api/auth/delete - Delete user account

Cryptocurrency Portfolio Routes

  • GET /api/crypto - Get user's crypto portfolio
  • POST /api/crypto - Add cryptocurrency to portfolio
  • GET /api/crypto/cryptocurrencies - Get list of available cryptocurrencies from CoinRanking
  • GET /api/crypto/cryptocurrencies/:uid - Get specific cryptocurrency info
  • POST /api/crypto/cryptocurrencies - Get crypto info by UID

Transaction Routes

  • GET /api/transactions - Get user's transaction history
  • POST /api/transactions/exchange - Calculate exchange rate between cryptocurrencies
  • POST /api/transactions/confirm - Confirm and execute crypto exchange
  • POST /api/transactions/send - Send cryptocurrency to another user
  • GET /api/transactions/user-transactions - Get filtered transactions with advanced search options

User Routes

  • GET /api/users - Get user information
  • DELETE /api/users - Delete user account

🎯 Key Functionalities

Peer-to-Peer Transfers

Users can send cryptocurrencies to other users by providing:

  • Receiver's public address
  • Cryptocurrency UID and symbol
  • Amount to send

The system validates sufficient balance, updates both sender and receiver portfolios, and generates a unique hash for each transaction.

Cryptocurrency Exchange

Users can exchange between different cryptocurrencies:

  1. Select source and target cryptocurrencies
  2. Enter amount to exchange
  3. System fetches real-time exchange rates from CoinRanking API
  4. Confirm exchange to update portfolio
  5. Transaction is recorded with unique hash

Transaction Filtering

Advanced filtering options include:

  • Hash: Search by transaction hash (partial match)
  • User From/To: Filter by sender/receiver public address
  • Symbol: Filter by cryptocurrency symbol
  • Amount: Filter by minimum amount (from/to)
  • Date: Filter by specific date
  • Type: Filter by transaction type (send/exchange)

πŸŽ“ Learning Objectives

This project demonstrates:

  • Full-stack JavaScript development with Node.js and Express
  • RESTful API design and implementation
  • External API integration (CoinRanking)
  • Secure authentication with JWT tokens
  • MongoDB database design and relationships
  • User-to-user transaction systems
  • Real-time data fetching and processing
  • Frontend-backend communication
  • Session management techniques
  • Transaction hash generation using crypto module
  • Advanced database querying and filtering

πŸ” Security Considerations

  • Passwords are hashed using bcrypt before storage
  • JWT tokens for stateless authentication
  • Protected routes require valid authentication
  • Input validation on all endpoints using express-validator
  • CORS configuration for secure cross-origin requests
  • Unique transaction hashes using SHA-256
  • Atomic database operations to prevent race conditions
  • Balance validation before executing transfers

πŸ“ Models

User Model

  • Username, email, password (hashed)
  • Public address (unique identifier for receiving funds)
  • Timestamps

Crypto Model

  • User reference
  • Cryptocurrency UID, name, symbol
  • Amount held
  • Timestamps

Transaction Model

  • Unique hash (SHA-256)
  • User From/To references
  • Symbol, from/to amounts
  • Transaction type (send/exchange)
  • Date timestamp

🚧 Future Enhancements

  • Add transaction categories and tags
  • Implement email notifications for transactions
  • Create admin dashboard for system monitoring
  • Implement two-factor authentication
  • Add support for more cryptocurrency APIs
  • Implement transaction limits and daily caps
  • Add multi-signature wallet support

πŸ‘¨β€πŸ’» Author

Antonio Juan GonzΓ‘lez-Conde Abril (Phosky71)

πŸ“„ License

This project is part of a portfolio demonstrating full-stack development capabilities.


This is an educational project created to demonstrate full-stack web development skills with Node.js, Express, MongoDB, vanilla JavaScript, and external API integration.

About

Full-stack digital wallet simulator with Node.js/Express backend and vanilla JavaScript frontend. Features authentication, sessions, MongoDB integration and secure balance operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •