Skip to content

stateofisrl/qfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

59 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tesla Investment Platform

A comprehensive Django-based investment platform with Tesla-inspired dark theme, user authentication, investment plans, deposits, withdrawals, and support system.

πŸš€ Features

User Side

  • Authentication: Secure registration and login with email
  • Dashboard: View balance, investments, and earnings with real-time updates
  • Deposit Management: Submit crypto deposits with proof
  • Investment Plans: Browse and subscribe to investment plans with automatic ROI crediting
  • Withdrawals: Request fund withdrawals with automatic balance handling
  • Support System: Create tickets and communicate with admin

Admin Side (Django Admin)

  • User Management: Manage user balances and accounts
  • Deposit Approval: Approve deposits with automatic balance updates
  • Support Management: Reply to user tickets inline
  • Investment Plans: Create and manage investment plans
  • Withdrawal Processing: Approve/reject with automatic refund on rejection

Automated Features

  • βœ… Automatic Balance Updates: Deposits auto-credit on approval
  • βœ… Smart Refunds: Rejected withdrawals auto-refund balance
  • βœ… ROI Crediting: Completed investments automatically credit earnings + principal
  • βœ… Duplicate Prevention: Status-change detection prevents double-credits
  • βœ… Total Earnings Tracking: Dashboard tracks cumulative ROI earnings

πŸ›  Technical Stack

  • Backend: Django 4.2.7, Django REST Framework 3.14.0
  • Frontend: Tailwind CSS (Tesla dark theme), Alpine.js, Vanilla JavaScript
  • Database: SQLite (default), PostgreSQL (production)
  • Authentication: Token-based + Session authentication
  • Security: CSRF protection, JWT support, HTTPS ready
  • Static Files: WhiteNoise with compression
  • Deployment: Gunicorn + Nginx ready

πŸ“‹ Prerequisites

  • Python 3.14.0
  • pip and virtualenv
  • PostgreSQL (for production)
  • Nginx (for production deployment)

πŸ“¦ Installation

Development Setup

  1. Clone the Repository

    git clone <your-repo>
    cd prodig
  2. Create Virtual Environment

    python -m venv venv
    venv\Scripts\activate  # Windows
    source venv/bin/activate  # Linux/Mac
  3. Install Dependencies

    pip install -r requirements.txt
  4. Setup Environment

    cp .env.example .env
    # Edit .env with your settings
  5. Run Migrations

    python manage.py migrate
  6. Create Superuser

    python manage.py createsuperuser
  7. Collect Static Files

    python manage.py collectstatic --noinput
  8. Run Development Server

    python manage.py runserver 8001

Access at http://127.0.0.1:8001

Pre-Deployment Check

Run the deployment readiness checker:

python check_deployment.py

This validates:

  • βœ… Environment configuration
  • βœ… Database connectivity
  • βœ… Static files collection
  • βœ… Security settings
  • βœ… Required dependencies
  • βœ… Signal handlers
  • βœ… Template files

πŸš€ Production Deployment

See DEPLOYMENT.md for comprehensive production deployment guide.

Quick production checklist:

  1. Set DEBUG=False in .env
  2. Configure PostgreSQL database
  3. Set strong SECRET_KEY
  4. Update ALLOWED_HOSTS
  5. Enable SSL/HTTPS
  6. Configure Gunicorn + Nginx
  7. Run python manage.py check --deploy

API Documentation

Authentication Endpoints

  • POST /api/users/register/ - Register new user
  • POST /api/users/login/ - Login user
  • POST /api/users/logout/ - Logout user
  • GET /api/users/me/ - Get current user profile

Investment Endpoints

  • GET /api/investments/plans/ - Get all investment plans
  • GET /api/investments/my-investments/ - Get user investments
  • POST /api/investments/my-investments/subscribe/ - Subscribe to plan

Deposit Endpoints

  • GET /api/deposits/wallets/ - Get crypto wallets
  • GET /api/deposits/ - Get user deposits
  • POST /api/deposits/ - Submit new deposit

Withdrawal Endpoints

  • GET /api/withdrawals/ - Get user withdrawals
  • POST /api/withdrawals/request_withdrawal/ - Request withdrawal

Support Endpoints

  • GET /api/support/tickets/ - Get support tickets
  • POST /api/support/tickets/ - Create ticket
  • POST /api/support/tickets/{id}/add_reply/ - Add reply

Database Models

CustomUser

  • Email, username, password
  • Balance, total_invested, total_earnings
  • Profile information

InvestmentPlan

  • Name, description
  • ROI percentage, duration
  • Min/max investment amounts

UserInvestment

  • User, plan, amount
  • Status, dates, returns

CryptoWallet

  • Cryptocurrency type
  • Wallet address

Deposit

  • User, amount, cryptocurrency
  • Proof type and content
  • Status (pending/approved/rejected)

Withdrawal

  • User, amount, cryptocurrency
  • Wallet address, status
  • Signal: Auto-refunds on rejection

SupportTicket & SupportReply

  • Priority, status, category
  • Admin inline replies
  • User-admin communication

🎯 Automated Transaction Flow

Deposit Flow

  1. User submits deposit with proof
  2. Admin reviews in Django admin
  3. Admin approves β†’ Signal auto-credits balance
  4. Duplicate prevention via approved_at timestamp

Withdrawal Flow

  1. User requests withdrawal (balance deducted)
  2. Admin reviews request
  3. If rejected β†’ Signal auto-refunds balance
  4. Duplicate prevention via status change detection

Investment Flow

  1. User subscribes to plan (balance deducted)
  2. Investment becomes active
  3. Admin completes investment β†’ Signal credits:
    • Principal amount back to balance
    • ROI earnings to balance
    • Updates total_earnings field
  4. User can cancel active investment β†’ Signal refunds amount
  5. Duplicate prevention via earned field check

🌐 API Endpoints

Authentication

  • POST /api/users/register/ - Register new user
  • POST /api/users/login/ - Login (returns token)
  • POST /api/users/logout/ - Logout
  • GET /api/users/me/ - Current user profile

Investments

  • GET /api/investments/plans/ - List investment plans
  • GET /api/investments/my-investments/ - User's investments
  • POST /api/investments/my-investments/subscribe/ - Subscribe to plan
  • POST /api/investments/my-investments/cancel_investment/ - Cancel investment

Deposits

  • GET /api/deposits/wallets/ - Crypto wallet addresses
  • GET /api/deposits/my_deposits/ - User's deposits
  • POST /api/deposits/ - Submit new deposit

Withdrawals

  • GET /api/withdrawals/my-withdrawals/ - User's withdrawals
  • POST /api/withdrawals/request_withdrawal/ - Request withdrawal

Support

  • GET /api/support/tickets/ - List user tickets
  • POST /api/support/tickets/ - Create ticket
  • GET /api/support/tickets/{id}/ - Ticket details with replies
  • POST /api/support/tickets/{id}/add_reply/ - Add reply

πŸ”§ Admin Panel

Access: http://yourdomain.com/admin/

Key Features

  • User Management: Edit balances, total_invested, total_earnings
  • Deposit Approval: Inline actions, auto-balance update
  • Investment Tracking: View all active/completed investments
  • Withdrawal Processing: Approve with proof, reject with auto-refund
  • Support Tickets: Inline reply system with admin indicator
  • Investment Plans: Create plans with ROI % and duration

Admin Credentials

Set during deployment with python manage.py createsuperuser

🚨 Troubleshooting

Dashboard not showing updated earnings

  1. Check browser console for JavaScript errors
  2. Verify API endpoint returns correct data: /api/users/me/
  3. Hard refresh: Ctrl+Shift+R (Windows) / Cmd+Shift+R (Mac)

Balance not updating after approval

  1. Check Django admin logs
  2. Verify signal files exist:
    • apps/deposits/signals.py
    • apps/withdrawals/signals.py
    • apps/investments/signals.py
  3. Check apps.py imports signals in ready() method

Static files not loading

python manage.py collectstatic --clear --noinput

Database errors

python manage.py migrate
python manage.py check

πŸ“ Development Commands

# Create migrations
python manage.py makemigrations

# Apply migrations
python manage.py migrate

# Create superuser
python manage.py createsuperuser

# Collect static files
python manage.py collectstatic

# Run development server
python manage.py runserver 8001

# Django shell
python manage.py shell

# Check deployment readiness
python check_deployment.py

# Security check
python manage.py check --deploy

πŸ“š Documentation

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature-name
  3. Commit changes: git commit -m 'Add feature'
  4. Push to branch: git push origin feature-name
  5. Submit pull request

πŸ“„ License

Proprietary - All rights reserved Β© 2024-2025

πŸ™‹ Support

  • In-App: Use the support ticket system
  • Admin: Login to Django admin for backend management
  • Documentation: See DEPLOYMENT.md for detailed guides

Built with Django 4.2.7 | Styled with Tesla-inspired design | Ready for Production πŸš€

Project Structure

prodig/
β”œβ”€β”€ manage.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ settings.py
β”‚   β”œβ”€β”€ urls.py
β”‚   β”œβ”€β”€ wsgi.py
β”‚   └── celery.py
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ users/
β”‚   β”œβ”€β”€ investments/
β”‚   β”œβ”€β”€ deposits/
β”‚   β”œβ”€β”€ withdrawals/
β”‚   └── support/
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ base.html
β”‚   β”œβ”€β”€ login.html
β”‚  πŸ”§ Configuration

### Environment Variables (.env)

**Development:**
```env
DEBUG=True
SECRET_KEY=development-key-change-in-production
ALLOWED_HOSTS=localhost,127.0.0.1
DB_ENGINE=django.db.backends.sqlite3

Production:

DEBUG=False
SECRET_KEY=<generate-strong-key>
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DB_ENGINE=django.db.backends.postgresql
DB_NAME=investment_platform
DB_USER=postgres
DB_PASSWORD=<secure-password>
DB_HOST=localhost
DB_PORT=5432
CSRF_COOKIE_SECURE=True
SESSION_COOKIE_SECURE=True
SECURE_SSL_REDIRECT=True
SECURE_HSTS_SECONDS=31536000

πŸ§ͺ Testing

Run Pre-Deployment Checks

python check_deployment.py

Django Deployment Check

python manage.py check --deploy

Test Individual Components

# Test investment completion and earnings
python test_complete_inv.py

# Test database connectivity
python check_db.py

πŸ“ Project Structure

prodig/
β”œβ”€β”€ manage.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Procfile                    # Heroku/deployment
β”œβ”€β”€ runtime.txt                 # Python version
β”œβ”€β”€ DEPLOYMENT.md              # Deployment guide
β”œβ”€β”€ check_deployment.py        # Pre-deployment validator
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ settings.py            # Base settings
β”‚   β”œβ”€β”€ settings_production.py # Production settings
β”‚   β”œβ”€β”€ urls.py
β”‚   β”œβ”€β”€ wsgi.py
β”‚   └── context_processors.py
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ users/                 # User management
β”‚   β”‚   β”œβ”€β”€ models.py          # CustomUser model
β”‚   β”‚   β”œβ”€β”€ views.py
β”‚   β”‚   β”œβ”€β”€ serializers.py
β”‚   β”‚   └── urls.py
β”‚   β”œβ”€β”€ investments/           # Investment system
β”‚   β”‚   β”œβ”€β”€ models.py          # InvestmentPlan, UserInvestment
β”‚   β”‚   β”œβ”€β”€ signals.py         # Auto ROI crediting
β”‚   β”‚   └── views.py
β”‚   β”œβ”€β”€ deposits/              # Deposit handling
β”‚   β”‚   β”œβ”€β”€ models.py          # Deposit, CryptoWallet
β”‚   β”‚   β”œβ”€β”€ signals.py         # Auto balance update
β”‚   β”‚   └── views.py
β”‚   β”œβ”€β”€ withdrawals/           # Withdrawal system
β”‚   β”‚   β”œβ”€β”€ models.py          # Withdrawal
β”‚   β”‚   β”œβ”€β”€ signals.py         # Auto refund
β”‚   β”‚   └── views.py
β”‚   └── support/               # Support tickets
β”‚       β”œβ”€β”€ models.py          # SupportTicket, SupportReply
β”‚       β”œβ”€β”€ admin.py           # Inline admin replies
β”‚       └── views.py
β”œβ”€β”€ templates/                 # HTML templates (Tesla theme)
β”‚   β”œβ”€β”€ base.html              # Master template
β”‚   β”œβ”€β”€ dashboard.html         # Main dashboard
β”‚   β”œβ”€β”€ investments.html       # Investment page
β”‚   β”œβ”€β”€ deposits.html          # Deposit page
β”‚   β”œβ”€β”€ withdrawals.html       # Withdrawal page
β”‚   └── support.html           # Support page
└── static/                    # Frontend assets
    β”œβ”€β”€ css/
    β”‚   └── tesla.css          # Tesla dark theme
    └── js/
        β”œβ”€β”€ main.js            # API utilities
        β”œβ”€β”€ dashboard.js       # Dashboard logic
        β”œβ”€β”€ investments.js     # Investment logic
        β”œβ”€β”€ deposits.js        # Deposit logic
        β”œβ”€β”€ withdrawals.js     # Withdrawal logic
        └── support.js         # Support logic

πŸ” Security Features

  • CSRF Protection: All forms protected
  • Token Authentication: Secure API endpoints
  • Password Hashing: Django PBKDF2 with SHA256
  • SSL/HTTPS Support: Production-ready configuration
  • Input Validation: Server-side validation
  • XSS Protection: Template auto-escaping
  • Secure Cookies: HTTPOnly, Secure, SameSite
  • SQL Injection Protection: ORM parameterized queries

🎨 UI/UX Features

  • Tesla Dark Theme: Professional black & gray design
  • Mobile Responsive: Works on all device sizes
  • Alpine.js: Interactive hamburger menu
  • Real-time Updates: JavaScript fetches live data
  • Status Badges: Color-coded transaction statuses
  • Modal Dialogs: Support ticket details
  • Form Validation: Client + server side

πŸ“Š Database Models

python manage.py makemigrations python manage.py migrate


### Load Sample Data
Create sample investment plans and crypto wallets through the admin panel.

## Deployment

### Using Gunicorn
```bash
pip install gunicorn
gunicorn config.wsgi:application --bind 0.0.0.0:8000

Production Settings

  • Set DEBUG=False
  • Update SECRET_KEY to strong value
  • Configure ALLOWED_HOSTS
  • Enable SECURE_SSL_REDIRECT=True
  • Setup PostgreSQL database
  • Use environment variables for sensitive data

Support

For issues or questions, create a support ticket through the platform.

License

Proprietary - All rights reserved

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors