How darwineee/cpproject works
Project type and purpose
• This is a monolithic C++ application (“CPProject”) that implements a secure user authentication flow and a points‐based wallet management system.
• It sits between end users (admins and regular users) and two kinds of external systems: an SMTP mail server (for OTP emails) and a local SQLite database (for storing credentials, profiles, and transaction history).
File structure
• Top level:
• CMakeLists.txt, CMakePresets.json, CMakeSettings.json – build configuration
• README.md – project overview, features, usage
• CPProject/ directory:
• CPProject.cpp – entry point (CLI UI and orchestrator)
• Five core modules under source and include:
– CredentialReader(.cpp/.h)
– EmailSender(.cpp/.h)
– OTPManager(.cpp/.h)
– UserAuth(.cpp/.h)
– WalletManager(.cpp/.h)
README for additional insights
• Dependencies: SQLite3, OpenSSL, Boost, mailio, nlohmann_json
• Features:
• Two‐factor authentication (email OTP)
• Role‐based access (admin vs. regular user)
• Wallet operations (admin top-up/distribute, user transfers)
• Security measures: SQL transaction blocks, password hashing with salt, SQL injection protection
Main components and relationships
• CLI Interface (CPProject.exe)
• Core Modules
– CredentialReader: loads configuration, reads credentials from JSON or console
– UserAuth: handles password hashing, salting, login/signup flows
– OTPManager: generates and validates one-time passwords
– EmailSender: sends OTP via SMTP (mailio)
– WalletManager: executes wallet transactions, maintains balances, logs history
• Database: SQLite3 engine (persistent storage)
• External Service: SMTP Mail Server
• Crypto Library: OpenSSL (used by UserAuth and OTPManager)
• Config Parser: nlohmann_json (used by CredentialReader)
• Utility: Boost (date_time for timestamping transactions)
b. Relationships and data flows
• User/Admin → CLI Interface: issues commands (signup, login, view profile, transfer points)
• CLI → CredentialReader → JSON config file
• CLI → UserAuth → SQLite DB (users table, password hashes)
• CLI → OTPManager ↔ OpenSSL (crypto)
• OTPManager → EmailSender → SMTP Server
• CLI → WalletManager ↔ SQLite DB (wallets table, transaction table)
• WalletManager uses Boost to timestamp transactions
c. Architectural patterns and principles
• Modular separation by responsibility (single-responsibility principle)
• Monolithic process with well-defined component boundaries
• Layered interactions: CLI → business logic modules → persistence/external services
• Transactional boundaries: all wallet operations wrapped in SQL transaction blocks
Essential elements to capture
• Names of every core class/module
• Data stores and external services
• Direction of control and data flow
• Key technologies alongside each component (e.g., “SQLite3”, “OpenSSL”, “mailio”, “nlohmann_json”, “Boost”)