# kothakula-sagar/abra-logistics-crm architecture

> Architecture diagram of the GitHub repository kothakula-sagar/abra-logistics-crm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kothakula-sagar/abra-logistics-crm
- Repository: https://github.com/kothakula-sagar/abra-logistics-crm

## Overview

Abra Logistics CRM is a browser-based, role-aware logistics sales and marketing application backed by Firebase, with an Express server for protected APIs and external delivery integrations. A CRM user initiates the principal workflow by signing in through the browser, then uses the application to manage leads, customers, staff workflows, campaigns, and SEO content. For email campaigns, the user selects a provider and sends from the campaign; the documented providers are an authorized Gmail account and Gmail API with OAuth 2.0. The repository also contains SEO generation and performance-analysis features, but the sampled inputs do not establish their complete orchestration.

#### Components

##### Browser shell and identity
- **CRM browser entry** — `index.html`: Main login/application page; the sign-in and password-reset flows are implemented in the authentication module.
- **Role-based application shell** — `js/app.js`: Maintains current user and view state, builds navigation, switches views, and loads selected domain renderers.
- **Authentication and authorization** — `js/auth.js`: Signs users in and out through Firebase Authentication, checks their Firestore user profile, and handles password resets and authenticated access.
- **Shared Firebase client** — `js/firebase.js`: Initializes Firebase Authentication, Firestore, and Storage and exposes a shared client API used by browser modules.
- **Shared UI helpers** — `js/ui.js`: Provides DOM-facing helpers for toasts, loading indicators, modals, tabs, and sidebar behavior.

##### Sales operations and workforce
- **Lead pipeline and assignment** — `js/leads.js`: Implements the substantial lead-management surface; assignment and related logic are also present in the separate assignment module.
- **Assignment workflow** — `js/assignment.js`: Implements lead assignment behavior as a distinct domain module.
- **Customer management** — `js/customers.js`: Implements customer-facing CRM workflows.
- **Accounts and user administration** — `js/accounts.js`: Lets administrators review and update Firestore user records.
- **HR and staff operations** — `js/hr-transfers.js`: Implements HR transfer workflows; `js/leave.js` separately implements leave management.
- **Training management** — `js/training.js`: Implements training workflows; `js/training-admin.js` provides the administrative counterpart.
- **Operational audit and reporting** — `js/call-audit.js`: Implements call-audit workflows; `js/report.js` provides reporting, and `js/history.js` implements the SEO-generation history dashboard.

##### Marketing, content, and analysis
- **Campaign and product marketing** — `js/marketing.js`: Manages marketing products and campaigns, including campaign content and recipient tracking.
- **Marketing channels** — `js/marketing-channels.js`: Implements channel-specific marketing workflows.
- **Campaign analytics and reports** — `js/campaign-analytics.js`: Analyzes campaign performance; `js/campaign-reports.js` supplies campaign reporting.
- **SEO generation and AI** — `js/ai.js`: Implements AI-related functionality; the available excerpts do not establish its full call flow. SEO history and generated content are represented in the history module.
- **Performance analysis** — `js/performance-ai.js`: Turns PageSpeed Insights audit data into recommendations using configured Groq, Gemini, or OpenRouter APIs.
- **Application dashboards** — `js/dashboard.js`: Calculates dashboard statistics using product and marketing data; `js/super-dashboard.js` supplies a separate super-admin dashboard.

##### Server and external interfaces
- **Express API and integrations** — `server.js`: Runs the Express server and contains protected API routes and server-side integration logic, including Telegram-related operations and email endpoints documented by the README.
- **CRM user** — *(external; no repository path)*: The human actor who signs in, navigates CRM views, and initiates campaign sends.
- **Firebase services** — *(external; no repository path)*: Provide browser authentication, Firestore persistence, and file storage; the server also imports Firebase Admin.
- **Email delivery providers** — *(external; no repository path)*: The README documents Email Marketing through an authorized Gmail account and Gmail API delivery through OAuth 2.0.
- **Google OAuth** — *(external; no repository path)*: Authorizes Gmail API access through the documented callback flow.
- **Telegram Bot API** — *(external; no repository path)*: The server code includes Telegram operations, but the sampled material does not establish the complete trigger path.

#### Relationships

- **CRM user -> CRM browser entry**: opens the CRM to sign in; evidence: `README.md` (documents opening the CRM to authorize Gmail; the login entry is indicated by `index.html`).
- **CRM browser entry -> Authentication and authorization**: provides the login surface; evidence: `index.html` (entry-to-script wiring was not sampled).
- **Authentication and authorization -> Shared Firebase client**: performs sign-in and reads the user profile; evidence: `js/auth.js` (excerpt).
- **Role-based application shell -> Shared Firebase client**: reads lead, assignment-queue, and leave data for application statistics; evidence: `js/app.js` (excerpt).
- **Role-based application shell -> Lead pipeline and assignment**: selects and loads domain views; evidence: `js/app.js` (excerpt shows view dispatch for leave and HR transfers; lead-view dispatch is not shown).
- **Lead pipeline and assignment -> Assignment workflow**: ownership relationship only; evidence: none (inferred).
- **Accounts and user administration -> Shared Firebase client**: reads and updates user documents; evidence: `js/accounts.js` (excerpt).
- **Application dashboards -> Campaign and product marketing**: loads product and meta-campaign data for dashboard calculations; evidence: `js/dashboard.js` (excerpt).
- **Campaign and product marketing -> Shared UI helpers**: displays feedback through toast helpers; evidence: `js/marketing.js` (excerpt).
- **CRM user -> Campaign and product marketing**: selects a campaign email provider and sends; evidence: `README.md`.
- **Campaign and product marketing -> Email delivery providers**: sends via the campaign’s selected provider; evidence: `README.md` (the specific frontend-to-endpoint call is not established).
- **Google OAuth -> Express API and integrations**: returns authorization to the documented Gmail callback endpoint; evidence: `README.md`.
- **Express API and integrations -> Firebase services**: accesses Firestore-backed user and delivery records; evidence: `server.js` (excerpt).
- **Express API and integrations -> Telegram Bot API**: performs Telegram API operations; evidence: `server.js` (excerpt).
- **Performance analysis -> Groq, Gemini, or OpenRouter**: sends analysis requests to the selected provider; evidence: `js/performance-ai.js` (excerpt).

#### Coverage limits

The source sample does not include HTML script wiring, most module implementations, or the server’s complete route definitions. Consequently, exact browser-to-server email call sites, view-to-module dispatch for many domains, and the trigger for server-side Telegram notifications could not be verified. Connections marked inferred or described only as documented should not be treated as confirmed runtime wiring.

Main entry points: [`js/marketing.js`](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/marketing.js) (Campaign and product marketing), [`server.js`](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/server.js) (Express API and integrations), [`js/firebase.js`](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/firebase.js) (Shared Firebase client), [`js/app.js`](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/app.js) (Role-based app shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser_identity["Browser and identity"]
  node_crm_browser["CRM browser entry<br/>Web entry"]
  node_app_shell["Role-based app shell<br/>Browser app"]
  node_auth["Authentication and authorization<br/>Auth module"]
  node_firebase_client["Shared Firebase client<br/>Client SDK"]
  node_ui_helpers["Shared UI helpers<br/>UI module"]
end

subgraph group_crm_operations["CRM operations"]
  node_leads["Lead pipeline<br/>CRM module"]
  node_assignment["Assignment workflow<br/>CRM module"]
  node_accounts["Accounts administration<br/>Admin module"]
end

subgraph group_marketing_analysis["Marketing and analysis"]
  node_dashboard["Application dashboards<br/>Dashboard module"]
  node_marketing["Campaign and product marketing<br/>Marketing module"]
  node_performance_ai["Performance analysis<br/>Analysis module"]
end

subgraph group_server_integrations["Server integrations"]
  node_express_api["Express API and integrations<br/>Server API"]
end

subgraph group_external_systems["External systems"]
  node_crm_user(("CRM user<br/>External actor"))
  node_firebase_services[("Firebase services<br/>Cloud services")]
  node_email_providers["Gmail delivery providers<br/>Email provider"]
  node_google_oauth["Google OAuth<br/>OAuth service"]
  node_telegram_api["Telegram Bot API<br/>Messaging API"]
  node_ai_providers["Groq, Gemini, OpenRouter<br/>AI providers"]
end

node_crm_user -->|"opens CRM"| node_crm_browser
node_crm_browser -->|"provides login"| node_auth
node_auth -->|"authenticates and reads profile"| node_firebase_client
node_app_shell -->|"reads application data"| node_firebase_client
node_app_shell -->|"loads domain views"| node_leads
node_leads -.->|"ownership"| node_assignment
node_accounts -->|"reads and updates users"| node_firebase_client
node_dashboard -->|"loads campaign data"| node_marketing
node_marketing -->|"shows feedback"| node_ui_helpers
node_crm_user -->|"selects and sends campaign"| node_marketing
node_marketing -->|"sends campaign email"| node_email_providers
node_google_oauth -->|"returns authorization"| node_express_api
node_express_api -->|"accesses records"| node_firebase_services
node_express_api -->|"performs API operations"| node_telegram_api
node_performance_ai -->|"sends analysis requests"| node_ai_providers

click node_crm_browser "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/index.html"
click node_app_shell "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/app.js"
click node_auth "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/auth.js"
click node_firebase_client "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/firebase.js"
click node_ui_helpers "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/ui.js"
click node_leads "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/leads.js"
click node_assignment "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/assignment.js"
click node_accounts "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/accounts.js"
click node_dashboard "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/dashboard.js"
click node_marketing "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/marketing.js"
click node_performance_ai "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/performance-ai.js"
click node_express_api "https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/server.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_crm_browser,node_app_shell,node_auth,node_firebase_client,node_ui_helpers toneBlue
class node_leads,node_assignment,node_accounts toneAmber
class node_dashboard,node_marketing,node_performance_ai toneMint
class node_express_api toneRose
class node_crm_user,node_firebase_services,node_email_providers,node_google_oauth,node_telegram_api,node_ai_providers toneIndigo
```

## Components

### Browser and identity

CRM entry, application shell, authentication, and shared browser services.

- [CRM browser entry](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/index.html): Web entry · `index.html`
- [Role-based app shell](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/app.js): Browser app · `js/app.js`
- [Authentication and authorization](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/auth.js): Auth module · `js/auth.js`
- [Shared Firebase client](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/firebase.js): Client SDK · `js/firebase.js`
- [Shared UI helpers](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/ui.js): UI module · `js/ui.js`

### CRM operations

Lead assignment and account administration.

- [Lead pipeline](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/leads.js): CRM module · `js/leads.js`
- [Assignment workflow](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/assignment.js): CRM module · `js/assignment.js`
- [Accounts administration](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/accounts.js): Admin module · `js/accounts.js`

### Marketing and analysis

Campaign workflows, dashboards, and performance analysis.

- [Application dashboards](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/dashboard.js): Dashboard module · `js/dashboard.js`
- [Campaign and product marketing](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/marketing.js): Marketing module · `js/marketing.js`
- [Performance analysis](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/js/performance-ai.js): Analysis module · `js/performance-ai.js`

### Server integrations

Protected APIs and server-side integrations.

- [Express API and integrations](https://github.com/kothakula-sagar/abra-logistics-crm/blob/main/server.js): Server API · `server.js`

### External systems

Human actors and third-party services.

- **CRM user**: External actor
- **Firebase services**: Cloud services
- **Gmail delivery providers**: Email provider · Authorized Gmail account and Gmail API delivery through OAuth 2.0.
- **Google OAuth**: OAuth service
- **Telegram Bot API**: Messaging API
- **Groq, Gemini, OpenRouter**: AI providers

## Connections

- CRM user → CRM browser entry: opens CRM (evidence: `README.md`)
- CRM browser entry → Authentication and authorization: provides login
- Authentication and authorization → Shared Firebase client: authenticates and reads profile (evidence: `js/auth.js`)
- Role-based app shell → Shared Firebase client: reads application data (evidence: `js/app.js`)
- Role-based app shell → Lead pipeline: loads domain views (evidence: `js/app.js`)
- Lead pipeline → Assignment workflow: ownership · Inferred; not shown in the code that was read.
- Accounts administration → Shared Firebase client: reads and updates users (evidence: `js/accounts.js`)
- Application dashboards → Campaign and product marketing: loads campaign data (evidence: `js/dashboard.js`)
- Campaign and product marketing → Shared UI helpers: shows feedback (evidence: `js/marketing.js`)
- CRM user → Campaign and product marketing: selects and sends campaign (evidence: `README.md`)
- Campaign and product marketing → Gmail delivery providers: sends campaign email · Provider delivery is documented; the specific frontend-to-endpoint call is not established. (evidence: `README.md`)
- Google OAuth → Express API and integrations: returns authorization (evidence: `README.md`)
- Express API and integrations → Firebase services: accesses records (evidence: `server.js`)
- Express API and integrations → Telegram Bot API: performs API operations (evidence: `server.js`)
- Performance analysis → Groq, Gemini, OpenRouter: sends analysis requests (evidence: `js/performance-ai.js`)
