How openchargemap/ocm-system works
Main Components
• API Layer:
• OCM.API.Core: Contains the core business logic, handling data-related operations and common services (managers, caching, and utilities).
• OCM.API.Client: Client libraries to interact with the API.
• OCM.API.Web: Implements the RESTful endpoints and MVC controllers to serve website pages and the API.
• OCM.API.Worker: Handles background tasks such as refreshing the cache or running an API mirror.
• Website UI:
• The “Website” folder houses the MVC-based website (controllers, views, and related assets) that support standard web interactions.
• Import/Processing Component:
• The “Import” directory contains various submodules (like the Import Manager UI, Import Worker, and Import Analysis) for processing and importing data from external sources.
• Frontend Application:
• The “App” folder includes client-side code (HTML, JavaScript, TypeScript, CSS) potentially used for a mobile or web application interface.
• Data Storage & Caching:
• SQL Server (with Entity Framework Core) for the primary relational data storage.
• MongoDB as a caching layer used heavily by the API to serve requests faster.
• External Services & Connectors:
• References to external services (such as third-party import providers and possibly external mapping APIs) are integrated in various parts of the system.
• Localisation:
• The “Localisation” folder suggests support for multiple languages, impacting many UI components.
Representing Relationships and Flows
• Clients (Developers, Mobile/Website Users, External Apps)
• Web Browser/Mobile App → API Gateway.
• That the API layer (OCM.API.Web) sits behind a gateway and communicates with both the SQL Server (via Entity Framework Core) and MongoDB (for caching).
• Communication links:
• API calls from external systems/AJAX calls from the Website.
• The API Worker periodically refreshes or resets the MongoDB cache.
• The Import modules connect to external data sources and write data to SQL Server (or update the cache).
• The Website’s MVC controllers serve pages and use similar backend services.
Architectural Patterns and Design Principles
• Layered Architecture: Separate the concerns by splitting the project into layers (API core, presentation layer through MVC, background services, and data access).
• Microservices/Worker Pattern: The background workers for cache refreshing and API mirroring can be seen as microservice-like components.
• Repository and Manager Pattern: The “Manager” classes (e.g., UserManager, AuditLogManager, NotificationManager) and “Provider” patterns in the codebase indicate a clean separation of business logic and data access.
• Extensibility: The design supports outsourcing further import providers or localisation components, making the system modular.
Relevant Technologies and Frameworks
• C# with .Net 6 and Entity Framework Core.
• SQL Server as the relational database.
• MongoDB for caching operations.
• ASP.NET MVC for the website and API controllers.
• TypeScript/Angular/Ionic references (via the App folder) for client-side development.
• Third-party libraries (as seen in the “ThirdParty” folder entries) for mapping, bootstrap aesthetics, and client-side validation.
• Notes on Interactions: For instance, “API calls use caching layer (MongoDB) to speed up responses” or “Import modules process external data feeds and update SQL Server.”
Final Advice
• Be comprehensive but avoid unnecessary over-complication. Capture each main component and their interdependencies.
• Critical data flows (client requests, API processing, background cache refresh, import flows) and the communication paths between the API/Web, Backend Services, and Data stores.