π Real-time User Presence & Movement Intelligence Service
PlaceLive-Tracker is the social awareness and movement analytics engine of the PlaceLive ecosystem. This microservice manages real-time user presence tracking, movement logging, privacy-controlled visibility, and friend discovery at specific places. It serves as the foundation for PlaceLive's revolutionary "photocopy problem" solution, enabling users to find friends near relevant shops without manual calls.
- Real-time Presence Management: Track user entry/exit in geofenced areas with timestamp precision
- Movement Pattern Analysis: Log and analyze user movement patterns for behavioral insights
- Friend Discovery Engine: Compute "friends present at this place" for social connectivity
- Privacy-Controlled Visibility: Granular control over who can see user presence
- Context-Aware Tracking: Different visibility rules based on place types (public, private, work)
- Active Friend Identification: Find which friends are currently at specific places
- Automated Friend Requests: Send location-based friend requests when users need something from nearby shops
- Circle-Based Privacy: Respect user-defined friend circles and permission levels
- Role-Based Access Control: Parents can monitor children, managers can see employee availability
- Shop Analytics: Provide businesses with anonymized foot traffic insights
- Peak Time Analysis: Identify busy periods for different types of establishments
- User Behavior Patterns: Generate insights for personalized recommendations
- Social Proof: Show when friends have visited specific places
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Geofencing ββββββ Tracker Service ββββββ User Service β
β Service β β β β β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β MySql ββββββ Common Library ββββββ Notification β
β (Presence Data) β β (Generic CRUD) β β Service β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
- Framework: Spring Boot 2.x with Spring Data JPA
- Database: PostgreSQL with optimized indexing for temporal queries
- Architecture: Event-driven microservice with RESTful APIs
- Integration: Kafka for real-time event streaming
- Caching: Redis for frequently accessed presence data
- Monitoring: Spring Boot Actuator with custom metrics
Location Event Input (from Geofencing Service)
|
βΌ
Tracker Event Processing:
βββΊ Validate user permissions
βββΊ Update presence records
βββΊ Calculate active time windows
βββΊ Trigger friend notifications (if enabled)
βββΊ Log analytics data
Query Processing (from API requests):
βββΊ Receive place/user query
βββΊ Check privacy permissions
βββΊ Query active presence records
βββΊ Filter by friend relationships
βββΊ Return PlaceWithFriendsDTO
// Find active users in specific geofences
trackerRepo.findByGeofenceIdInAndUserIdInAndIsUserInTrue(
List<String> geofenceIds,
List<String> userIds
)
// Get user presence history
trackerRepo.findByUserIdAndTimestampBetween(
String userId,
LocalDateTime start,
LocalDateTime end
)
// Find users currently at a place
trackerRepo.findActiveUsersAtPlace(
String placeId,
LocalDateTime activeWindow
)- Java 11 or higher
- Maven 3.6+
- PostgreSQL 12+
- Redis 6.x (for caching)
- Docker (optional)
-
Clone the repository
git clone https://github.com/JLSS-virtual/PlaceLive-Tracker.git cd PlaceLive-Tracker -
Configure database
# application.yml spring: datasource: url: jdbc:postgresql://localhost:5432/placelive_tracker username: your_username password: your_password -
Configure Redis
spring: redis: host: localhost port: 6379 -
Run the application
./mvnw spring-boot:run
docker build -t placelive-tracker .
docker run -p 8083:8083 placelive-trackerPOST /api/v1/tracker/events
Content-Type: application/json
{
"userId": "user123",
"geofenceId": "geofence456",
"placeId": "place789",
"eventType": "ENTRY",
"timestamp": "2024-01-01T12:00:00Z",
"latitude": 40.7128,
"longitude": -74.0060
}GET /api/v1/tracker/active-friends?placeId=place789&userId=user123GET /api/v1/tracker/presence-history?userId=user123&from=2024-01-01&to=2024-01-02GET /api/v1/tracker/place-analytics?placeId=place789&period=DAILY{
"placeId": "place789",
"placeName": "Central Library",
"activeFriends": [
{
"userId": "friend1",
"username": "alice_student",
"entryTime": "2024-01-01T11:30:00Z",
"status": "STUDYING",
"visibilityLevel": "FRIENDS"
},
{
"userId": "friend2",
"username": "bob_researcher",
"entryTime": "2024-01-01T10:15:00Z",
"status": "WORKING",
"visibilityLevel": "PUBLIC"
}
],
"totalActiveUsers": 15,
"userCanSeeAll": false
}{
"userId": "user123",
"period": {
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-02T00:00:00Z"
},
"visits": [
{
"placeId": "place789",
"placeName": "Central Library",
"entryTime": "2024-01-01T09:00:00Z",
"exitTime": "2024-01-01T17:30:00Z",
"duration": "PT8H30M",
"purpose": "STUDY"
}
],
"totalPlacesVisited": 5,
"totalTimeTracked": "PT12H45M"
}- Granular Visibility Settings: Control who can see presence at different place types
- Friend Circle Integration: Respect user-defined social groups
- Temporary Invisibility: Users can go "offline" while still being tracked for safety
- Place-Specific Privacy: Different rules for home, work, public places
- Data Retention Policies: Automatic cleanup of old presence data
- Authentication Required: All API calls require valid JWT tokens
- Rate Limiting: Prevent abuse of tracking queries
- Data Encryption: All sensitive data encrypted at rest and in transit
- Audit Logging: Complete audit trail of all tracking activities
- GDPR Compliance: User data deletion and export capabilities
@Service
public class TrackerService {
public void recordPresenceEvent(PresenceEvent event) {
// Validate privacy settings
// Update presence records
// Trigger notifications if needed
}
public List<ActiveFriend> getActiveFriendsAtPlace(String placeId, String userId) {
// Check user permissions
// Query active presence records
// Filter by friend relationships
// Return filtered results
}
}@Service
public class PresenceAnalyticsService {
public PlaceAnalytics generatePlaceAnalytics(String placeId, Period period) {
// Aggregate presence data
// Calculate peak hours
// Generate foot traffic insights
// Anonymize user data
}
public UserBehaviorPattern analyzeUserBehavior(String userId) {
// Analyze movement patterns
// Identify favorite places
// Calculate visit frequencies
// Generate recommendations
}
}@Service
public class PrivacyControlService {
public boolean canUserSeePresence(String viewerId, String targetUserId, String placeId) {
// Check friend relationship
// Validate place-specific permissions
// Apply privacy circle rules
// Return visibility decision
}
}- Dwell Time Analysis: Distinguish between passing by and actually visiting
- Movement Validation: Confirm genuine presence vs. GPS errors
- Battery-Optimized Updates: Reduce tracking frequency based on user activity
- Offline Mode Support: Handle periods when users are offline
- Friend Recommendation: Suggest new friends based on common places
- Activity Matching: Connect users with similar interests at the same places
- Group Formation: Identify natural friend groups based on presence patterns
- Event Detection: Automatically detect gatherings and social events
- Foot Traffic Analytics: Provide businesses with valuable insights
- Peak Hour Identification: Help businesses optimize staffing
- Customer Journey Mapping: Track how users move between places
- Competitive Intelligence: Anonymous comparison with similar businesses
- Intelligent Caching: Redis caching for frequently accessed presence data
- Database Partitioning: Time-based partitioning for efficient queries
- Batch Processing: Group similar operations for better performance
- Connection Pooling: Optimized database connections
- Concurrent Tracking: 100K+ simultaneous active users
- Query Performance: <100ms response time for friend queries
- Data Throughput: 50K+ presence events per second
- Storage Efficiency: Optimized data structures for long-term storage
@EventListener
public void handleGeofenceEvent(GeofenceEvent event) {
PresenceEvent presenceEvent = convertToPresenceEvent(event);
recordPresenceEvent(presenceEvent);
if (event.getType() == EventType.ENTRY) {
notifyNearbyFriends(event.getUserId(), event.getPlaceId());
}
}@Autowired
private UserServiceClient userServiceClient;
@Autowired
private GeofencingServiceClient geofencingServiceClient;
@Autowired
private NotificationServiceClient notificationServiceClient;- Active Users: Number of users currently being tracked
- Presence Events: Entry/exit events per minute
- Friend Queries: Social discovery requests per hour
- Privacy Actions: Privacy setting changes and visibility updates
GET /actuator/health
GET /actuator/metrics/tracker.active.users
GET /actuator/metrics/tracker.presence.events- Real-time Presence Map: Visual representation of active users
- Social Activity Feed: Recent friend discoveries and interactions
- Place Popularity Trends: Most visited places over time
- User Engagement Metrics: How users interact with tracking features
src/
βββ main/java/com/placelive/tracker/
β βββ controller/ # REST API endpoints
β βββ service/ # Business logic layer
β βββ repository/ # Data access layer
β βββ model/ # Entity definitions
β βββ dto/ # Data transfer objects
β βββ event/ # Event handling
β βββ config/ # Configuration classes
β βββ util/ # Utility classes
βββ main/resources/
β βββ application.yml # Configuration
β βββ db/migration/ # Database scripts
βββ test/ # Unit and integration tests
CREATE TABLE presence_events (
id BIGSERIAL PRIMARY KEY,
user_id VARCHAR(255) NOT NULL,
place_id VARCHAR(255) NOT NULL,
geofence_id VARCHAR(255) NOT NULL,
event_type VARCHAR(50) NOT NULL,
timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
latitude DECIMAL(10,8),
longitude DECIMAL(11,8),
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_presence_user_time ON presence_events(user_id, timestamp);
CREATE INDEX idx_presence_place_time ON presence_events(place_id, timestamp);
CREATE INDEX idx_presence_geofence_active ON presence_events(geofence_id, event_type, timestamp);We welcome contributions to PlaceLive-Tracker! Please follow our development guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/presence-analytics - Write comprehensive tests
- Follow our coding standards
- Submit a pull request
- Unit Tests: Test individual service methods
- Integration Tests: Test API endpoints and database interactions
- Performance Tests: Validate response times and throughput
- Privacy Tests: Ensure privacy controls work correctly
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: jlss.virtual.0808@gmail.com
PlaceLive-Tracker: Empowering social connections through intelligent presence tracking and privacy-first social discovery. ππ₯