A Spring Boot application for managing electricity tokens and meters, providing functionality for token purchases, meter management, and automated notifications.
-
Token Management
- Purchase electricity tokens
- Validate tokens
- Track token expiry
- View token history
-
Meter Management
- Register new meters
- Associate meters with users
- View meter details
- Track meter consumption
-
User Management
- User registration and authentication
- Role-based access control
- User profile management
-
Notification System
- Automated token expiry notifications
- Email notifications
- Real-time status updates
- Backend Framework: Spring Boot
- Database: JPA/Hibernate
- Security: Spring Security
- Documentation: Swagger/OpenAPI
- Build Tool: Maven/Gradle
- Java Version: 24
Before running this application, make sure you have:
- JDK 24 or later installed
- Maven/Gradle build tool installed
- An IDE (preferably IntelliJ IDEA)
- Email server configuration (for notifications)
- Clone the repository:
bash git clone https://github.com/NE-PREP-2024-2025/springboot-eucl
- Navigate to the project directory:
cd pringboot-eucl
- Build the project:
mvn clean install
- Run the application:
mvn spring-boot:run
Access Endpoints at swagger at http:localhost:8080/swagger-ui/index.html
GET /api/v1/users/all
- Get all usersGET /api/v1/users/{id}
- Get user by IDPUT /api/v1/users/{id}
- Update userDELETE /api/v1/users/{id}
- Delete user
POST /purchase
- Purchase new tokenGET /{meterNumber}
- Get tokens by meter numberPOST /{token}
- Validate tokenGET /all
- Get all tokensPUT /{token}
- Update token status
Create an application.properties
file in src/main/resources
with the following configurations:
properties
# Database Configuration
spring.datasource.url=jdbc:postgresql://localhost:5432/your_database spring.datasource.username=your_username spring.datasource.password=your_password
# JPA Properties
spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true
# Email Configuration
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=your-email@gmail.com
spring.mail.password=your-app-password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
The application implements role-based access control with the following roles:
- ADMIN: Full system access
- CUSTOMER: Limited access to personal information and token purchases
The system includes scheduled tasks for:
- Token expiry checks (runs every 5 minutes)
- Notification processing
- Email delivery
The system implements global exception handling for:
- Bad Request exceptions
- Authentication failures
- Invalid data inputs
- System errors
- Entity Not found Exception