A professional, premium trading Profit & Loss (PnL) tracker built with Next.js 16, TypeScript, Tailwind CSS, and Recharts. Features a sleek Bloomberg terminal-inspired dark-mode dashboard for tracking trading performance with advanced analytics and real-time updates.
- Total P&L: Comprehensive profit/loss tracking with percentage returns
- Win Rate: Detailed win/loss breakdown with visual indicators
- Average Win/Loss: Performance metrics per trade
- Profit Factor: Advanced metric for strategy evaluation
- Max Drawdown: Peak-to-trough decline analysis
- Current Streak: Winning/losing streak tracking
- Conditional formatting (Emerald green for profits, Rose red for losses)
- Dynamic trend indicators with animations
- Built with Recharts for smooth, responsive visualizations
- Real-time equity tracking with gradient fills
- Custom tooltips with detailed P&L data
- Responsive design scaling to any screen size
- Bloomberg-style dark theme with professional styling
- Complete trade history with comprehensive details
- Columns: Date, Symbol, Type, Quantity, Price, Total, P&L, P&L %
- Color-coded profits and losses for quick analysis
- BUY/SELL badges with intuitive icons
- Inline editing capabilities
- Smooth hover effects and transitions
- Track deposits and withdrawals
- Complete fund transaction history
- Initial capital configuration
- Fund flow visualization
- Visual representation of trading performance
- Daily P&L heatmap
- Profitable and losing day identification
- Monthly performance summaries
- OAuth 2.0 Integration:
- Google OAuth support
- Microsoft Entra ID (Azure AD) support
- Secure session management with NextAuth.js
- Data Storage Options:
- Google Drive integration for cloud backup
- OneDrive/SharePoint integration (optional)
- Secure data compression and encryption
- Role-based access control
- Environment-based configuration
- Mobile-first approach
- Desktop, tablet, and mobile optimization
- Touch-friendly interface
- Adaptive layouts
- Dark mode by default (Bloomberg terminal aesthetic)
- Custom Shadcn-style components
- Tailwind CSS v3 with animations
- Glassmorphism effects
- Smooth transitions and micro-interactions
| Category | Technology |
|---|---|
| Framework | Next.js 16 with App Router |
| Language | TypeScript 5.9 |
| Styling | Tailwind CSS 3.4 |
| Charts | Recharts 3.5 |
| Icons | Lucide React |
| UI Components | Shadcn-style components + Radix UI |
| Authentication | NextAuth.js 5.0-beta |
| Date Handling | date-fns 3.6 |
| Testing | Jest 29 + React Testing Library |
| Code Quality | ESLint + Prettier |
| Cloud Storage | Google Drive API, Microsoft Graph |
- Node.js 18+ (LTS recommended)
- npm 9+ or yarn 1.22+
- Git
- Google Cloud Console account (for OAuth)
# 1. Clone the repository
git clone https://github.com/ric-v/drawdown.git
cd drawdown
# 2. Install dependencies
npm install
# 3. Set up environment variables (see Setup Guide below)
cp .env.example .env.local
# 4. Run development server
npm run dev
# 5. Open browser
# Navigate to http://localhost:3000# Development server with hot reload
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
# Format code with Prettier
npm run format
# Run unit tests
npm test
# Run tests in watch mode
npm test:watch
# Generate coverage report
npm test:coverage
# Type checking
npm run type-checkCreate a .env.local file in the root directory:
# NextAuth Configuration
AUTH_SECRET="your-random-secret-key-at-least-32-chars"
AUTH_URL="http://localhost:3000"
# Google OAuth
AUTH_GOOGLE_ID="your-google-client-id"
AUTH_GOOGLE_SECRET="your-google-client-secret"
# Microsoft Entra ID (Optional)
AUTH_MICROSOFT_ENTRA_ID_ID="your-client-id"
AUTH_MICROSOFT_ENTRA_ID_SECRET="your-client-secret"
AUTH_MICROSOFT_ENTRA_ID_TENANT_ID="common"openssl rand -base64 32See Setup Guide for detailed OAuth configuration instructions for:
- β Google OAuth
- β Microsoft Entra ID
- β Google Drive Integration
- β OneDrive Integration
Complete documentation is available in the /docs folder:
| Document | Purpose |
|---|---|
| Setup Guide | OAuth and environment configuration |
| Deployment Guide | Production deployment to Vercel, Azure |
| User Guide | Feature walkthrough and usage |
| Features | Detailed feature documentation |
| Security | Security practices and data protection |
| Roadmap | Future features and improvements |
drawdown/
βββ public/ # Static assets
βββ src/
β βββ app/ # Next.js app router
β β βββ (public)/ # Public pages (privacy, terms)
β β βββ api/ # API routes
β β β βββ auth/ # NextAuth configuration
β β β βββ portfolio/ # Portfolio endpoints
β β β βββ ...
β β βββ actions/ # Server actions
β β βββ globals.css # Global styles with CSS variables
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Main dashboard
β βββ components/
β β βββ auth/ # Authentication components
β β βββ features/ # Feature-specific components
β β β βββ portfolio/ # Portfolio KPIs, charts
β β β βββ transactions/ # Transaction management
β β β βββ funds/ # Fund management
β β βββ layout/ # Layout components
β β βββ ui/ # Reusable UI components
β βββ config/ # Configuration files
β βββ hooks/ # React hooks
β βββ lib/
β β βββ utils/ # Utility functions
β β βββ google-drive.ts # Google Drive integration
β β βββ onedrive.ts # OneDrive integration
β β βββ auth/ # Auth utilities
β βββ middleware.ts # Next.js middleware
β βββ types/ # TypeScript type definitions
βββ docs/ # Documentation
βββ .eslintrc.json # ESLint configuration
βββ .prettierrc # Prettier configuration
βββ jest.config.js # Jest testing configuration
βββ jest.setup.js # Jest setup
βββ tsconfig.json # TypeScript configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ next.config.js # Next.js configuration
βββ package.json # Project dependencies
The project includes comprehensive unit tests using Jest and React Testing Library:
# Run all tests
npm test
# Run tests in watch mode
npm test:watch
# Generate coverage report
npm test:coverage- β Utility functions (formatting, colors, calculations)
- β Type definitions
- β Component integration tests
- β API route validation
Tests are co-located with source files:
src/
βββ lib/
β βββ utils/
β βββ utils.ts
β βββ __tests__/
β βββ utils.test.ts
interface DailyPnL {
id: string;
date: Date;
pnl: number; // Profit (+ve) or Loss (-ve)
notes?: string;
}interface PortfolioStats {
totalPnL: number;
totalPnLPercentage: number;
winRate: number;
totalDays: number;
profitDays: number;
lossDays: number;
averageProfit: number;
averageLoss: number;
largestProfit: number;
largestLoss: number;
currentEquity: number;
initialCapital: number;
profitFactor: number;
expectancy: number;
maxDrawdown: number;
currentStreak: number;
}| Usage | Color | CSS Class |
|---|---|---|
| Profits | Emerald-600 | text-emerald-600 dark:text-emerald-400 |
| Losses | Rose-600 | text-rose-600 dark:text-rose-400 |
| Neutral | Gray-500 | text-gray-500 dark:text-gray-400 |
| Background | Black | #000000 |
| Text | Light Gray | #f3f4f6 |
- Headings: System fonts (sans-serif stack)
- Body: System fonts for performance
- Mono: System monospace for data
- OAuth 2.0 authentication
- Secure session tokens
- Environment-based secrets
- Data encryption for cloud storage
- CORS protection
- CSP headers configured
- No tracking cookies by default
- GDPR-compliant privacy policy
- User data stored in their Google Drive/OneDrive
- See Security Documentation
- Fork the repository on GitHub
- Connect to Vercel
- Set environment variables
- Deploy with one click
npm run build
az staticwebapp up --name drawdown --source . --deployment-token <token>See Deployment Guide for Docker setup.
- The current setup uses file-based storage (works locally)
- Vercel's filesystem is read-only in production
- You MUST use a database for production (Vercel Postgres, MongoDB Atlas, Supabase, etc.)
- See Deployment Guide for database setup
- Chrome/Edge: Latest 2 versions
- Firefox: Latest 2 versions
- Safari: Latest version
- Mobile browsers: iOS Safari 12+, Chrome Mobile latest
Contributions are welcome! Follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Run linter:
npm run lint:fix - Format code:
npm run format - Run tests:
npm test - Check types:
npm run type-check
All pull requests must pass CI/CD checks.
See Roadmap for upcoming features:
- Real-time data integration with brokers
- AI-powered trading insights
- Advanced analytics dashboards
- Multi-portfolio support
- Trading signals and alerts
- Tax reporting tools
- Mobile app (React Native)
- Community features
This project is licensed under the ISC License - see LICENSE file for details.
- Design inspired by Bloomberg Terminal
- Built with Next.js
- UI components inspired by Shadcn UI
- Charts powered by Recharts
- Icons by Lucide React
- Authentication by NextAuth.js
- π Documentation
- π Report Issues
- π¬ Discussions
Made with β€οΈ by the Trading Community
Last updated: January 6, 2026
