ThreatLens is a comprehensive security log analysis platform that provides real-time threat detection, AI-powered analysis, and intuitive visualization of security events.
- Real-time Log Processing: Monitor security logs in real-time
- AI-Powered Analysis: Advanced threat detection using machine learning
- macOS Console Integration: Native support for macOS Console logs
- Web Dashboard: Modern React-based user interface
- WebSocket API: Real-time updates and notifications
- Multi-format Support: Parse various log formats (syslog, Console, custom)
- Threat Categorization: Automatic event classification
- Historical Analysis: Search and analyze historical security events
threatlens/
βββ frontend/ # React TypeScript frontend
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API services
β β βββ types/ # TypeScript definitions
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
β
βββ backend/ # FastAPI Python backend
β βββ app/ # Main application code
β β βββ realtime/ # Real-time processing
β β βββ migrations/ # Database migrations
β β βββ ... # Core modules
β βββ tests/ # Backend tests
β βββ data/ # Sample data
β βββ scripts/ # Utility scripts
β βββ main.py # API server entry point
β βββ requirements.txt # Python dependencies
β
βββ docs/ # Documentation
βββ docker-compose.yml # Docker configuration
βββ README.md # This file
- Node.js 16+ and npm (for frontend)
- Python 3.8+ (for backend)
- Docker (optional, for containerized deployment)
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up environment
python setup_env.py
# Start the backend server
python main.pyBackend will be available at: http://localhost:8000
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will be available at: http://localhost:3000
# Start both frontend and backend
docker-compose up -d
# View logs
docker-compose logs -fCopy backend/.env.example to backend/.env and configure:
# Database
DATABASE_URL=sqlite:///./threatlens.db
# Security
SECRET_KEY=your-secret-key
# API Settings
DEBUG=true
LOG_LEVEL=INFOThe frontend automatically connects to the backend API. For custom configurations, check frontend/src/services/api.ts.
Web Interface:
- Navigate to http://localhost:3000/ingest
- Upload log files or paste log content
- Click "Analyze" to process
API:
# Upload file
curl -X POST -F "file=@logfile.log" http://localhost:8000/api/ingest/file
# Submit text
curl -X POST -H "Content-Type: application/json" \
-d '{"content":"log content","source":"test"}' \
http://localhost:8000/api/ingest/textcd backend
# Analyze recent Console logs
python scripts/console_integration.py
# Security-focused monitoring
python scripts/console_integration.py --mode security --hours 24
# Monitor specific process
python scripts/console_integration.py --mode process --process sshdThe system supports real-time log monitoring through WebSocket connections. Connect to ws://localhost:8000/ws for live updates.
cd backend
pytest # Run all tests
pytest --cov=app # Run with coverage
pytest tests/test_parser.py # Run specific testcd frontend
npm test # Run tests
npm run test:coverage # Run with coverageOnce the backend is running, visit:
- Interactive API Docs: http://localhost:8000/docs
- OpenAPI Schema: http://localhost:8000/openapi.json
- Backend: Use Gunicorn with Uvicorn workers
- Frontend: Build and serve with nginx
- Database: Consider PostgreSQL for production
- Monitoring: Set up logging and health checks
See DEPLOYMENT.md for detailed deployment instructions.
# Build and deploy
docker-compose -f docker-compose.prod.yml up -d- Authentication: JWT-based user authentication
- Input Validation: Comprehensive input sanitization
- Rate Limiting: API rate limiting and abuse prevention
- CORS: Configurable cross-origin resource sharing
- Audit Logging: Complete audit trail of all actions
- Concurrent Processing: Multi-threaded log processing
- WebSocket Scaling: Efficient real-time communication
- Database Optimization: Indexed queries and connection pooling
- Caching: In-memory caching for frequently accessed data
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check the
docs/directory - Issues: Report bugs and request features via GitHub Issues
- Discussions: Join community discussions
- β macOS Console Integration: Full support for Console log format
- β Real-time Processing: WebSocket-based live monitoring
- β Enhanced UI: Modern React dashboard with real-time updates
- β Security Hardening: Comprehensive security measures
- β Performance Optimization: Improved processing speed and scalability
ThreatLens - Making security log analysis intelligent and accessible.