Open Charge Map

By: Justin Stewart
10-24-2024


Home Page
electric vehicle

Table of Contents

Openchargemap.org

I have been searching for open-source projects to practice my programming skills, I stumbled upon this hidden gem: Open Charge Map. It is an open source web app that displays electric vehicle charging locations. While I don't make enough money to buy an electric car in order to save money on gas, I can certainly access a free code editor and dive into some coding. I remember when electricity was 10 cents a gallon... On a side note the local utility company in my area increased the price of electricity at the beginning of summer this year, probably so we can help pay for rich people to charge their Teslas.

This is only a brief overview of this open source project. I’m excited to share this discovery with you and explore the potential contributions we can make together!

Here is the link for openchargemap.org!

The Open Charge Map website is incredibly user-friendly, featuring a dynamic canvas element that updates in real time with the locations of charging stations. Most users will find that their location is automatically detected, making navigation effortless.

When you click on the map, you’ll be prompted to sign in, and there’s also a handy search bar to quickly find charging stations in your area. It can be used without signing in. This platform serves as a global public registry of electric vehicle charging stations, established in 2011. Its crowdsourced dataset combines manually entered information with open data imported from government-run registries and charging networks, all under an MIT License.


The API

Developers interested in building their own applications can easily tap into the wealth of data provided by OpenChargeMap through its API. This allows you to integrate charging station information into your projects seamlessly. If you're curious about how the map application is built, you can explore the source code, which utilizes the latest technologies like Ionic, Angular, and TypeScript.

Check out the repository on Github.

To appreciate how OpenChargeMap functions behind the scenes, let's break down its server-side architecture into digestible sections:


Server-Side Architecture

OpenChargeMap.org is built using modern web technologies that ensure efficient data handling and high performance. Here's a breakdown of the server-side stack used in the project:

OpenChargeMap's server-side code is primarily written in C#, and it includes a web application that interacts with users and developers alike.

Why C# and .NET 6?

C# is a versatile and powerful programming language, particularly well-suited for building server-side applications. .NET 6 brings performance enhancements and long-term support, making it an ideal choice for large-scale projects like OpenChargeMap. The project is built using Visual Studio 2022 Community Edition or higher, which provides a rich development environment with built-in tools for debugging and testing. .NET 6 support in Visual Studio allows developers to use the latest language features and take advantage of performance optimizations.

Data for Open Charge Map is primarily stored in SQL Server, a relational database system known for its robustness and scalability.

Entity Framework Core(EF Core) is used as the Object-Relational Mapper (ORM), allowing seamless interaction between the C# code and the SQL Server database. This enables developers to work with database records as C# objects, simplifying CRUD (Create, Read, Update, Delete) operations. EF Core allows for easy migrations and schema management, ensuring the database evolves alongside the application without manual intervention.


   public class ChargingLocation
   {
       public int Id { get; set; }
       public string Name { get; set; }
       public decimal Latitude { get; set; }
       public decimal Longitude { get; set; }
   }

Mongo DB

To improve the performance of API reads, OpenChargeMap uses a MongoDB cache layer. Most read requests for data are serviced by this caching system, which drastically reduces the load on the SQL Server database and speeds up response times for users.

MongoDB is a NoSQL database, optimized for read-heavy workloads with its flexible document storage format. Frequently accessed data, such as charging locations and related metadata, is cached in MongoDB to avoid repeated calls to SQL Server. This caching strategy ensures faster API responses, particularly for high-traffic endpoints.

Example of MongoDB Usage: When a request is made for charging locations, the application first checks the MongoDB cache. If the data is present, it is returned immediately; otherwise, the application fetches the data from SQL Server, caches it in MongoDB, and serves it to the user.

The combination of SQL Server for structured data storage and MongoDB for high-speed caching provides a robust system that can handle large datasets and high traffic efficiently. The choice of Entity Framework Core ensures that the database layer integrates smoothly with the application, while C# and .NET 6 provide the power and flexibility needed to build and maintain a large-scale, production-grade API.


Deployment

If you want to work on this project on your own machine, clone the github repository. Setting up the OpenChargeMap application involves several key steps to ensure everything runs smoothly. Follow these instructions to deploy the application successfully:

Configure MongoDB. Set up MongoDB as a service on your server. Initialize the ocm_mirror database to manage cached data effectively.

Configure the ASP.NET State Services to start automatically. This is crucial for maintaining session state across the application. Ensure that the service is started.

Install the SQL Server 2012 CLR Data Types (Version 11.x), as this is required for Entity Framework to function properly. This step is essential for handling certain data types within your application.

Install the URL Rewrite Module 2.0, which is necessary for proper handler mapping in the web application. This module helps with SEO-friendly URLs and routing requests appropriately.

Enable read/write permissions for the application pool user on the \Temp folders. This access is vital for the application to write temporary files and logs during its operation.

Finally, configure the web.config file according to your environment’s specifications. This file is crucial for managing settings such as database connections, authentication modes, and custom application settings. By following these steps, you will successfully deploy the OpenChargeMap application, making it ready for use and contributions.


System Requirements

To set up your own development environment for contributing to OpenChargeMap, you'll need the following system requirements:

Operating System: Windows 7 or higher (or Windows Server 2008 or higher) Development Environment: Visual Studio 2015 Professional or equivalent Express Editions (Web, Windows) with the latest NuGet package manager and TypeScript add-in installed Database: MS SQL Express 2008 R2 or later Additional Tools: Node.js

By meeting these requirements, you'll be well-equipped to dive into the OpenChargeMap codebase and start contributing to this valuable resource for electric vehicle charging stations.