How fan9704/garbage_classifier_backend works
Project Type and Purpose
• The README clearly states this is “Garbage Classifier Backend” and part of an integrated system that also contains an application, frontend, and hardware components.
• Its main purpose is to provide RESTful and GraphQL APIs for user management, machine control (lock/unlock, linking with users), wallet services, and bank account interactions, among other features.
• It also includes integrations with external services such as Firebase (for FCM tokens), RabbitMQ (for asynchronous messaging, noted as a future/distributed feature), Redis (for session management), and monitoring tools like Prometheus and Grafana.
File Structure
• Key directories include:
• src/main/java: Contains the full business logic, broken into packages for controllers, services, repositories, models (entities), configurations, and GraphQL handling.
• The configuration package houses setup for Firebase, RabbitMQ, Global CORS, Redis, security, Swagger (API documentation), and WebSocket.
• GraphQL endpoints are clearly separate under the “GraphQL” directory with further subdivided packages for queries, mutations, and resolvers.
• src/main/resources holds the application properties, Firebase service account credentials, and GraphQL schema definitions.
• Test directories mirror the main structure ensuring unit tests for controllers, services, and repositories.
• Additionally, there are Docker and Maven wrapper files for containerization and builds.
README for Additional Insights
• The README shows sample URLs for Swagger UI (for API documentation), Prometheus, and Grafana panels for system monitoring.
• There is a detailed listing of available REST API endpoints and GraphQL integration indicating a rich API surface meant for external clients.
• Overall, the software is deployed as a standalone Spring Boot application, with containerization supported via Docker.
a. Main Components to Include:
• Client Interfaces: Representing end-user clients (including the Swagger-based web interface and mobile/other applications) that interact with the backend.
• REST API Controllers (e.g., UserController, MachineController, etc.)
• GraphQL Endpoints (queries, mutations, resolvers)
• Business Logic / Service Layer: Handling the business operations of registration, wallet management, machine operations, etc.
• Data Access Layer / Repository: Using Spring Data JPA for repository access to entities like User, Machine, Wallet, and others.
• Domain Models: The entity classes that represent the system’s data.
• Configuration Modules: Including security, Swagger API docs, Firebase, RabbitMQ, and Redis.
• External Integrations:
• Monitoring: Prometheus and Grafana panels for system health.
• Messaging Systems: RabbitMQ for distributed messaging (even if it’s noted as a future feature).
• Cloud Services: Firebase for cloud messaging.
• WebSocket/Real-time: Components used for WebSocket communication.
• Database: Though not explicitly shown, the use of JPA implies a relational database underlying the repository layer.
• Other System Projects: Optionally, indicate the overall system linkage to the Application, Frontend, and Hardware projects mentioned in the README.
b. Relationships and Interactions:
• Data flows from external clients (via HTTP/GraphQL) entering through the controllers.
• Interactions from controllers to the service layer and subsequently to the repository layer.
• Monitoring endpoints (Prometheus, Grafana) linked to the backend—possibly through Actuator and Micrometer integration.
• If including the overall system context, show how the backend interfaces with the Frontend, Application, and Hardware components via defined APIs.
c. Architectural Patterns and Design Principles:
• The system follows a layered architecture (controllers, services, repositories).
• It utilizes GraphQL alongside REST, showing a hybrid API model.
• It integrates common enterprise-grade components (messaging, caching, security, and monitoring), highlighting best practices in modular design.
d. Relevant Technologies:
• Spring Boot (for the main application framework)
• Spring Data JPA (for database interactions)
• GraphQL (for flexible API queries/mutations)
• Maven (for project management and builds)
• Docker (for containerizing the application)
• External tools: RabbitMQ, Firebase, Redis, Swagger UI, Prometheus, and Grafana.