Services Overview
The service layer contains the business logic of the application. Services orchestrate repositories, handle business rules, and integrate with external APIs.
Core Services
User Service (user_service.go)
Manages user-related business logic:
- User profile management
- Social media integration
- User connections
- Profile enrichment
- User recommendations
Key Methods:
GetUserByID()- Get user by IDGetUserByTelegramID()- Get user by Telegram IDUpdateUserSocials()- Update social media usernamesGetRecommendedUsers()- Get user recommendationsEnrichUserProfile()- Enrich user profile with social data
Event Service (event_service.go)
Handles event management:
- Event CRUD operations
- Event filtering and search
- Event status management
- Event approval workflow
Key Methods:
CreateEvent()- Create a new eventUpdateEvent()- Update event detailsGetEventBySlug()- Get event by slugListEvents()- List events with filtersGetEventWithAttendees()- Get event with attendee list
Event Attendee Service (event_attendee_service.go)
Manages event attendance:
- Registration for events
- Attendance tracking
- Waitlist management
Key Methods:
RegisterForEvent()- Register user for eventCancelAttendance()- Cancel event attendanceCheckAttendance()- Check if user is attendingGetEventAttendees()- Get list of attendees
Quest Service (quest_service.go)
Handles quest system logic:
- Quest creation and management
- Task completion tracking
- Progress calculation
- Leaderboard generation
- Quest registration approval
Key Methods:
CreateQuest()- Create a new questStartQuest()- User starts a questCompleteTask()- Complete a quest taskGetUserProgress()- Get user's quest progressGetLeaderboard()- Get quest leaderboardApproveTask()- Admin approves task completionRejectTask()- Admin rejects task completion
Notification Service (notification_service.go)
Manages user notifications:
- Creating notifications
- Sending notifications
- Notification status tracking
Key Methods:
CreateNotification()- Create a notificationGetUserNotifications()- Get user's notificationsMarkAsClicked()- Mark notification as clickedMarkAsDismissed()- Mark notification as dismissed
Notification Job Service (notification_job_service.go)
Handles bulk and scheduled notifications:
- Bulk notification sending
- Scheduled notifications
- Job status tracking
- Background worker processing
Key Methods:
CreateNotificationJob()- Create a notification jobSendBulkNotification()- Send bulk notificationsStartWorker()- Start background workerProcessNotificationJob()- Process a notification job
Conference Service (conference_service.go)
Manages conferences:
- Conference CRUD operations
- Conference-event relationships
- Conference agenda management
Key Methods:
CreateConference()- Create a conferenceGetConferenceBySlug()- Get conference by slugGetConferenceWithEvents()- Get conference with eventsUpdateConference()- Update conference details
Conference Attendee Service (conference_attendee_service.go)
Handles conference attendance:
- Conference registration
- Attendee management
- Bulk attendee import
Key Methods:
RegisterForConference()- Register for conferenceCancelRegistration()- Cancel registrationListConferenceAttendees()- List attendeesBulkUploadAttendees()- Bulk import attendees
Conference Agenda Service (conference_agenda_service.go)
Manages conference agenda:
- Agenda item CRUD
- Agenda organization
- Time slot management
Key Methods:
CreateAgendaItem()- Create agenda itemGetAgendaByConferenceID()- Get agenda for conferenceUpdateAgendaItem()- Update agenda item
Speaker Service (speaker_service.go)
Manages speakers:
- Speaker CRUD operations
- Speaker enrichment
- Speaker-conference mapping
Key Methods:
CreateSpeaker()- Create a speakerGetSpeakerByID()- Get speaker by IDEnrichSpeaker()- Enrich speaker with social dataGetConferenceSpeakers()- Get speakers for conference
Enrichment Service (enrichment_service.go)
Handles social media enrichment:
- Twitter enrichment
- LinkedIn enrichment
- Crypto enrichment
- AI-powered profile analysis
Key Methods:
GenerateEnrichment()- Generate enrichment for userGenerateEnrichmentSync()- Synchronous enrichmentGenerateMultipleEnrichments()- Bulk enrichment
Verification Service (verification_service.go)
Handles task verification:
- Twitter task verification
- Social media proof verification
- Automated verification logic
Key Methods:
VerifyTwitterTask()- Verify Twitter task completionVerifyTask()- Generic task verification
Telegram Service (telegram_service.go)
Integrates with Telegram:
- Sending messages
- User authentication
- Group chat integration
Key Methods:
SendMessage()- Send Telegram messageSendToGroup()- Send message to groupVerifyTelegramAuth()- Verify Telegram authentication
Quest Reminder Service (quest_reminder_service.go)
Manages quest reminders:
- Reminder template management
- Scheduled reminder sending
- Quest progress tracking
Key Methods:
CreateReminderTemplate()- Create reminder templateSendReminder()- Send quest reminderGetTemplates()- Get reminder templates
External Integration Services
Twitter Service (twitter_service.go)
Integrates with Twitter/Apify:
- Fetching Twitter profiles
- Fetching tweets
- Twitter data enrichment
LinkedIn Service (linkedin_service.go)
Integrates with LinkedIn:
- Fetching LinkedIn profiles
- Profile data extraction
Azure Storage Service (azure_storage_service.go)
Handles Azure Blob Storage:
- Image uploads
- Video uploads
- File management
Cloudflare R2 Service (cloudflare_r2_service.go)
Handles Cloudflare R2 storage:
- Image uploads
- Video uploads
- CDN integration
JWT Service (jwt_service.go)
Handles JWT tokens:
- Token generation
- Token validation
- Token refresh
Service Patterns
Dependency Injection
Services receive dependencies through constructors:
func NewUserService(
userRepo repositories.UserRepository,
connectionRepo *repositories.ConnectionRepository,
// ... other dependencies
) *UserService {
return &UserService{
userRepo: userRepo,
connectionRepo: connectionRepo,
// ...
}
}Error Handling
Services return domain-specific errors:
if err != nil {
return nil, fmt.Errorf("failed to create user: %w", err)
}Transaction Management
Services handle database transactions when needed:
tx := s.db.Begin()
// ... operations
tx.Commit()Service Responsibilities
- Business Logic: Implement business rules and validations
- Orchestration: Coordinate multiple repositories
- External Integration: Communicate with external APIs
- Data Transformation: Transform data between layers
- Error Handling: Handle and transform errors appropriately