first commit
This commit is contained in:
416
ADMIN_PANEL.md
Normal file
416
ADMIN_PANEL.md
Normal file
@@ -0,0 +1,416 @@
|
||||
# Admin Panel Documentation
|
||||
|
||||
## Overview
|
||||
|
||||
The TurboTrades admin panel provides comprehensive tools for managing the marketplace, tracking financials, monitoring transactions, and overriding item prices. This panel is only accessible to users with admin privileges (staffLevel >= 3).
|
||||
|
||||
## Access Control
|
||||
|
||||
### Granting Admin Access
|
||||
|
||||
Use the `make-admin.js` script to grant admin privileges:
|
||||
|
||||
```bash
|
||||
node make-admin.js
|
||||
```
|
||||
|
||||
This sets your Steam ID (76561198027608071) to staffLevel 3.
|
||||
|
||||
Alternatively, set admin Steam IDs in the `.env` file:
|
||||
|
||||
```env
|
||||
ADMIN_STEAM_IDS=76561198027608071,76561198027608072
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
### 1. Dashboard Tab
|
||||
|
||||
The dashboard provides a quick overview of your marketplace:
|
||||
|
||||
#### Quick Stats
|
||||
- **Total Users**: Number of registered users
|
||||
- **Active Items**: Currently listed items (with CS2/Rust breakdown)
|
||||
- **Transactions**: Daily, weekly, and monthly transaction counts
|
||||
- **Total Fees**: All-time fees collected from transactions
|
||||
|
||||
#### Recent Activity
|
||||
- Last 10 completed transactions
|
||||
- User information and transaction details
|
||||
- Real-time transaction amounts
|
||||
|
||||
#### Top Sellers
|
||||
- Users with the highest sales volume
|
||||
- Total sales amount and item count per seller
|
||||
|
||||
### 2. Financial Tab
|
||||
|
||||
Comprehensive financial analytics and profit tracking:
|
||||
|
||||
#### Period Filters
|
||||
- **Today**: Current day's transactions
|
||||
- **This Week**: Last 7 days
|
||||
- **This Month**: Last 30 days
|
||||
- **This Year**: Last 365 days
|
||||
- **All Time**: Complete financial history
|
||||
|
||||
#### Financial Metrics
|
||||
|
||||
##### Deposits
|
||||
- Total amount deposited by users
|
||||
- Number of deposit transactions
|
||||
- Shows money coming into the platform
|
||||
|
||||
##### Withdrawals
|
||||
- Total amount withdrawn by users
|
||||
- Number of withdrawal transactions
|
||||
- Shows money leaving the platform
|
||||
|
||||
##### Net Balance
|
||||
- Calculated as: `Deposits - Withdrawals`
|
||||
- Shows the platform's cash flow position
|
||||
|
||||
##### User Purchases
|
||||
- Total value of items purchased by users
|
||||
- Number of items bought
|
||||
- Represents marketplace activity
|
||||
|
||||
##### Total Sales
|
||||
- Value of all items sold through the marketplace
|
||||
- Number of items sold
|
||||
- Tracks marketplace volume
|
||||
|
||||
##### Fees Collected
|
||||
- **This is your revenue!**
|
||||
- Total fees collected from transactions
|
||||
- Number of fee-generating transactions
|
||||
- Fees are typically a percentage of each sale
|
||||
|
||||
##### Profit Tracking
|
||||
- **Gross Profit**: Total fees collected (direct revenue)
|
||||
- **Net Profit**: Gross profit minus (Withdrawals - Deposits)
|
||||
- Provides clear view of platform profitability
|
||||
|
||||
### 3. Transactions Tab
|
||||
|
||||
View and filter all transactions in the system:
|
||||
|
||||
#### Filters
|
||||
- **Type**: Filter by transaction type
|
||||
- Deposit: User adds funds
|
||||
- Withdrawal: User removes funds
|
||||
- Purchase: User buys an item
|
||||
- Sale: User sells an item
|
||||
- Trade: Item exchange
|
||||
- Bonus: Promotional credits
|
||||
- Refund: Returned funds
|
||||
- **Status**: Filter by transaction status
|
||||
- Completed: Successfully processed
|
||||
- Pending: Awaiting processing
|
||||
- Failed: Transaction failed
|
||||
- Cancelled: User cancelled
|
||||
- Processing: Currently being processed
|
||||
- **User ID**: Filter by specific user MongoDB ID
|
||||
- **Search**: Real-time search with debouncing
|
||||
|
||||
#### Transaction Details
|
||||
Each transaction shows:
|
||||
- Date and time
|
||||
- User information (avatar, username)
|
||||
- Transaction type (color-coded badge)
|
||||
- Status (color-coded badge)
|
||||
- Amount (green for positive, red for negative)
|
||||
- Fee collected
|
||||
- User's balance after transaction
|
||||
|
||||
#### Pagination
|
||||
- 50 transactions per page
|
||||
- Navigate between pages
|
||||
- Total transaction count displayed
|
||||
|
||||
### 4. Items Tab
|
||||
|
||||
Manage all marketplace items with price override capabilities:
|
||||
|
||||
#### Game Separation
|
||||
- **All Games**: View items from both games
|
||||
- **CS2**: Counter-Strike 2 items only
|
||||
- **Rust**: Rust items only
|
||||
|
||||
#### Filters
|
||||
- **Status**:
|
||||
- Active: Currently listed
|
||||
- Sold: Successfully sold items
|
||||
- Removed: Delisted items
|
||||
- **Category**: Filter by item type (rifles, pistols, knives, gloves, etc.)
|
||||
- **Search**: Real-time item name search
|
||||
- **Sort By**:
|
||||
- Listed Date: When item was added
|
||||
- Price: Listing price
|
||||
- Market Price: Steam market price
|
||||
- Views: Item popularity
|
||||
|
||||
#### Item Display
|
||||
Each item shows:
|
||||
- Item image
|
||||
- Item name and details
|
||||
- Game badge (CS2/Rust)
|
||||
- Rarity badge (color-coded)
|
||||
- Wear condition (for CS2 items)
|
||||
- Phase (for Doppler/Gamma Doppler)
|
||||
- Seller information
|
||||
- View count
|
||||
- **Listing Price**: Price set by seller
|
||||
- **Market Price**: Current Steam market price
|
||||
- **Edit Prices** button for overrides
|
||||
|
||||
#### Price Override System
|
||||
|
||||
##### Why Override Prices?
|
||||
- Correct incorrect market data
|
||||
- Adjust for special items (e.g., rare patterns)
|
||||
- Manual pricing for items not on Steam market
|
||||
- Promotional pricing
|
||||
|
||||
##### How to Override
|
||||
1. Click "Edit Prices" on any item
|
||||
2. Modal opens with current prices
|
||||
3. Modify:
|
||||
- **Listing Price**: What buyers pay
|
||||
- **Market Price**: Reference price from Steam
|
||||
4. Click "Save Changes"
|
||||
5. Item is marked with `priceOverride: true`
|
||||
|
||||
##### Tracking Overrides
|
||||
- Items with admin overrides are flagged in the database
|
||||
- `priceOverride` field set to `true`
|
||||
- `priceUpdatedAt` timestamp updated
|
||||
- Original prices preserved in history
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### Dashboard
|
||||
```
|
||||
GET /api/admin/dashboard
|
||||
```
|
||||
Returns comprehensive dashboard data.
|
||||
|
||||
### Financial Overview
|
||||
```
|
||||
GET /api/admin/financial/overview?period=all
|
||||
```
|
||||
Parameters:
|
||||
- `period`: today, week, month, year, all
|
||||
- `startDate`: Custom start date (ISO format)
|
||||
- `endDate`: Custom end date (ISO format)
|
||||
|
||||
Returns financial metrics and profit calculations.
|
||||
|
||||
### Transactions
|
||||
```
|
||||
GET /api/admin/transactions?type=sale&status=completed&limit=50&skip=0
|
||||
```
|
||||
Parameters:
|
||||
- `type`: Transaction type filter
|
||||
- `status`: Transaction status filter
|
||||
- `userId`: Filter by user ID
|
||||
- `limit`: Results per page (max 100)
|
||||
- `skip`: Pagination offset
|
||||
- `startDate`: Filter from date
|
||||
- `endDate`: Filter to date
|
||||
|
||||
Returns paginated transaction list.
|
||||
|
||||
### Items
|
||||
```
|
||||
GET /api/admin/items/all?game=cs2&status=active&limit=100&skip=0
|
||||
```
|
||||
Parameters:
|
||||
- `game`: cs2, rust, or empty for all
|
||||
- `status`: active, sold, removed
|
||||
- `category`: Item category
|
||||
- `rarity`: Item rarity
|
||||
- `search`: Search query
|
||||
- `sortBy`: price, marketPrice, listedAt, views
|
||||
- `sortOrder`: asc, desc
|
||||
- `limit`: Results per page (max 200)
|
||||
- `skip`: Pagination offset
|
||||
|
||||
Returns paginated item list.
|
||||
|
||||
### Update Item Price
|
||||
```
|
||||
PUT /api/admin/items/:id/price
|
||||
```
|
||||
Body:
|
||||
```json
|
||||
{
|
||||
"price": 99.99,
|
||||
"marketPrice": 95.00
|
||||
}
|
||||
```
|
||||
|
||||
Sets custom prices and marks item as overridden.
|
||||
|
||||
### Users
|
||||
```
|
||||
GET /api/admin/users?limit=50&skip=0
|
||||
```
|
||||
Parameters:
|
||||
- `limit`: Results per page (max 100)
|
||||
- `search`: Username or Steam ID search
|
||||
- `sortBy`: balance, createdAt
|
||||
- `sortOrder`: asc, desc
|
||||
|
||||
Returns user list with balances.
|
||||
|
||||
## Understanding Profit
|
||||
|
||||
### Revenue Streams
|
||||
|
||||
1. **Transaction Fees**
|
||||
- Primary revenue source
|
||||
- Configured percentage of each sale
|
||||
- Stored in `transaction.fee` field
|
||||
- Example: 5% fee on $100 sale = $5 revenue
|
||||
|
||||
2. **Float (User Deposits)**
|
||||
- Users deposit money before purchasing
|
||||
- Money held in user balances
|
||||
- Not counted as profit until fees are collected
|
||||
- Withdrawals reduce available float
|
||||
|
||||
### Profit Calculation
|
||||
|
||||
```
|
||||
Gross Profit = Sum of all transaction fees
|
||||
Net Profit = Gross Profit - (Total Withdrawals - Total Deposits)
|
||||
```
|
||||
|
||||
**Example:**
|
||||
- Users deposited: $10,000
|
||||
- Users withdrew: $6,000
|
||||
- Fees collected: $500
|
||||
|
||||
```
|
||||
Net Profit = $500 - ($6,000 - $10,000)
|
||||
Net Profit = $500 - (-$4,000)
|
||||
Net Profit = $4,500
|
||||
```
|
||||
|
||||
This accounts for the float you're holding.
|
||||
|
||||
### Important Notes
|
||||
|
||||
- **Deposits** increase available funds but aren't profit
|
||||
- **Withdrawals** decrease available funds and impact net profit
|
||||
- **Fees** are pure profit
|
||||
- **Net Profit** shows true profitability after accounting for float
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Price Overrides
|
||||
1. Document why you're overriding prices
|
||||
2. Check Steam market regularly for updates
|
||||
3. Use overrides sparingly for special cases
|
||||
4. Review overridden items periodically
|
||||
|
||||
### Financial Monitoring
|
||||
1. Check financial tab daily
|
||||
2. Monitor deposit/withdrawal ratio
|
||||
3. Track fee collection rates
|
||||
4. Watch for unusual transaction patterns
|
||||
|
||||
### Transaction Review
|
||||
1. Investigate failed transactions
|
||||
2. Monitor for refund patterns
|
||||
3. Check for suspicious activity
|
||||
4. Verify high-value transactions
|
||||
|
||||
### Item Management
|
||||
1. Separate CS2 and Rust analytics
|
||||
2. Remove inactive listings
|
||||
3. Monitor market price discrepancies
|
||||
4. Track item popularity (views)
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Admin Access
|
||||
- Limit admin access to trusted staff only
|
||||
- Use staffLevel 3 or higher
|
||||
- Consider IP whitelisting for production
|
||||
- Enable 2FA for admin accounts
|
||||
|
||||
### Price Overrides
|
||||
- Log all price changes
|
||||
- Track which admin made changes
|
||||
- Implement approval workflow for large changes
|
||||
- Set maximum override limits
|
||||
|
||||
### Transaction Monitoring
|
||||
- Alert on large transactions
|
||||
- Flag unusual patterns
|
||||
- Monitor for fraud
|
||||
- Implement rate limiting
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Can't Access Admin Panel
|
||||
1. Verify your staffLevel is >= 3
|
||||
2. Check ADMIN_STEAM_IDS in .env
|
||||
3. Clear cookies and re-login
|
||||
4. Check browser console for errors
|
||||
|
||||
### Financial Data Looks Wrong
|
||||
1. Verify transaction status filters
|
||||
2. Check date range selection
|
||||
3. Ensure database indexes are built
|
||||
4. Run data consistency checks
|
||||
|
||||
### Items Not Showing Prices
|
||||
1. Run price update from admin panel
|
||||
2. Check SteamAPIs.com API key
|
||||
3. Verify item names match market data
|
||||
4. Use price override for missing items
|
||||
|
||||
### Slow Performance
|
||||
1. Reduce pagination limit
|
||||
2. Use specific filters instead of "All"
|
||||
3. Add database indexes
|
||||
4. Consider caching frequently accessed data
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Planned Features
|
||||
- Export financial reports (CSV/PDF)
|
||||
- Charts and graphs for trends
|
||||
- Email alerts for large transactions
|
||||
- Bulk price override tools
|
||||
- User ban/restriction management
|
||||
- Automated fraud detection
|
||||
- Revenue forecasting
|
||||
- Inventory analytics
|
||||
- A/B testing for fees
|
||||
|
||||
### Integration Ideas
|
||||
- Stripe for deposits/withdrawals
|
||||
- PayPal integration
|
||||
- Cryptocurrency payments
|
||||
- Steam trading bot automation
|
||||
- Discord notifications
|
||||
- Slack integration for alerts
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
1. Check this documentation
|
||||
2. Review backend logs
|
||||
3. Check browser console
|
||||
4. Verify database state
|
||||
5. Contact development team
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2024
|
||||
**Version**: 1.0.0
|
||||
**Requires**: Admin access (staffLevel >= 3)
|
||||
Reference in New Issue
Block a user