Building a Scalable Web Application for McCance’s EV Charging Solutions Using Python and PHP

As McCance Highways expands its role in deploying EV charging infrastructure across the UK, the need for a robust, dynamic web application becomes vital. Such a platform must render complex commercial and civil EV charging solutions with real-time functionality, data management, and visual presentation capabilities.

In this blog, we'll walk through the technical approach of building a custom application for McCance’s EV Charging Solutions, leveraging Python and PHP as core backend technologies. Our goal is to develop an app that not only showcases available EV infrastructure but also supports client interaction, data visualization, and integration with charging unit telemetry.


Why a Custom EV Charging Platform?

Before we dive into the code, let's understand the purpose behind the platform. This application aims to:

  • Display available EV charging solutions with real-time capabilities.

  • Handle client enquiries and project tracking.

  • Integrate charging unit performance data from IoT systems.

  • Enable admin-level configuration for new locations or charger types.

  • Provide a dashboard with analytics for usage, uptime, and sustainability metrics.


Tech Stack Overview

We use a hybrid backend architecture where Python (Flask or FastAPI) is responsible for real-time data services and analytics, while PHP (Laravel or core PHP) manages CMS-level functionalities like user management, content handling, and contact forms.

Front-End:

  • HTML5 / CSS3 / JavaScript (React or Vue for interactivity)

  • Bootstrap or Tailwind CSS

Back-End:

  • Python (FastAPI) for API services, analytics, and live EV unit data

  • PHP (Laravel) for CMS, admin tools, content delivery

Database:

  • MySQL or PostgreSQL

  • Redis (optional, for real-time session or caching)

Deployment & Hosting:

  • Dockerized containers

  • Nginx or Apache as web server

  • AWS / DigitalOcean / Heroku for cloud deployment


System Architecture Diagram

plaintextCopyEditUser Interface
   |
   |---> PHP Backend (Laravel) <-------- Admin, CMS, Auth
   |
   |---> Python API (FastAPI) <-------- Real-time Telemetry, Analytics, Scheduler
   |
   |---> PostgreSQL Database <-------- Shared Data Layer

Setting Up the Python API with FastAPI

FastAPI is an excellent choice for building real-time data APIs. Here's how we set it up:

Install FastAPI and Uvicorn:

bashCopyEditpip install fastapi uvicorn

Define Your First Endpoint for EV Charger Listing:

pythonCopyEditfrom fastapi import FastAPI
from typing import List
from pydantic import BaseModel

app = FastAPI()

class Charger(BaseModel):
    id: int
    name: str
    type: str
    speed_kw: int
    location: str

@app.get("/chargers", response_model=List[Charger])
def get_chargers():
    return [
        {"id": 1, "name": "Rapid Charger", "type": "DC", "speed_kw": 50, "location": "Fleet Hub"},
        {"id": 2, "name": "Smart Wall Unit", "type": "AC", "speed_kw": 22, "location": "Admin HQ"}
    ]

This endpoint allows the front end to fetch charger data dynamically.


Integrating Charging Unit Telemetry

To handle incoming data from EV charging units (temperature, uptime, charge cycles, etc.), use a FastAPI background task:

pythonCopyEdit@app.post("/telemetry")
async def receive_telemetry(data: dict):
    # Save data to DB or Redis
    process_data_async(data)
    return {"status": "received"}

Here, the telemetry data can be visualized via a dashboard (explained below).


Creating the Admin CMS in PHP (Laravel)

Laravel makes content management and user roles easier. Here's a basic breakdown of the Laravel setup for handling EV product entries.

Install Laravel:

bashCopyEditcomposer create-project --prefer-dist laravel/laravel evcms

Create a Charger Model:

bashCopyEditphp artisan make:model Charger -m

Inside the migration:

phpCopyEditSchema::create('chargers', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('type');
    $table->integer('speed_kw');
    $table->string('location');
    $table->timestamps();
});

Admin Panel CRUD:

Using Laravel Breeze or Voyager, you can quickly scaffold a dashboard to manage EV charging entries.


Bridging PHP and Python: Inter-Backend Communication

To connect the Laravel app to the FastAPI data endpoints, use PHP’s GuzzleHTTP to consume the Python API:

phpCopyEdituse GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'http://localhost:8000/chargers');
$chargers = json_decode($response->getBody());

This hybrid architecture lets you split heavy real-time workloads (Python) from content and CMS (PHP) while maintaining a shared experience.


Implementing Real-Time Data Visualization

For the admin dashboard, you can use Chart.js or Plotly.js with Python endpoints feeding live JSON:

Python Route (FastAPI):

pythonCopyEdit@app.get("/analytics/usage")
def get_usage():
    return {
        "labels": ["Jan", "Feb", "Mar"],
        "data": [134, 212, 158]
    }

Front-End Chart:

javascriptCopyEditfetch('/analytics/usage')
.then(response => response.json())
.then(data => {
    new Chart(ctx, {
        type: 'line',
        data: {
            labels: data.labels,
            datasets: [{
                label: 'Monthly Usage (kWh)',
                data: data.data,
                borderColor: 'green'
            }]
        }
    });
});

Features Checklist

Here’s what the app delivers once fully deployed:

FeatureTechnology Used
Real-time charger statusPython (FastAPI + Redis)
Admin CMSLaravel (PHP)
Client-side analyticsChart.js + Python endpoints
User & role authenticationLaravel Auth / Sanctum
Charger telemetry ingestionPython REST API
SEO-ready product pagesLaravel Blade / Vue

Final Thoughts

Building a hybrid application for McCance’s EV Charging Solutions using Python and PHP leverages the strengths of both ecosystems. Python handles real-time data processing and analytics, while PHP powers admin features, CMS content, and system management. This dual-technology stack ensures the app remains scalable, flexible, and performance-optimised—perfect for a modern business managing complex infrastructure like EV charging across the UK.

With a focus on user-friendly design, real-time capability, and admin control, this platform can play a crucial role in supporting McCance’s mission of delivering sustainable, smart charging networks to civil and commercial spaces.

0
Subscribe to my newsletter

Read articles from Stella Josephine directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Stella Josephine
Stella Josephine