Slack Events Breakdown
Overview
This system is designed to manage calendar events extracted from Slack messages. It processes incoming messages, extracts relevant event details, stores them in a database, and provides RESTful API endpoints for event management. The system is built using Java with Spring Boot and integrates with Slack for automated event parsing and notifications.
Components
1. Entity: CalendarEvent
- Represents an event in the system.
- Fields
- id: Unique identifier for the event.
- date: Date of the event.
- title: Title of the event.
- description: Additional details about the event.
- type: Classification of the event (e.g., general, check-in, grade).
- period: Period during which the event occurs.
- Uses JPA annotations for ORM mapping. 2. Repository: CalendarEventRepository
- Extends JpaRepository to interact with the database.
- Provides methods for querying events:
- findByDate(LocalDate date): Fetch events by a specific date.
- findByDateBetween(LocalDate startDate, LocalDate endDate): Fetch events within a date range.
- findByType(String type): Fetch events by type.
- findByTitle(String title): Fetch event by title. 3. Service: CalendarEventService
- Business logic layer handling event management.
- Methods include:
- saveEvent(CalendarEvent event): Saves an event to the database.
- getEventsByDate(LocalDate date): Retrieves events for a specific date.
- updateEventByTitle(String title, String newTitle, String description): Updates an event’s title and description.
- deleteEventByTitle(String title): Deletes an event by title.
- getEventsWithinDateRange(LocalDate startDate, LocalDate endDate): Fetches events within a given range.
- parseSlackMessage(Map<String, String> jsonMap, LocalDate weekStartDate): Parses Slack messages and creates corresponding events.
- extractEventsFromText(String text, LocalDate weekStartDate): Uses regex to extract event details from Slack messages. 4. Controller: CalendarEventController
- Exposes REST API endpoints for managing calendar events.
- Endpoints:
- POST /api/calendar/add: Parses Slack messages and creates events.
- POST /api/calendar/add_event: Adds an event manually.
- GET /api/calendar/events/{date}: Retrieves events for a given date.
- DELETE /api/calendar/delete/{title}: Deletes an event by title.
- PUT /api/calendar/edit/{title}: Updates an event’s title and description.
- GET /api/calendar/events: Fetches all events.
- GET /api/calendar/events/range?start=YYYY-MM-DD&end=YYYY-MM-DD: Fetches events within a date range.
- GET /api/calendar/events/next-day: Retrieves events for the next day.
Workflow
- Event Creation:
- Slack messages are sent to the /api/calendar/add endpoint.
- The CalendarEventService extracts and saves events.
- Events can also be manually added via /api/calendar/add_event. - Event Retrieval:
- Users can fetch events by date, type, or within a date range. - Event Modification:
- Events can be updated or deleted using respective endpoints. Slack Integration:
- Events parsed from Slack messages are stored in the system.
- Event updates trigger Slack notifications.
Technologies Used
- Spring Boot: Backend framework.
- Spring Data JPA: Database interaction.
- Hibernate: ORM for database handling.
- Slack API: Integration for parsing and notifying about events.
- REST API: Exposes endpoints for event management.
Future Enhancements
- Implement authentication and authorization.
- Improve natural language processing for better Slack message parsing.
- Add event recurrence support.
- Enhance the UI for event management.