How bunnycoder1999/ccms-monitor works
Purpose and topology
This repository is a CCMS meter-monitoring system: a Next.js operator UI, a Spring Boot backend, and Kafka-based asynchronous meter-reading transport. The backend integrates with configurable service providers, including Jio, to obtain meter identities/readings, persist them, expose REST APIs, and publish/consume reading events.
Entry points and deployment
• Backend application entry point: ccms_monitor/src/main/java/com/example/ccms_monitor/CcmsApplication.java.
• Frontend is a Next.js App Router application rooted at ccms-frontend/src/app/layout.tsx; unauthenticated entry is ccms-frontend/src/app/login/page.tsx.
• Service/container orchestration is represented by root compose.yaml, ccms_monitor/compose.yaml, ccms-frontend/compose.yaml, and Kafka-specific kafka-docker/docker-compose.yml.
• Both application tiers provide Docker build definitions: ccms_monitor/Dockerfile and ccms-frontend/Dockerfile.
Backend API and integration boundary
Spring MVC controllers form the HTTP boundary for meter serial numbers, readings, Jio integration, and related read operations:
ccms_monitor/src/main/java/com/example/ccms_monitor/controller/MeterSerialNoController.java,
ccms_monitor/src/main/java/com/example/ccms_monitor/controller/MeterReadingController.java,
and ccms_monitor/src/main/java/com/example/ccms_monitor/controller/JioController.java.
Service-layer orchestration separates provider/API operations from transport: service/JioService.java, service/DataFetchService.java, and service/MeterService.java.
Provider authentication and scheduled ingestion
Provider definitions are configuration-driven through config/ServiceProvider.java and config/ServiceProviderConfig.java. Authentication handling is isolated in service/AuthService.java, backed by config/AuthProperties.java. Periodic retrieval is initiated by scheduler/ScheduledTasks.java, which drives the fetch-to-processing pipeline rather than requiring UI-triggered ingestion.
Persistence model
Meter serial numbers and readings are distinct domain entities:
model/MeterSerialNo.java and model/MeterReading.java.
Their repositories, repository/MeterSerialNoRepo.java and repository/MeterReadingRepo.java, define the database boundary used by services/controllers. Backend runtime configuration, including infrastructure connection settings, is centralized in src/main/resources/application.properties.
Kafka event pipeline
Kafka decouples reading production from downstream consumption. kafka/KafkaProducerService.java publishes kafka/dto/MeterReadingEvent.java; kafka/KafkaConsumerService.java receives events for processing/persistence workflows. Broker/client setup belongs in config/KafkaConfig.java. Kafka is external infrastructure supplied by kafka-docker/docker-compose.yml.
Frontend application flow
Authenticated navigation and shared shell are defined in ccms-frontend/src/app/(authenticated)/layout.tsx, with operational pages for the dashboard, meter IDs, and meter readings:
dashboard/page.tsx, meter-ids/page.tsx, and meter-readings/page.tsx.
The UI fetches backend data through service modules—services/axiosInstance.ts, services/meterService.ts, and services/meterReadingService.ts—rather than directly from pages.
Client state and presentation boundaries
React Query is installed at the app boundary through providers/QueryProvider.tsx; resource-specific query behavior is encapsulated in hooks/useMeterQueries.ts and hooks/useMeterReadingQueries.ts. Tables and fetch controls (components/MeterTable.tsx, components/MeterReadingTable.tsx, components/MeterFetchForm.tsx) render and trigger operational workflows. providers/ThemeProvider.tsx and components/app-sidebar.tsx provide cross-cutting UI state/navigation.
Main entry points: MeterReadingController.java Meter REST controllers · docker-compose.yml Kafka broker · layout.tsx App shell & login · compose.yaml Service orchestration
Components 19
Next.js Operator UI
- App shell & login · Provides the root shell, authentication entry, and authenticated navigation.
ccms-frontend/src/app/layout.tsx - Operations pages · Dashboard, meter IDs, and meter readings workflows.
- Query hooks · Resource-specific meter and reading query behavior.
- Backend API client · Axios-backed meter and reading API modules.
- Meter operations UI · Tables and fetch controls render operational workflows.
Spring Boot Backend
- CCMS application
ccms_monitor/src/main/java/com/example/ccms_monitor/CcmsApplication.java - Meter REST controllers · HTTP boundary for meter serials, readings, and Jio operations.
ccms_monitor/src/main/java/com/example/ccms_monitor/controller/MeterReadingController.java - Meter & provider services · Orchestrates meter operations, provider APIs, and data fetching.
- Provider configuration · Config-driven service-provider definitions.
- Provider authentication · Uses configured authentication properties for provider access.
- Scheduled ingestion · Initiates periodic fetch-to-processing work.
- Meter domain · Separate meter serial number and reading records.
- Meter repositories · Database boundary for serial numbers and readings.
Kafka Transport
- Reading event producer · Publishes MeterReadingEvent messages.
- Kafka broker · External asynchronous reading transport.
kafka-docker/docker-compose.yml - Reading event consumer · Processes received reading events for persistence workflows.
Deployment & Infrastructure
- Application database · Infrastructure connection settings are in application properties.
- Service orchestration · Coordinates application and infrastructure containers.
compose.yaml - Application containers · Backend and frontend images are built independently.
ccms_monitor/Dockerfile
Connections 20
- App shell & login → Operations pages: routes users to
- App shell & login → Query hooks: installs query provider
- Operations pages → Meter operations UI: renders
- Meter operations UI → Query hooks: uses
- Query hooks → Backend API client: fetches through
- Backend API client → Meter REST controllers: REST requests
- CCMS application → Meter REST controllers: hosts
- Meter REST controllers → Meter & provider services: delegates to
- Scheduled ingestion → Meter & provider services: triggers ingestion
- Meter & provider services → Provider configuration: selects provider
- Meter & provider services → Provider authentication: authenticates provider calls
- Meter & provider services → Meter repositories: reads and writes
- Meter repositories → Meter domain: persists
- Meter repositories → Application database: stores in
- Meter & provider services → Reading event producer: publishes readings
- Reading event producer → Kafka broker: publishes events
- Kafka broker → Reading event consumer: delivers events
- Reading event consumer → Meter repositories: persists processing results
- Service orchestration → Application containers: builds and runs
- Service orchestration → Kafka broker: provisions