Appearance
Backend Architecture
The backend of the Coastal Element AI SDR project is a monorepo built with pnpm workspaces and Turbo. It consists of multiple microservices and shared packages.
Architecture Diagram
Request Flow
- Client Request: A request is initiated from the client-side application.
- API Gateway: All incoming requests are first received by the API Gateway. The gateway is responsible for routing the request to the appropriate microservice based on the request path.
- Microservice Processing: The request is then handled by one of the following microservices:
- Auth Service: Handles user authentication, authorization, and session management.
- Brand Service: Manages brand-related data.
- Campaign Service: Manages campaign-related data.
- Worker Service: Processes background jobs for campaigns (EMAIL, SMS, VOICEMAIL) using Redis queues.
- Shared Packages: Each microservice utilizes the shared packages to perform its tasks:
- Database: The service connects to the database using the Prisma client from the
dbpackage. - Shared Auth Logic: The service uses the
authpackage for shared authentication utilities. - Shared Utilities: The service uses the
sharedpackage for common utilities like logging.
- Database: The service connects to the database using the Prisma client from the
- Response: The microservice sends a response back to the API Gateway, which then forwards it to the client.
Microservices
The apps directory contains the following microservices:
- Gateway: The API gateway that acts as the single entry point for all client requests.
- Auth Service: Handles user authentication and authorization.
- Brand Service: Manages brand data and logic.
- Campaign Service: Manages campaign data and logic.
- Worker Service: Background job processing service for campaign execution with real-time monitoring.
Shared Packages
The packages directory contains the following shared packages:
- Database: Contains the Prisma schema, database client, and database-related utilities.
- Auth Package: Shared authentication utilities, permissions, and roles.
- Shared: Shared utilities for logging, middleware, types, etc.