Transformer Thermal Inspection Management System - REST API Server
A robust Spring Boot RESTful API for managing transformer thermal inspections, image analysis, and maintenance records with comprehensive versioning support.
Features • Quick Start • Database Schema • API Docs • Reports • Team
| Name |
|---|
| Yasiru Basnayake |
| Kumal Loneth |
| Dasuni Herath |
| Hasitha Gallella |
- Transformer Management - Full CRUD operations for transformer records
- Inspection Management - Track and manage thermal inspections
- Image Management - Upload, store, and retrieve baseline/thermal images
- ML Analysis Integration - Automated anomaly detection results storage
- Report Generation - Maintenance records and thermal inspection reports with versioning
- Version History - Complete audit trail for all reports with restore capability
- JWT Authentication - Secure API access with role-based authorization
- Docker Support - Easy deployment with Docker Compose
# Clone the repository
git clone https://github.com/Team-Arbitary/Arbit-Backend.git
cd Arbit-Backend
# Start with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f appAccess the API at: http://localhost:5509/transformer-thermal-inspection
- JDK 21
- Maven 3.9+
- PostgreSQL 14+
-- Create database
CREATE DATABASE trasformer_inspection_db;
-- Create user (if needed)
CREATE USER postgres WITH PASSWORD '1234';
GRANT ALL PRIVILEGES ON DATABASE trasformer_inspection_db TO postgres;cd app
mvn clean install
mvn spring-boot:run+---------------------+ +-------------------------+
| transformer_records | | inspection_records |
+---------------------+ +-------------------------+
| id (PK) |<------| id (PK) |
| transformer_no (UK) | | inspection_no (UK) |
| pole_no | | transformer_no (FK) |
| regions | | branch |
| type | | date_of_inspection |
| location | | time |
+---------------------+ | maintenance_date |
| status |
+-----------+-------------+
|
+-------------------------------+-------------------------------+
| | |
v v v
+---------------------+ +-------------------------+ +-----------------------------+
| image_inspect | | maintenance_records | | thermal_inspection_reports |
+---------------------+ +-------------------------+ +-----------------------------+
| id (PK) | | id (PK) | | id (PK) |
| transformer_no | | inspection_id (FK) | | inspection_id (FK) |
| inspection_no | | inspector_name | | transformer_no |
| image_type | | status | | report_data (JSON) |
| image_data (BYTEA) | | voltage_reading | | version |
| upload_date | | current_reading | | is_current |
| weather_condition | | recommended_action | | created_by |
| status | | remarks | | created_at |
+---------------------+ | report_data (JSON) | | updated_at |
| version | +-----------------------------+
| is_current |
| start_time |
+---------------------+ | completion_time |
| analysis_result | | supervised_by |
+---------------------+ | tech_i, tech_ii, tech_iii|
| id (PK) | | helpers |
| inspection_no (UK) | | inspected_by |
| transformer_no | | rectified_by |
| annotated_image_data| | re_inspected_by |
| analysis_result_json| | css |
| analysis_status | | created_at |
| analysis_date | | updated_at |
| processing_time_ms | +-------------------------+
| error_message |
+---------------------+
| Table | Description |
|---|---|
transformer_records |
Stores transformer equipment information (ID, location, type, pole number) |
inspection_records |
Tracks inspection events linked to transformers (dates, status, branch) |
image_inspect |
Stores baseline and thermal images as binary data (BYTEA) |
analysis_result |
ML analysis results including annotated images and JSON detection data |
maintenance_records |
Detailed maintenance reports with full versioning support |
thermal_inspection_reports |
Thermal inspection forms with versioning for audit trail |
The system implements a versioned report management approach for generating and storing maintenance records and thermal inspection reports.
+------------------+ +------------------+ +------------------+
| User fills |---->| Frontend sends |---->| Backend creates |
| form in UI | | JSON payload | | new version |
+------------------+ +------------------+ +------------------+
|
v
+------------------+
| Mark previous |
| as non-current |
+------------------+
- Each save creates a new version - Previous versions are preserved for audit
is_currentflag - Only one version is marked as current at any timeversioncounter - Incremental version number per inspection- Full audit trail - Complete history of all changes with timestamps
// Backend versioning logic:
1. Query max version for inspection_id
2. Mark all existing records as is_current = false
3. Create new record with version = max + 1, is_current = true
4. Return saved record with new version numberReports store comprehensive form data as JSON in the report_data field:
{
"startTime": "08:00",
"completionTime": "16:00",
"supervisedBy": "John Smith",
"gangComposition": {
"tech1": "Technician A",
"tech2": "Technician B",
"tech3": "Technician C",
"helpers": "Helper 1, Helper 2"
},
"workDataSheet": {
"gangLeader": "Leader Name",
"kva": "100",
"make": "ABB",
"tapPosition": "3",
"earthResistance": "0.5"
},
"checklist": {
"transformerCondition": true,
"bushingCondition": true,
"oilLevelChecked": true,
"connectionsTightened": true
},
"findings": {
"severity": "critical",
"description": "Hotspot detected at bushing",
"recommendations": ["Replace insulation", "Schedule maintenance"]
}
}Users can view complete version history and restore any previous version:
GET /api/maintenance-records/history/{inspectionId} - Get all versions
GET /api/maintenance-records/version/{inspectionId}/{version} - Get specific version
POST /api/maintenance-records/restore/{inspectionId}/{version} - Restore old version as new
http://localhost:5509/transformer-thermal-inspection
# Login to get JWT token
POST /api/users/login
Content-Type: application/json
{
"username": "admin",
"password": "password"
}
# Response
{
"jwt": "eyJhbGciOiJIUzI1NiIs..."
}
# Use token in subsequent requests
Authorization: Bearer <jwt_token>| Method | Endpoint | Description |
|---|---|---|
POST |
/transformer-management/create |
Create new transformer record |
GET |
/transformer-management/view/{id} |
Get transformer by ID |
GET |
/transformer-management/view-all |
Get all transformers |
PUT |
/transformer-management/update |
Update transformer details |
DELETE |
/transformer-management/delete/{id} |
Delete transformer |
POST |
/transformer-management/filter |
Filter transformers |
| Method | Endpoint | Description |
|---|---|---|
POST |
/inspection-management/create |
Create new inspection |
GET |
/inspection-management/view/{id} |
Get inspection by ID |
GET |
/inspection-management/transformer/{transformerNo} |
Get inspections by transformer |
GET |
/inspection-management/view-all |
Get all inspections |
PUT |
/inspection-management/update |
Update inspection |
DELETE |
/inspection-management/delete/{id} |
Delete inspection |
| Method | Endpoint | Description |
|---|---|---|
POST |
/image-inspection-management/upload |
Upload baseline or thermal image |
GET |
/image-inspection-management/baseline/{transformerNo} |
Get baseline image |
GET |
/image-inspection-management/thermal/{inspectionNo} |
Get thermal image |
PUT |
/image-inspection-management/baseline/{transformerNo} |
Update baseline image |
DELETE |
/image-inspection-management/thermal/{inspectionNo} |
Delete thermal image |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/maintenance-records |
Save record (creates new version) |
GET |
/api/maintenance-records/{id} |
Get record by ID |
GET |
/api/maintenance-records/inspection/{inspectionId} |
Get current record |
GET |
/api/maintenance-records/history/{inspectionId} |
Get version history |
GET |
/api/maintenance-records/version/{inspectionId}/{version} |
Get specific version |
POST |
/api/maintenance-records/restore/{inspectionId}/{version} |
Restore version |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/thermal-inspection-reports |
Save report (creates new version) |
GET |
/api/thermal-inspection-reports/inspection/{inspectionId} |
Get current report |
GET |
/api/thermal-inspection-reports/history/{inspectionId} |
Get version history |
POST |
/api/thermal-inspection-reports/restore/{inspectionId}/{version} |
Restore version |
server:
port: 5509
servlet:
context-path: /transformer-thermal-inspection
spring:
datasource:
url: jdbc:postgresql://localhost:5432/trasformer_inspection_db
username: postgres
password: 1234
jpa:
hibernate:
ddl-auto: update
show-sql: false
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
jwt:
secret: your-256-bit-secret-key
expiration: 86400000 # 24 hours in millisecondsmake up # Start production containers
make dev-up # Start development with hot reload
make logs # View application logs
make down # Stop all containers
make clean # Remove containers and volumes| Service | Port | Description |
|---|---|---|
app |
5509 | Spring Boot application |
db |
5432 | PostgreSQL database |
Arbit-Backend/
├── app/
│ ├── src/main/java/com/uom/Software_design_competition/
│ │ ├── application/
│ │ │ ├── controller/ # REST controllers
│ │ │ ├── transport/ # Request/Response DTOs
│ │ │ └── util/ # Utilities
│ │ └── domain/
│ │ ├── entity/ # JPA entities
│ │ ├── repository/ # Spring Data repositories
│ │ └── service/ # Business logic
│ └── src/main/resources/
│ ├── application.yml # Main config
│ └── application.properties
├── docker-compose.yml
├── Dockerfile
├── Makefile
└── create-tables.sql # Database schema
This project is licensed under the MIT License - see the LICENSE file for details.
Made by Team Arbitary