A scalable, high-availability microservices-based backend system for event management, built with FastAPI and designed for trading-grade consistency and 99.99% uptime.
Evently implements a modern microservices architecture with 5 core services, each designed for specific business domains while maintaining loose coupling and high cohesion.
| Service | Purpose | Key Features |
|---|---|---|
| Auth Service | Authentication & Authorization | JWT tokens, RBAC, OTP verification, session management |
| Events Service | Event Management | CRUD operations, caching, pub/sub notifications |
| Bookings Service | Booking & Availability | High-consistency bookings, waitlist, optimistic locking |
| Analytics Service | Analytics & Reporting | Real-time metrics, event-driven aggregation |
| Email Workers | Asynchronous Processing | Celery-based email notifications, background tasks |
- Framework: FastAPI (async, high-performance)
- Database: PostgreSQL with SQLAlchemy ORM
- Cache: Redis (caching, sessions, pub/sub, distributed locking)
- Message Queue: Celery with Redis broker
- Authentication: JWT with role-based access control
- Secrets Management: Zero SDK
- Containerization: Docker with health checks
- Monitoring: Structured logging, health endpoints
- Asynchronous Pub/Sub: Redis channels for event notifications
- Background Processing: Celery tasks for non-blocking operations
Client β Auth Service (JWT validation)
Client β Events Service (browse events)
Client β Bookings Service (create booking)
Events Service - Bookings Service (add published events)
Events Service β Analytics Service (event metrics)
Bookings Service β Analytics Service (booking metrics)
Bookings Service β Email Workers (send notifications)
Auth Service -> Email Workers (send emails)
Each service maintains its own PostgreSQL database with domain-specific models:
- Users: User accounts, roles, verification status
- UserSessions: Active sessions, security tracking
- Events: Event details, capacity, pricing, status
- Bookings: Booking records with optimistic locking
- BookingItems: Individual booking line items
- EventAvailability: Real-time capacity tracking
- WaitlistEntry: Waitlist management
- AuditLogs: Complete audit trail
- EventStats: Per-event aggregated metrics
- DailyStats: Time-series daily aggregates
- TopEvents: Pre-computed leaderboards
- SystemMetrics: System-wide KPIs
- EventLog: Event processing audit
Decision: Microservices architecture Trade-offs:
- β Pros: Independent scaling, technology diversity, fault isolation, team autonomy
- β Cons: Increased complexity, network latency, distributed data management
- Rationale: Event management has distinct domains (auth, events, bookings, analytics) that benefit from independent evolution
Decision: Each service owns its database Trade-offs:
- β Pros: Data isolation, independent schema evolution, service autonomy
- β Cons: Cross-service queries require API calls, eventual consistency challenges
- Rationale: Strong domain boundaries enable independent scaling and reduce coupling
Decision: Redis pub/sub for inter-service communication Trade-offs:
- β Pros: Loose coupling, real-time updates, scalability
- β Cons: Eventual consistency, message ordering challenges
- Rationale: Analytics and notifications can tolerate eventual consistency for better performance
Decision: Version-based optimistic locking in bookings Trade-offs:
- β Pros: High concurrency, better performance than pessimistic locking
- β Cons: Retry logic required, potential for conflicts
- Rationale: Booking conflicts are rare, optimistic locking provides better user experience
Decision: Redis for caching, sessions, pub/sub, and distributed locking Trade-offs:
- β Pros: Single technology, high performance, rich data structures
- β Cons: Single point of failure, memory limitations
- Rationale: Redis provides excellent performance for all use cases
- Stateless Services: All services are stateless, enabling easy horizontal scaling
- Load Balancing: Docker Compose with multiple replicas
- Database Scaling: Read replicas and connection pooling
- Cache Scaling: Redis clustering for high availability
- Circuit Breaker Pattern: Automatic service degradation
- Health Checks: Built-in health endpoints with dependency checks
- Graceful Degradation: Services continue with reduced functionality
- Retry Logic: Exponential backoff for transient failures
- Distributed Locking: Redis-based locks prevent race conditions
- 99.99% Uptime SLA: Designed for mission-critical operations
- Automatic Failover: Service restart policies and health monitoring
- Data Redundancy: Database backups and replication
- Zero-Downtime Deployments: Rolling updates with health checks
- JWT Tokens: Stateless authentication with access/refresh token rotation
- Role-Based Access Control: User and Admin roles with granular permissions
- Session Management: Redis-based session tracking with security features
- Zero SDK: Secure secrets management
- Input Validation: Pydantic schemas for all API inputs
- SQL Injection Protection: SQLAlchemy ORM with parameterized queries
- Rate Limiting: Redis-based rate limiting on authentication endpoints
- CORS Protection: Configurable origin restrictions
- HTTPS Enforcement: TLS termination at load balancer
- Internal Network: Isolated Docker network for service communication
- Multi-Level Caching: Application-level and Redis caching
- Smart Cache Invalidation: Event-driven cache updates
- TTL Management: Configurable cache expiration
- Connection Pooling: Optimized database connections
- Indexing Strategy: Strategic indexes for query performance
- Query Optimization: Efficient SQLAlchemy queries
- Non-Blocking Operations: FastAPI async/await throughout
- Background Tasks: Celery for email processing
- Event-Driven Updates: Real-time notifications via pub/sub
- Real-time Aggregation: Analytics updated via Redis pub/sub events
- Pre-computed Metrics: Optimized dashboard queries
- Time-series Optimization: Efficient daily/weekly/monthly aggregates
- Priority-based Queue: FIFO with admin override capabilities
- Automatic Notifications: Real-time waitlist position updates
- Capacity Release: Automatic booking when capacity becomes available
- Version-based Locking: Prevents booking conflicts without blocking
- Retry Mechanisms: Automatic retry with exponential backoff
- Audit Trail: Complete history of all booking changes
- Zero SDK Integration: Secure secrets management without hardcoded values
- Environment Flexibility: Seamless local/production configuration
- Security by Default: No secrets in code or environment files
- Auth Service - Authentication, JWT, RBAC, OTP verification
- Events Service - Event CRUD, caching, pub/sub notifications
- Bookings Service - High-consistency bookings, waitlist, availability
- Analytics Service - Real-time analytics, metrics, reporting
- Email Workers - Asynchronous email processing, notifications
- Docker & Docker Compose
- Zero SDK token for secrets management
# Clone repository
git clone <repository-url>
cd evently
# Set up environment
export ZERO_TOKEN="your-zero-token"
# Start all services
docker-compose up -d
# Check service health
curl http://localhost:35000/health # Auth Service
curl http://localhost:35001/health # Events Service
curl http://localhost:35002/health # Bookings Service
curl http://localhost:35003/health # Analytics Service- Auth Service: http://localhost:35000
- Events Service: http://localhost:35001
- Bookings Service: http://localhost:35002
- Analytics Service: http://localhost:35003
# Run all service tests
pytest auth_service/tests/ -v
pytest events_service/tests/ -v
pytest bookings_service/tests/ -v
pytest analytics_service/tests/ -v- Unit Tests: Service logic and business rules
- Integration Tests: API endpoints and database operations
- Concurrency Tests: Booking conflicts and race conditions
- Performance Tests: Load testing and optimization validation
- Health Endpoints:
/healthon all services with dependency checks - Service Information:
/infoendpoints with service capabilities - Structured Logging: JSON-formatted logs with correlation IDs
- Request Timing: Response time tracking
- Database Metrics: Query performance and connection pooling
- Cache Metrics: Hit rates and performance
- Error Tracking: Comprehensive error logging and alerting
- User Authentication: Immediate consistency for security
- Booking Operations: ACID transactions for financial accuracy
- Payment Processing: Strong consistency for monetary operations
- Analytics Updates: Event-driven updates with eventual consistency
- Cache Invalidation: Eventual consistency for performance
- Cross-Service Queries: Eventual consistency for scalability
- Complete Audit Trail: All operations logged with timestamps
- Data Retention: Configurable retention policies
- Security Logging: Authentication and authorization events
- Service Isolation: Independent service scaling
- Data Isolation: Service-specific databases
- Configuration Management: Zero SDK for tenant-specific configs
- Database Backups: Automated backup strategies
- Service Redundancy: Multiple service instances
- Geographic Distribution: Multi-region deployment support