Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SustainableWasteManagementAPI is a Spring Boot RESTful API that helps manage waste efficiently. It allows users to handle waste categories, recycling tips, and disposal guidelines, promoting eco-friendly practices for a cleaner planet.

NotificationsYou must be signed in to change notification settings

ZannyM/SustainableWasteManagementAPI

Repository files navigation

A RESTful API for sustainable waste management, providing information on waste categories, recycling tips, and disposal guidelines.

Features

  • Waste Categories Management: Add, update, retrieve, and delete waste categories

  • Recycling Tips: Get actionable insights on how to recycle different materials

  • Disposal Guidelines: Retrieve best practices for safe and sustainable disposal

  • Spring Security Authentication: Simple and secure username/password authentication

  • Role-Based Access Control: Different access levels for users and admins

  • Soft Delete Functionality: Preserves data relationships while allowing "deletion"

  • Performance Optimization:

    • Caching for improved response times
    • Rate limiting to prevent API abuse
  • API Documentation: Swagger/OpenAPI documentation

  • Monitoring: Application health metrics and performance monitoring

Live API

The API is deployed and accessible athttps://sustainablewastemanagementapi.onrender.com

Interactive API documentation is available at:https://sustainablewastemanagementapi.onrender.com/swagger-ui/index.html

Prerequisites

  • Java 17
  • Spring Boot 3.x
  • Maven 3.6+
  • Spring Security
  • H2 Database (for development)
  • Swagger/OpenAPI
  • Actuator & Micrometer (for monitoring)
  • Postman (API Testing)

Getting Started With Local Development

Clone the repository:

git clone https://github.com/ZannyM/SustainableWasteManagementAPI

Build the project:

mvn clean install

Run the application:

mvn spring-boot:run

Access the API at:

http://localhost:8080

Access the API documentation at:

http://localhost:8080/swagger-ui/index.html

Authentication

The API uses Spring Security with basic authentication:

Regular User:

Can perform standard operations

  • Username:user
  • Password:password

Admin User:

Has access to all endpoints including admin operations

  • Username:admin
  • Password:admin

API Endpoints

WasteCategory Endpoints

MethodEndpointDescriptionAuthentication
GET/api/waste-categoriesRetrieve all waste categoriesNone
GET/api/waste-categories/{id}Retrieve a waste category by IDNone
POST/api/waste-categoriesCreate a new waste categoryRequired
PUT/api/waste-categories/{id}Update a waste categoryRequired
DELETE/api/waste-categories/{id}Soft-delete a waste categoryRequired

RecyclingTip Endpoints

MethodEndpointDescriptionAuthentication
GET/api/recycling-tipsRetrieve all recycling tipsNone
GET/api/recycling-tips/{id}Retrieve a recycling tip by IDNone
POST/api/recycling-tipsCreate a new recycling tipRequired
PUT/api/recycling-tips/{id}Update a recycling tipRequired
DELETE/api/recycling-tips/{id}Soft-delete a recycling tipRequired

DisposalGuideline Endpoints

MethodEndpointDescriptionAuthentication
GET/api/disposal-guidelinesRetrieve all disposal guidelinesNone
GET/api/disposal-guidelines/{id}Retrieve a disposal guideline by IDNone
POST/api/disposal-guidelinesCreate a new disposal guidelineRequired
PUT/api/disposal-guidelines/{id}Update a disposal guidelineRequired
DELETE/api/disposal-guidelines/{id}Soft-delete a disposal guidelineRequired

Admin Endpoints

MethodEndpointDescriptionAuthentication
POST/api/admin/waste-categoriesCreate a new user (admin only)Admin Only
PUT/api/admin/waste-categories/{id}Update user informationAdmin Only
DELETE/api/admin/waste-categories/{id}Delete a userAdmin Only

Authentication Endpoints

MethodEndpointDescriptionAuthentication
GET/api/auth/meGet current user informationRequired

Soft Delete Implementation

This API implements a soft delete approach:

  • Records are not physically removed from the database
  • Instead, they are marked as inactive with anactive flag
  • This preserves data relationships and prevents constraint violations
  • Only active records are returned by default in API responses

Security

  • Public endpoints: GET operations on waste categories, recycling tips, and disposal guidelines
  • Protected endpoints: POST, PUT, DELETE operations (require authentication)
  • Admin endpoints: Special operations for administrators only

Monitoring

  • Application health:http://localhost:8080/actuator/health
  • Metrics:http://localhost:8080/actuator/metrics
  • Prometheus metrics:http://localhost:8080/actuator/prometheus

###Testing

  • JUnit 5: Unit and integration testing framework
  • Mockito: Mocking framework for isolating dependencies during tests
  • Spring Boot Test: For comprehensive testing of Spring components-Swagger UI: For interactive API testing

Running Tests

Run Unit and Integration Tests:

mvn test

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

Zanny Maholobela

About

SustainableWasteManagementAPI is a Spring Boot RESTful API that helps manage waste efficiently. It allows users to handle waste categories, recycling tips, and disposal guidelines, promoting eco-friendly practices for a cleaner planet.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp