Skip to content

VaraalakshimeV/AI-Powered-Competitor-Analysis-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎯 AI-Powered Competitor Analysis System

Market Intelligence Tool with LLM Integration

Python Flask AI Plotly Status

Developed at TVS Sensing Solutions | Internship Project


Note: This is a portfolio project showcasing work completed during my Data Science internship at TVS Sensing Solutions.


💡 The Business Problem

At TVS Sensing Solutions, the business development team needed a tool to quickly generate competitor analysis for market positioning and strategic planning. The challenge was to create a customizable system that could:

  • Generate competitor information based on specific product categories
  • Focus on TVS's sensor manufacturing portfolio
  • Provide structured, organized outputs for decision-making
  • Deliver results faster than manual web research

The Challenge: Build a tool that generates product-specific competitor intelligence with automated data generation and visualization.


✨ My Solution

I built an AI-powered web application using Flask and Ollama Mistral LLM that generates competitor profiles based on user-specified criteria.

What It Does:

Input: User specifies product type (e.g., pressure sensors), market focus (Indian/Global), and number of competitors
Process: Dynamic Query Construction → Ollama Mistral LLM → Data Processing → Ranking
Output: Structured competitor profiles with interactive dashboard + Excel export

Key Innovation:

Designed intelligent prompt engineering that transforms user inputs into structured queries for the Ollama Mistral model. Implemented data cleaning and a ranking algorithm that sorts generated competitor data by market share and turnover.


📊 Business Impact

Metric Before After Result
Analysis Tool Manual web research AI-powered generation Faster results
Query Customization Generic searches Product-specific prompts Targeted queries
Data Structure Unorganized notes Structured DataFrames Analysis-ready
Output Format Manual compilation Dashboard + Excel export Professional reports
Visualization Static notes 6+ Interactive charts Better insights

Real-World Results:

  • ✅ Built AI-powered system using Ollama Mistral LLM for competitor data generation
  • ✅ Created product-specific prompt engineering for TVS's sensor portfolio
  • ✅ Delivered interactive dashboard with 6+ Plotly visualizations
  • ✅ Generated structured Excel reports for business presentations

🏗️ System Architecture

High-Level Architecture

System Architecture

Architecture Overview:

┌─────────────────────────────────────────────────────────────────┐
│                        USER INTERFACE                           │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐           │
│  │  Home Page   │  │ Input Form   │  │  Dashboard   │           │
│  └──────────────┘  └──────────────┘  └──────────────┘           │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                   FLASK WEB APPLICATION                         │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐           │
│  │   Routes     │  │ Form Handler │  │ Template     │           │
│  │   (/index)   │  │   Validator  │  │  Renderer    │           │
│  └──────────────┘  └──────────────┘  └──────────────┘           │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                  PROMPT CONSTRUCTION MODULE                     │
│                                                                 │
│   Input: Product Type, Market, Sub-segment, Technology          │
│   Process: Combine → Format → Structure                         │
│   Output: "pressure sensors in automotive using MEMS"           │
│                                                                 │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│               DYNAMIC QUERY CONSTRUCTION                        │
│                                                                 │
│   Context: "I am an industrial expert in automotive..."         │
│   Query: "List top 10 Indian companies manufacturing..."        │
│   Format: JSON with 12 fields (Company, HQ, Market Share...)    │
│                                                                 │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                    OLLAMA MISTRAL LLM                           │
│                                                                 │
│   Model: mistral                                                │
│   Input: Structured prompt with context                         │
│   Output: JSON array of competitor objects                      │
│                                                                 │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│               DATA PROCESSING PIPELINE                          │
│                                                                 │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐           │
│  │ JSON Parser  │→ │Data Cleaning │→ │Normalization │           │
│  └──────────────┘  └──────────────┘  └──────────────┘           │
│                                                                 │
│  • Remove markdown ```json``` tags                              │
│  • Convert "5%" → 5.0                                           │
│  • Convert "5 Billion USD" → 5000000000                         │
│  • Extract "500-1000 employees" → 750                           │
│                                                                 │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                   RANKING ALGORITHM                             │
│                                                                 │
│   1. Sort by Market Share (descending)                          │
│   2. Then by Turnover (descending)                              │
│   3. Select Top N competitors                                   │
│                                                                 │
└────────────────────────────┬────────────────────────────────────┘
                             │
                             ▼
┌─────────────────────────────────────────────────────────────────┐
│                    OUTPUT GENERATION                            │
│                                                                 │
│  ┌──────────────────┐              ┌──────────────────┐         │
│  │  VISUALIZATIONS  │              │  EXCEL EXPORT    │         │
│  ├──────────────────┤              ├──────────────────┤         │
│  │ • Pie Chart      │              │ • XlsxWriter     │         │
│  │ • Bar Charts (3) │              │ • Formatted      │         │
│  │ • Scatter Plot   │              │ • All 12 fields  │         │
│  │ • Histogram      │              │ • Download ready │         │
│  └──────────────────┘              └──────────────────┘         │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Five-Layer Architecture:

Layer 1: User Input - Web form capturing product and market specifications
Layer 2: Flask Application - Backend processing and routing
Layer 3: AI Engine - Ollama Mistral for competitor data generation
Layer 4: Data Pipeline - Cleaning, structuring, and ranking
Layer 5: Visualization - Interactive Plotly dashboards and Excel export


🔄 System Workflow

Use Case Diagram

                    ┌──────────────────────────┐
                    │         USER             │
                    └───────────┬──────────────┘
                                │
                ┌───────────────┼───────────────┐
                │               │               │
                ▼               ▼               ▼
    ┌──────────────────┐  ┌─────────────┐  ┌─────────────┐
    │ Input Product    │  │View         │  │Export Excel │
    │ Specifications   │  │Dashboard    │  │Report       │
    └──────────────────┘  └─────────────┘  └─────────────┘
                │
                ▼
    ┌──────────────────────┐
    │ Generate Competitor  │
    │ Analysis             │
    └──────────────────────┘
                │
                ▼
    ┌──────────────────────┐
    │ Ask Custom Questions │
    │ (Chatbot)            │
    └──────────────────────┘

Complete system capabilities showing user interactions


Detailed Data Flow Diagram

                    ┌──────────┐
                    │   USER   │
                    └─────┬────┘
                          │
                          ▼
                 ┌────────────────┐
                 │  Input Form    │
                 │ • Product Type │
                 │ • Market       │
                 │ • Count        │
                 └────────┬───────┘
                          │
                          ▼
                 ┌────────────────┐
                 │ Build Prompt   │
                 │ Construction   │
                 └────────┬───────┘
                          │
                          ▼
                 ┌────────────────┐
                 │ Ollama Mistral │
                 │      LLM       │
                 └────────┬───────┘
                          │
                          ▼
                 ┌────────────────┐
                 │  Parse JSON    │
                 │   Response     │
                 └────────┬───────┘
                          │
                          ▼
                 ┌────────────────┐
                 │ Clean & Norm.  │
                 │     Data       │
                 └────────┬───────┘
                          │
                          ▼
                 ┌────────────────┐
                 │ Rank by Market │
                 │ Share/Turnover │
                 └────────┬───────┘
                          │
                ┌─────────┴─────────┐
                ▼                   ▼
         ┌─────────────┐     ┌─────────────┐
         │   Plotly    │     │   Excel     │
         │  Dashboard  │     │   Export    │
         └──────┬──────┘     └──────┬──────┘
                │                   │
                └─────────┬─────────┘
                          │
                          ▼
                    ┌──────────┐
                    │   USER   │
                    └──────────┘

End-to-end processing pipeline from input to output


🎬 Application Showcase

Home Page

Home Page

Landing page with navigation to analysis modules




Input Form - Product Selection

Input Form 1

User specifies market type, product segment, and competitor filters




Input Form - Technology Details

Input Form 2

Additional filters for sub-segment and technology specifications




Toggle Switch & Pressure Sensor Excel Download

Toggle Switch Excel Download

Indian/Global market toggle and instant Excel download functionality




Analytics Dashboard Overview

Dashboard

Interactive dashboard with multiple visualization types




Market Share Distribution

Market Share Pie

Pie chart showing competitive landscape distribution




Market Share Comparison

Market Share Bar

Bar chart comparing competitor market positions




Employee Count Analysis

Employee Count

Organizational scale comparison across competitors




Efficiency Matrix (Market Share vs Employees)

Efficiency Matrix

Scatter plot identifying company size and market position




AI Research Assistant (ComPIBOT)

Chatbot

Conversational interface for ad-hoc queries




Excel Export Sample

Excel Export

Structured data export for reports




⚙️ Technical Architecture

Core Components I Built:

1. User Input Processing Module

  • Flask form handling for product specifications
  • Market type selection (Indian/Global)
  • Competitor count configuration
  • Dynamic field validation

2. Prompt Construction Engine

  • Product description builder
  • Sub-segment combination logic
  • Technology specification integration
  • Structured query formation

3. AI Integration Layer

  • Ollama Mistral LLM integration
  • Context-aware prompt engineering
  • JSON response parsing
  • Error handling for invalid responses

4. Data Processing Pipeline

  • Market share normalization (%, Billion, Million, USD)
  • Turnover standardization across currencies
  • Employee range extraction (e.g., "500-1000" → 750)
  • Data type conversion and cleaning

5. Ranking Algorithm

  • Dual-criteria sorting (Market Share × Turnover)
  • Top N competitor selection
  • Handles missing values

6. Visualization Module

  • 6 distinct Plotly chart types
  • Market share pie charts
  • Employee count bar charts
  • Efficiency scatter plots
  • Revenue distribution histograms
  • Interactive HTML rendering

7. Export Service

  • XlsxWriter integration
  • Structured Excel formatting
  • In-memory file generation
  • Browser download handling

8. Web Interface

  • Flask routing and template rendering
  • Responsive Bootstrap UI
  • Real-time dashboard updates
  • Custom prompt chatbot interface

🛠️ Technology Stack

Category Technologies Purpose
Backend Python 3.11, Flask 3.0.0 Web framework, routing, business logic
AI/NLP Ollama 0.6.2, Mistral LLM Competitor data generation
Data Processing Pandas 2.1.1 Data manipulation, cleaning, ranking
Visualization Plotly 5.17.0 Interactive charts and dashboards
Export XlsxWriter Excel report generation
Frontend HTML5, CSS3, Bootstrap Responsive UI
Testing Pytest Unit testing

🎯 Key Features

What This System Does:

Dynamic Form Processing - Captures user specifications for competitor analysis

LLM Integration - Uses Ollama Mistral to generate structured competitor data

Smart Data Cleaning - Normalizes multiple data formats from LLM responses

Ranking Algorithm - Sorts competitors by market share and turnover

Interactive Dashboards - 6 visualizations for data analysis

Excel Export - Professional reports ready for download

Customizable Queries - Market type, product segment, sub-segment, technology filters

Chatbot Interface - Ad-hoc queries with conversational AI


💻 Technical Skills Demonstrated

AI/ML Engineering:

  • Large Language Model (LLM) integration
  • Prompt engineering for structured outputs
  • JSON parsing and validation
  • Context-aware query construction

Backend Development:

  • Flask web application development
  • Dynamic form handling
  • File generation and download
  • Error handling

Data Engineering:

  • Data cleaning pipeline
  • Multi-format normalization
  • Currency and percentage standardization
  • Ranking algorithm implementation

Data Visualization:

  • Dashboard design
  • Interactive Plotly charts
  • Multiple visualization types
  • Export functionality

Full-Stack Development:

  • Frontend UI/UX design
  • Backend logic implementation
  • Template rendering
  • End-to-end system integration

🚀 Development Process

How I Built This:

1. Requirements Gathering - Understood competitor analysis needs from TVS team

2. System Design - Designed Flask application with LLM integration

3. Prompt Engineering - Built dynamic query construction from user inputs

4. AI Integration - Implemented Ollama Mistral with structured output validation

5. Data Pipeline - Developed cleaning and ranking algorithms

6. Visualization - Created 6 interactive dashboards

7. Testing - Built pytest test suite for validation


🧪 Testing

Created test suite using pytest to validate:

  • Page loading and routing
  • Custom prompt functionality
  • Response accuracy against expected outputs
# Sample test structure
def test_index_page(client):
    response = client.get("/")
    assert response.status_code == 200

def test_response_accuracy():
    expected_output = ["Bosch", "TE Connectivity", "Sensata"]
    # Validate chatbot responses

🤝 Let's Connect

I'm a Data Analytics Engineering graduate student at Northeastern University seeking co-op/full-time Data Analyst or Data Scientist roles.

This project demonstrates my ability to:

  • ✅ Build AI-powered applications using Large Language Models
  • ✅ Design interactive dashboards for data visualization
  • ✅ Develop end-to-end web applications
  • ✅ Work independently on complete project lifecycle

Interested in discussing this project?

📧 Email: varaalakshime.l@northeastern.edu
💼 LinkedIn: [https://www.linkedin.com/in/varaalakshime-v]

Available for Co-op: May 2025 - December 2025


📄 Project Context

Developed during Data Scientist internship at TVS Sensing Solutions Private Limited, Madurai - A leading manufacturer of advanced sensing technologies and electronic components under the TVS Sensing Solution Group, specializing in pressure sensors, speed sensors, temperature sensors, and position sensors for automotive and industrial applications.


📚 References

  • Ollama Documentation - LLM integration and prompt engineering
  • Flask Documentation - Web framework implementation
  • Plotly Documentation - Interactive visualizations
  • Pandas Documentation - Data manipulation and analysis

🙏 Acknowledgments

  • TVS Sensing Solutions Private Limited - Internship opportunity and domain expertise
  • Dr. M. S. Sabitha (External Guide) - Technical guidance and project mentorship
  • Dr. C. Mahadevi (Internal Guide) - Academic supervision

⭐ Built with Flask • Ollama Mistral • Plotly • Pandas ⭐

AI-Powered Competitor Analysis Tool

⭐ If you found this project helpful, please star the repository!

About

Turn competitor data into your competitive advantage—automatically!

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors