A comprehensive audit event management system designed for enterprise-grade event tracking, real-time alerting, and compliance monitoring. This platform demonstrates modern microservices architecture integrating Python, Java, React, PostgreSQL, and Redis.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ External Apps │────▶│ FastAPI API │────▶│ PostgreSQL │
│ (API Keys) │ │ (Python) │ │ Database │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Redis Streams │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ React UI │◀────│ Java Rule │
│ Dashboard │ │ Engine │
└─────────────────┘ └─────────────────┘
- RESTful API for event ingestion and management
- JWT-based authentication for dashboard users
- API key authentication for external applications
- Rate limiting per API key
- Redis Streams integration for event publishing
- Modern dashboard built with React 18 and TypeScript
- Real-time event monitoring
- API key management interface
- Alert visualization and management
- Consumes events from Redis Streams
- Applies configurable rules for alert generation
- Supports multiple alert severity levels
- Persistent alert storage in PostgreSQL
- PostgreSQL 15 for persistent storage
- Redis 7 for event streaming
- Docker Compose for orchestration
- GitHub Actions for CI/CD
- Docker and Docker Compose
- Git
# Clone the repository
git clone https://github.com/your-org/auditflow.git
cd auditflow
# Copy environment file
cp .env.example .env
# Start all services
docker-compose up -d
# Verify services are running
docker-compose ps- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Dashboard: http://localhost:5173
- PostgreSQL: localhost:5432
- Redis: localhost:6379
curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "securepassword"}'curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "securepassword"}'curl -X POST http://localhost:8000/api/keys \
-H "Authorization: Bearer <jwt_token>" \
-H "Content-Type: application/json" \
-d '{"name": "production-app", "description": "Production application key"}'curl -X POST http://localhost:8000/api/events \
-H "X-API-Key: <your_api_key>" \
-H "Content-Type: application/json" \
-d '{
"event_type": "login",
"severity": "info",
"source": "auth-service",
"payload": {
"user_id": "user123",
"ip_address": "192.168.1.100",
"success": true
}
}'login- User authentication eventslogout- User session terminationpayment- Financial transactionserror- Application errorsaccess- Resource access eventsmodification- Data modification eventsdeletion- Data deletion eventscustom- Custom event types
debug- Debugging informationinfo- Informational eventswarning- Warning conditionserror- Error conditionscritical- Critical conditions requiring immediate attention
The Java rule engine processes events and generates alerts based on configurable rules:
| Rule | Condition | Alert Level |
|---|---|---|
| Critical Error | severity == critical |
HIGH |
| Payment Failure | event_type == payment && payload.success == false |
HIGH |
| Multiple Failed Logins | event_type == login && count > 5 in 5min |
MEDIUM |
| Unusual Access Pattern | event_type == access && off_hours |
LOW |
# API Tests
cd api
pip install -r requirements.txt
pytest tests/ -v
# UI Tests
cd ui
npm install
npm test
# Rule Engine Tests
cd rule-engine
mvn test# Start infrastructure only
docker-compose up -d postgres redis
# Run API locally
cd api
pip install -r requirements.txt
uvicorn app.main:app --reload
# Run UI locally
cd ui
npm install
npm run dev
# Run Rule Engine locally
cd rule-engine
mvn spring-boot:runusers- Dashboard user accountsapi_keys- API keys for external applicationsevents- Audit event storagealerts- Generated alerts
| Variable | Description | Default |
|---|---|---|
POSTGRES_USER |
Database username | auditflow |
POSTGRES_PASSWORD |
Database password | auditflow_secret |
POSTGRES_DB |
Database name | auditflow |
JWT_SECRET |
JWT signing key | - |
REDIS_URL |
Redis connection URL | redis://localhost:6379 |
CORS_ORIGINS |
Allowed CORS origins | http://localhost:5173 |
- API Key Security: Keys are hashed before storage
- Rate Limiting: Per-key rate limiting prevents abuse
- JWT Tokens: Short-lived tokens with secure signing
- Input Validation: Pydantic schemas validate all input
- SQL Injection Prevention: SQLAlchemy ORM prevents SQL injection
MIT License - See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For issues and feature requests, please use the GitHub issue tracker.