terminal Technical Reference

Technical Documentation

Architecture, data flows, data models, geospatial zones, and search engine for the MaxLeadsNow platform.

01 Overview

MaxLeadsNow is a B2B territorial intelligence platform that combines real-time business search with geospatial analysis. Designed for sales teams that need systematic territorial reconnaissance.

Main flow
Search Map visualization Zone drawing Analysis Lead conversion Export

The platform allows sales representatives and managers to identify business opportunities in any geographic area, analyze the density and quality of existing businesses, and convert that data into actionable leads for their sales pipeline.

02 Architecture

The system is built on a modern web application architecture with hybrid rendering (server and client).

code Frontend
  • Progressive web application (Next.js + React 19)
  • Strict TypeScript
  • 35+ UI components (native dark-mode)
  • Interactive map renderer
dns Backend
  • PostgreSQL database with modern ORM
  • JWT authentication with HTTP-only cookies
  • Search engine (index of millions of businesses)
  • Server-side geospatial processing
Architecture Diagram
Browser (React 19 + Maps)
App Server (Next.js API Routes)
Search Engine
PostgreSQL DB
Maps Renderer

Geospatial processing includes geodesic area calculation, point-in-polygon detection, and real-time density metric generation.

03 Search Engine

The business search engine allows querying an up-to-date index with millions of registered establishments. The advanced search accepts the following parameters:

Parameter Type Description
keyword string Business type + search terms
location string City or metropolitan area
language string Language code (default: es)
device string Device type for contextual results

Response structure

Each result from the engine returns the following fields:

{
  "title":        "Farmacia San Pablo Reforma",
  "address":      "Av. Paseo de la Reforma 222, Juarez, CDMX",
  "phone":        "+52 55 1234 5678",
  "website":      "https://ejemplo.com",
  "rating":       4.6,
  "reviewsCount": 312,
  "category":     "Farmacia",
  "latitude":     19.4326,
  "longitude":    -99.1332
}

Preconfigured categories

Pharmacy Dentist Pediatrician General Practitioner Endocrinologist Psychiatrist Infectologist

The system is extensible to any business category available in the index.

04 Tactical Zones

Tactical zones are geographic regions defined by the user through polygon drawing tools on the map. Each zone is stored as a GeoJSON Polygon.

Zone data

Field Description
geometry Array of lat/lng coordinates defining the polygon
name Name assigned by the user
color Hexadecimal color for map visualization
assignedRep Assigned representative (optional)

Metrics calculated per zone

Geography
  • Area: km2 calculated with geodesic algorithm
  • Density: businesses/km2
Quality
  • Average rating: weighted average
  • Contactability: % phone, % web, % email
Rating Distribution
  • Excellent: rating ≥ 4.5
  • Good: 4.0 – 4.4
  • Average: 3.0 – 3.9
  • Low: < 3.0
  • No rating
Operations
  • Top 5 businesses: ranking by composite score
  • Workload: workday estimation

Composite score

The ranking of the best businesses per zone uses the formula:

score = rating * log10(reviewsCount + 1)

This calculation balances the business rating with its review volume, preventing businesses with few reviews but a perfect rating from dominating the ranking.

Workload estimation

time_per_visit     = 20 min (constant)
travel_time        = adjusted by density (min: 5 min, max: 20 min)
workday            = 6 effective hours
visits_per_day     = workday / (time_per_visit + travel_time)

05 Leads Pipeline

Each identified business can become a lead within the pipeline. Leads progress through defined states:

Pipeline States
New Under review Approved Exported
Rejected

Lead data

Each lead stores: source, business type, contact data (name, phone, email, website, social media), full address, GPS coordinates, rating, operator notes, and creation and update timestamps.

Lead sources

Direct search Web scraping Social media scraping Manual entry

Business types

Pharmacy Dentist Pediatrician General Practitioner Endocrinologist Psychiatrist Infectologist Other

06 CSV Import

The system allows bulk importing leads from CSV files. The process is fully automated with intelligent deduplication.

Import process

1
Upload CSV file
Supported optional columns:
name businessName phone email address city state website socialUrl leadType
2
Automatic deduplication
Duplicates are detected by two criteria:
duplicate = (businessName + city) matches
         OR (phone) matches
3
Normalization
The business type is automatically normalized to the system categories.
4
Import record
A record is generated with metrics: total rows processed, new leads created, and duplicates detected.
5
Leads created
New leads are created with the source marked as csv_import.

07 Data Model

The system operates with 4 main entities stored in PostgreSQL:

person User
Usuario {
  id          String    @id
  email       String    @unique
  nombre      String
  activo      Boolean   @default(true)
  createdAt   DateTime
}
saved_search Saved Search
BusquedaGuardada {
  id              String    @id
  usuarioId       String
  nombre          String
  keyword         String
  resultados      JSON      // array of businesses found
  zonas           JSON      // GeoJSON with drawn polygons
  totalResultados Int
  createdAt       DateTime
}
contact_page Lead
Lead {
  id              String    @id
  usuarioId       String
  fuente          String    // search, scraping_web, scraping_social, manual, csv_import
  estado          String    // nuevo, en_revision, aprobado, rechazado, exportado
  tipo            String    // farmacia, odontologo, pediatra, etc.
  nombre          String?
  negocio         String?
  direccion       String?
  ciudad          String?
  estado_geo      String?
  telefono        String?
  email           String?
  web             String?
  redesSociales   String?
  valoracion      Float?
  latitud         Float?
  longitud        Float?
  notas           String?
  createdAt       DateTime
  updatedAt       DateTime
}
upload_file Import
Importacion {
  id              String    @id
  usuarioId       String
  fuente          String
  archivo         String
  total           Int
  nuevos          Int
  duplicados      Int
  createdAt       DateTime
}

08 Security

System security is implemented in multiple layers:

lock Authentication
  • JWT signed with HS256 algorithm
  • HTTP-only cookies (not accessible from JavaScript)
  • Session expiration: 30 days
shield Route protection
  • Authentication middleware on all protected routes
  • Data isolation per user (every query filters by userId)
https Transport
  • Mandatory HTTPS in production
  • No sensitive data storage on client
database Database
  • Encrypted connections (SSL/TLS)
  • Credentials managed via environment variables

Ready to get started?

Access the dashboard and start searching for businesses in your target zone.

Go to Dashboard arrow_forward