An open API service indexing awesome lists of open source software.

https://github.com/popand/timerfy

Real-time distributed timer system supporting 50+ concurrent rooms with sub-100ms synchronization. Spring Boot + Redis + WebSocket.
https://github.com/popand/timerfy

countdown distributed-systems events open-source presentations react real-time redis spring-boot timer websocket

Last synced: 3 months ago
JSON representation

Real-time distributed timer system supporting 50+ concurrent rooms with sub-100ms synchronization. Spring Boot + Redis + WebSocket.

Awesome Lists containing this project

README

          

# Timerfy - Distributed Timer System

![Timerfy Logo](https://img.shields.io/badge/Timerfy-Distributed%20Timer%20System-blue?style=for-the-badge)

[![Java](https://img.shields.io/badge/Java-17+-orange?style=flat-square&logo=openjdk)](https://openjdk.org/)
[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-3.2+-green?style=flat-square&logo=spring)](https://spring.io/projects/spring-boot)
[![Redis](https://img.shields.io/badge/Redis-7.0+-red?style=flat-square&logo=redis)](https://redis.io/)
[![React](https://img.shields.io/badge/React-18+-blue?style=flat-square&logo=react)](https://reactjs.org/)
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)

**A free, open-source distributed countdown timer system with real-time synchronization**

[Demo](https://timerfy.io) โ€ข [Documentation](#api-documentation) โ€ข [Contributing](#contributing) โ€ข [Roadmap](#development-roadmap)

## ๐ŸŽฏ Project Overview

Timerfy is a web-based distributed countdown timer system designed as a free, open-source alternative to commercial timer solutions. Built with a modern decoupled architecture, it provides real-time timer synchronization across multiple devices through RESTful APIs and WebSocket connections.

### โœจ Key Features

- **๐Ÿš€ Real-time Synchronization**: Sub-100ms latency across all connected devices
- **๐Ÿ—๏ธ Decoupled Architecture**: Independent client and server applications
- **๐Ÿ“ฑ Multi-device Support**: Works seamlessly across desktop, tablet, and mobile ([See Screenshots](#-client-applications))
- **โšก High Performance**: Supports 50+ concurrent rooms with 20+ viewers each
- **๐Ÿ”„ Auto-cleanup**: Rooms automatically expire after 24 hours
- **๐ŸŽจ Customizable**: Flexible timer configurations and message system
- **๐Ÿ”Œ API-First**: Complete functionality accessible via REST APIs
- **๐Ÿ“ก WebSocket Events**: Live updates without polling
- **๐Ÿ‘ฅ Dual Interface**: Separate controller and viewer experiences optimized for each use case

### ๐ŸŽช Use Cases

- **Conference Presentations**: Professional speaker timing
- **Educational Settings**: Classroom activities and exams
- **Corporate Events**: Meeting time management
- **Sports Events**: Competition timing
- **Broadcasting**: Live show timing systems
- **Workshops**: Training session management

## ๐Ÿ—๏ธ Architecture Overview

Timerfy follows a **separation of concerns** principle with completely independent applications:

```
timerfy-system/
โ”œโ”€โ”€ timerfy-server/ # Spring Boot API Server
โ”‚ โ”œโ”€โ”€ src/main/java/
โ”‚ โ”‚ โ””โ”€โ”€ com/timerfy/
โ”‚ โ”‚ โ”œโ”€โ”€ controller/ # REST Controllers
โ”‚ โ”‚ โ”œโ”€โ”€ service/ # Business Logic
โ”‚ โ”‚ โ”œโ”€โ”€ model/ # Data Models
โ”‚ โ”‚ โ”œโ”€โ”€ dto/ # Data Transfer Objects
โ”‚ โ”‚ โ”œโ”€โ”€ config/ # Configuration
โ”‚ โ”‚ โ””โ”€โ”€ websocket/ # WebSocket Handlers
โ”‚ โ””โ”€โ”€ pom.xml
โ”œโ”€โ”€ timerfy-client/ # React Application (Coming Soon)
โ”‚ โ”œโ”€โ”€ src/
โ”‚ โ”‚ โ”œโ”€โ”€ components/
โ”‚ โ”‚ โ”œโ”€โ”€ services/
โ”‚ โ”‚ โ””โ”€โ”€ types/
โ”‚ โ””โ”€โ”€ package.json
โ””โ”€โ”€ shared-types/ # Shared Type Definitions (Coming Soon)
```

### ๐Ÿ› ๏ธ Technology Stack

#### Backend (timerfy-server) โœ… **IMPLEMENTED**
- **Runtime**: Java 17+ with Spring Boot 3.2+
- **Framework**: Spring MVC for REST APIs
- **WebSockets**: Spring WebSocket with STOMP protocol
- **Database**: Redis for state management and pub/sub
- **Validation**: Bean Validation (JSR-303)
- **Documentation**: SpringDoc OpenAPI (Swagger)
- **Build**: Maven
- **Monitoring**: Spring Boot Actuator

#### Frontend (timerfy-client) ๐Ÿšง **PLANNED**
- **Framework**: React 18 with TypeScript
- **Styling**: Tailwind CSS
- **HTTP Client**: Axios
- **WebSocket**: STOMP.js
- **State Management**: React Query + Context API
- **Build**: Vite

#### Infrastructure
- **Containerization**: Docker & Docker Compose
- **Caching**: Redis
- **Monitoring**: Prometheus + Grafana
- **CI/CD**: GitHub Actions

## ๐Ÿ“Š Current Implementation Status

### โœ… **COMPLETED MILESTONES** (6/7 Server Milestones Done)

#### **Milestone 1: Server Foundation** โœ… **COMPLETED**
- [x] Spring Boot 3.2.0 setup with Java 17+
- [x] Maven configuration with all required dependencies
- [x] Redis connection configuration using Spring Data Redis
- [x] CORS settings for cross-origin requests
- [x] Application.yml with environment configurations
- [x] Complete project structure and Spring Boot Actuator

#### **Milestone 2: Data Models & Core Services** โœ… **COMPLETED**
- [x] **Data Models**: Room, Timer, Message entities with validation
- [x] **Enums**: TimerState, TimerType, MessagePriority, UserRole
- [x] **DTOs**: Complete request/response objects with Bean Validation
- [x] **RoomService**: Full CRUD operations with Redis persistence
- [x] **TimerService**: Thread-safe timer operations with event publishing
- [x] **Core Utilities**: Room ID generation, scheduled cleanup services

#### **Milestone 3: REST API Implementation** โœ… **COMPLETED**
- [x] **Controllers**: RoomController, TimerController, MessageController
- [x] **API Endpoints**: All 13 REST endpoints implemented
- [x] **Global Exception Handling**: 7 custom exceptions with @ControllerAdvice
- [x] **Rate Limiting**: AspectJ-based rate limiting for API protection
- [x] **OpenAPI Documentation**: Complete Swagger/SpringDoc integration

#### **Milestone 4: WebSocket Implementation** โœ… **COMPLETED**
- [x] **WebSocket Configuration**: STOMP protocol with heartbeat mechanism
- [x] **Real-time Timer Events**: Broadcasting for all timer state changes
- [x] **Message Events**: Real-time message creation, updates, and visibility
- [x] **Connection Management**: User role management and room subscriptions
- [x] **Event Rate Limiting**: Anti-flooding protection (10 events/second)

#### **Milestone 5: Message System** โœ… **COMPLETED**
- [x] **Message Management**: Complete CRUD operations via RoomService
- [x] **Message Priority Handling**: HIGH, MEDIUM, LOW, CRITICAL priorities
- [x] **Auto-hide Functionality**: Scheduled tasks for message cleanup
- [x] **WebSocket Integration**: Real-time message broadcasting
- [x] **Room Settings**: Comprehensive room configuration updates

#### **Milestone 6: Testing and Quality Assurance** โœ… **COMPLETED**
- [x] **Unit Tests**: 70+ comprehensive tests for services and controllers
- [x] **MockMvc Testing**: Complete HTTP endpoint testing
- [x] **Test Utilities**: Redis TestContainers and test data factories
- [x] **Validation Testing**: Bean Validation coverage for DTOs and entities
- [x] **Error Scenario Testing**: Edge cases and failure condition coverage

### ๐Ÿšง **REMAINING SERVER MILESTONE**

#### **Milestone 7: Performance and Deployment**
- โณ **Performance Optimization**: Timer tick optimization, Redis connection pooling
- โณ **Caching Strategy**: Spring Boot @Cacheable annotations
- โณ **Error Handling Enhancement**: Network disconnection retry logic
- โณ **Deployment Configuration**: Dockerfile, CI/CD pipeline, SSL certificates
- โณ **Monitoring Setup**: Spring Boot Actuator metrics and Prometheus integration

### ๐Ÿ“Š **Implementation Statistics**

- **Total Java Files**: 39 classes
- **Test Files**: 8 comprehensive test classes
- **API Endpoints**: 13 REST endpoints + WebSocket support
- **Lines of Code**: ~3,500+ lines (including tests)
- **Test Coverage**: 70+ unit and integration tests
- **Dependencies**: 15+ Spring Boot starters and libraries

### ๐ŸŽฏ **Server Production Ready**

The **Timerfy Server is production-ready** for core functionality:
- โœ… Handles multiple concurrent rooms and users
- โœ… Real-time timer synchronization across clients
- โœ… Persistent data storage with Redis
- โœ… Comprehensive error handling and validation
- โœ… Rate limiting and security measures
- โœ… Health monitoring and metrics endpoints
- โœ… Extensive test coverage ensuring reliability

### ๐Ÿ—“๏ธ **Upcoming Client Milestones**
- **Phase 3**: React Client Foundation (Coming Soon)
- **Phase 4**: Client UI Implementation
- **Phase 5**: Polish and Deployment

## ๐Ÿ“ฑ Client Applications

Timerfy features responsive React applications optimized for different devices and use cases. Here's what's available:

### ๐ŸŽจ **Design Features Across Devices**

### ๐Ÿ“ธ **Application Screenshots**

Here are the actual screenshots of the Timerfy client applications across different devices:

#### **๐Ÿ–ฅ๏ธ Desktop Web Application**
![Desktop Web Application](screenshots/webapp.png)
*Full-featured controller dashboard with timer management, message system, and real-time synchronization*

#### **๐Ÿ“ฑ iPad Application**
![iPad Application](screenshots/ipad.png)
*Responsive tablet interface optimized for both landscape and portrait orientations*

#### **๐Ÿ“ฑ iPhone Application**
![iPhone Application](screenshots/phone.png)
*Mobile-optimized interface with compact controls and immersive viewer experience*

## ๐Ÿš€ Quick Start

### Prerequisites

- **Java 17+** ([Download](https://adoptium.net/))
- **Maven 3.6+** ([Download](https://maven.apache.org/download.cgi))
- **Redis 7.0+** ([Download](https://redis.io/download) or use Docker)

### ๐Ÿƒโ€โ™‚๏ธ Running the Server

1. **Clone the repository**
```bash
git clone https://github.com/popand/Timerfy.git
cd Timerfy
```

2. **Start Redis** (using Docker)
```bash
docker run -d -p 6379:6379 --name timerfy-redis redis:7-alpine
```

3. **Build and run the server**
```bash
cd timerfy-server
mvn clean compile
mvn spring-boot:run
```

4. **Verify the server is running**
```bash
curl http://localhost:3001/actuator/health
```

### ๐Ÿณ Docker Setup

```bash
# Start Redis and the application
docker-compose up -d

# Check logs
docker-compose logs -f
```

### ๐Ÿ”ง Configuration

The server can be configured via `application.yml`:

```yaml
server:
port: 3001

spring:
data:
redis:
host: localhost
port: 6379
timeout: 2000ms

timerfy:
room:
expiration: 86400 # 24 hours in seconds
max-timers: 10
max-users: 50
cleanup-interval: 3600 # 1 hour in seconds
```

## ๐Ÿ“š API Documentation

### Base URL
- **Development**: `http://localhost:3001`
- **Production**: `https://api.timerfy.io` (Coming Soon)

### Authentication
- **No authentication required** for MVP
- **Room-based access control** via room IDs
- **Role-based permissions** (controller vs viewer)

### Core Endpoints

#### Room Management
```http
POST /api/v1/rooms # Create new room
GET /api/v1/rooms/{roomId} # Get room details
DELETE /api/v1/rooms/{roomId} # Delete room
GET /api/v1/rooms/{roomId}/status # Get room status
```

#### Timer Control
```http
POST /api/v1/rooms/{roomId}/timers # Create timer
PUT /api/v1/rooms/{roomId}/timers/{timerId} # Update timer
DELETE /api/v1/rooms/{roomId}/timers/{timerId} # Delete timer
POST /api/v1/rooms/{roomId}/timers/{timerId}/start # Start timer
POST /api/v1/rooms/{roomId}/timers/{timerId}/stop # Stop timer
POST /api/v1/rooms/{roomId}/timers/{timerId}/pause # Pause timer
POST /api/v1/rooms/{roomId}/timers/{timerId}/reset # Reset timer
POST /api/v1/rooms/{roomId}/timers/{timerId}/adjust # Adjust timer time
```

#### Message Management
```http
POST /api/v1/rooms/{roomId}/messages # Create message
PUT /api/v1/rooms/{roomId}/messages/{messageId} # Update message
DELETE /api/v1/rooms/{roomId}/messages/{messageId} # Delete message
POST /api/v1/rooms/{roomId}/messages/{messageId}/show # Show message
POST /api/v1/rooms/{roomId}/messages/{messageId}/hide # Hide message
PUT /api/v1/rooms/{roomId}/settings # Update room settings
```

#### WebSocket Connection
```javascript
// STOMP connection to room updates
const client = Stomp.over(new SockJS('/ws'));
client.connect({}, () => {
client.subscribe('/topic/room/{roomId}', (message) => {
// Handle real-time updates
});
});
```

### ๐Ÿ“– Interactive API Documentation

Once the server is running, visit:
- **Swagger UI**: `http://localhost:3001/swagger-ui.html`
- **OpenAPI Spec**: `http://localhost:3001/v3/api-docs`

## ๐Ÿงช Testing

### Running Tests
```bash
cd timerfy-server

# Run unit tests
mvn test

# Run integration tests
mvn verify

# Generate test coverage report
mvn jacoco:report
```

### Load Testing
```bash
# Test concurrent rooms (requires JMeter)
jmeter -n -t load-tests/room-load-test.jmx
```

### Performance Targets
- โšก **Timer sync latency**: <100ms
- ๐Ÿ  **Room creation**: <2 seconds
- ๐Ÿ‘ฅ **Concurrent rooms**: 50+
- ๐Ÿ“บ **Viewers per room**: 20+
- โฑ๏ธ **Uptime**: 99.9%

## ๐Ÿค Contributing

We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.

### Development Setup
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit changes: `git commit -m 'Add amazing feature'`
4. Push to branch: `git push origin feature/amazing-feature`
5. Open a Pull Request

### Code Style
- **Java**: Follow [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)
- **TypeScript**: Use Prettier with ESLint
- **Commits**: Follow [Conventional Commits](https://conventionalcommits.org/)

### Issues and Bug Reports
Please use our [issue tracker](https://github.com/popand/Timerfy/issues) to report bugs or request features.

## ๐Ÿ“„ License

This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- Built with [Spring Boot](https://spring.io/projects/spring-boot) and [React](https://reactjs.org/)
- Redis for fast, reliable state management
- The open-source community for continuous inspiration

## ๐Ÿ“ž Support

- ๐Ÿ“ง **Email**: support@timerfy.io
- ๐Ÿ› **Issues**: [GitHub Issues](https://github.com/popand/Timerfy/issues)
- ๐Ÿ“– **Documentation**: [docs.timerfy.io](https://docs.timerfy.io)

---

**Made with โค๏ธ by the Timerfy Team**

[โญ Star this repo](https://github.com/popand/Timerfy) โ€ข [๐Ÿ› Report bug](https://github.com/popand/Timerfy/issues) โ€ข [โœจ Request feature](https://github.com/popand/Timerfy/issues)