Leadsmart
  1. Docs
Leadsmart
  • API Reference
  • Docs
    • LeadSmart API Documentation
    • Services
    • Middleware
    • Integrations
    • Database
    • Architecture
  • Authentication
    • Register
      POST
    • Update User
      PATCH
    • Login
      POST
    • Logout
      POST
    • Reset Password
      POST
    • Change Email
      POST
    • Request Password Reset
      POST
    • Request Email Change
      POST
    • Verify Email
      GET
  • Companies
    • Create Company
      POST
    • Join Company
      POST
    • Get All User Company
      GET
    • Get user Company
      GET
    • Update Company
      PATCH
    • Deactivate Company
      PATCH
    • Activate Company
      PATCH
    • Reset Invite Code
      PATCH
  • Members
    • Create a Member
      POST
    • Get All Member
      GET
    • Get Single Member
      GET
    • Update Member
      PATCH
    • Deactivate Member
      PATCH
    • Activate Member
      PATCH
  • Agendas
    • Create Company Agenda
    • Get All Agendas
    • Get Single Agenda
    • Get Agenda with Appoint
    • Get Available Slots
    • Update Agenda
    • Delete Agenda
    • Activate Agenda
    • Create Agenda Integration
    • Delete Agenda Integration
  • Appointments
    • Create Appointment
    • Get All Appointments
    • Get Appointment
    • Add Members
    • Delete Members
    • Update Appointment
    • Update Date
  • Plans
    • Get Single Plan
    • Get All Plans
    • Create Plan
    • Delete Plan
    • Update Plan
  • Plans Duration
    • Get Single Plan Duration
    • Create Plan Duration
    • Delete Plan Duration
    • Update Plan Duration
  • Company Roles
    • Get Single Company Role
    • Get All Company Roles
    • Create Company Role
    • Delete Company Role
    • Update Company Role
  • Clients
    • Get All Clients
    • Create Client
    • Get Client By Id
    • Update Client
    • Delete Client
  • Client Threads
    • Get All By Client
    • Get All By Instance
    • Create Client Thread
    • Get Client By Id
    • Update Client
    • Delete Client Thread
  • Admin
    • Get All Plans Duration
    • Get All Plans
    • Create Plan
    • Get All Members
    • Get All Companies
  • Chatwoot Accounts
    • Get Chatwoot Account
    • Update Chatwoot Account
    • Delete Chatwoot Account
    • Create Chatwoot Account
  • Integrations
    • Tokens
      • Fetch All Tokens
      • Fetch Token
      • Update Token
      • Remove Token
    • Google
      • Create Auth URL
      • Regenerate Auth URL
      • Renew Google Webhook
    • External Calendar
      • Create External Event
      • Update External Event
      • Delete External Event
      • Validate Calendar Id
      • Fetch External Calendars
  • Messaging
    • Instances
      • Create Instance
      • Get All Instance
      • Get Instance
      • Update Instance
      • Connect Instance
      • Disconnect Instance
      • Activate Instance
      • Deactivate Instance
    • Message
      • Send Message
  • AI Keys
    • Get All AI Keys
    • Get AI Keys By ID
    • Create AI Key
    • Update AI Key
    • Delete AI Key
  • Agent Prompts
    • Get All Agent Prompts
    • Get Agent Prompt By ID
    • Create Agent Prompt
    • Update Agent Prompt
    • Delete Agent Prompt
  • Agent Configuration
    • Get All Agent Configurations
    • Get Agent Configuration By ID
    • Create Agent Configuration
    • Update Agent Configuration
    • Delete Configuration Prompt
  • Agent Prompt Versions
    • Get All Agent Prompt Versions
    • Get Agent Prompt Version By ID
    • Create Agent Prompt Version
    • Update Agent Prompt Version
    • Delete Agent Prompt Version
  1. Docs

Services

The LeadSmart API implements a service-layer architecture where business logic is encapsulated in service modules. This document outlines the key services and their responsibilities.

Core Services#

Authentication Service#

Handles user authentication, token management, and security-related operations.
Key functionalities:
User login and token generation
Token validation and refresh
Password reset and recovery
User registration and activation
Implementation files:
src/services/auth.service.ts

User Service#

Manages user accounts and profiles.
Key functionalities:
User CRUD operations
User profile management
User role assignment
Password management
Implementation files:
src/services/user.service.ts

Company Service#

Manages company information and settings.
Key functionalities:
Company CRUD operations
Company settings management
Member management within companies
Company subscription management
Implementation files:
src/services/company.service.ts

Member Service#

Manages user memberships within companies.
Key functionalities:
Member CRUD operations
Role assignment within companies
Member invitations and onboarding
Member permissions management
Implementation files:
src/services/member.service.ts

Client Management#

Client Service#

Manages client information and interactions.
Key functionalities:
Client CRUD operations
Client data management
Client categorization and tagging
Client history tracking
Implementation files:
src/services/client.service.ts

Thread Service#

Manages conversation threads with clients.
Key functionalities:
Thread CRUD operations
Message history management
Thread status tracking
Unread message counting
Implementation files:
src/services/clientThread.service.ts

Appointment Management#

Agenda Service#

Manages appointment calendars and availability.
Key functionalities:
Agenda CRUD operations
Availability management
Calendar synchronization
Agenda sharing and permissions
Implementation files:
src/services/agenda.service.ts

Appointment Service#

Manages scheduled appointments and meetings.
Key functionalities:
Appointment CRUD operations
Appointment scheduling and rescheduling
Appointment reminders and notifications
Appointment status management
Implementation files:
src/services/appointment.service.ts

Messaging Services#

Messaging Service#

Manages WhatsApp messaging instances and message sending.
Key functionalities:
WhatsApp connection management
Message sending and receiving
QR code generation for WhatsApp Web
Connection status monitoring
Implementation files:
src/messaging/whatsapp.service.ts

Integration Services#

Google Calendar Integration#

Manages integration with Google Calendar for appointment synchronization.
Key functionalities:
Google Calendar authentication
Calendar event synchronization
Webhook registration and handling
Event creation and updates
Implementation files:
src/integrations/google/calendar.service.ts

OpenAI Integration#

Manages integration with OpenAI for AI-powered conversations.
Key functionalities:
OpenAI API authentication
Model selection and configuration
Prompt management
Response handling
Implementation files:
src/services/openai.service.ts
src/services/openaiBot.service.ts

Chatwoot Integration#

Manages integration with Chatwoot for customer support.
Key functionalities:
Chatwoot API authentication
Conversation synchronization
Agent assignment
Status tracking
Implementation files:
src/services/chatwootAccount.service.ts

Subscription and Billing#

Plan Service#

Manages subscription plans and features.
Key functionalities:
Plan CRUD operations
Feature management
Price configuration
Plan comparison
Implementation files:
src/services/plan.service.ts
src/services/planDuration.service.ts

Utility Services#

Vector Service#

Manages vector embeddings for AI applications.
Key functionalities:
Vector creation and storage
Vector search and retrieval
Vector indexing
Similarity calculations
Implementation files:
src/services/vector.service.ts

Service Architecture#

Services in LeadSmart API follow these design principles:
1.
Separation of Concerns: Each service is responsible for a specific domain area
2.
Dependency Injection: Services receive dependencies through constructor injection
3.
Error Handling: Services use custom exception classes for error cases
4.
Validation: Input validation is performed using Zod schemas
5.
Transactions: Database operations use transactions for data integrity
Services typically follow this pattern:
Services are used by controllers to handle business logic, keeping controllers focused on request/response handling rather than implementation details.
Modificado em 2025-04-24 22:31:56
Página anterior
LeadSmart API Documentation
Próxima página
Middleware
Built with