# praveen8848/toolshare_application architecture

> Architecture diagram of the GitHub repository praveen8848/toolshare_application, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/praveen8848/toolshare_application
- Repository: https://github.com/praveen8848/toolshare_application

## Overview

1. **Overall shape**
   ToolShare is a **microservice-based rental platform** with a React frontend and several Spring Boot backend services. The backend is split by business domain rather than by technical layer, with each service owning its own API, persistence model, and security boundary.

2. **Edge entry and routing**
   The **gateway** is the single backend entry point from the frontend. It handles request routing to downstream services and also contains cross-cutting concerns such as **JWT authentication**, **logging**, **rate limiting**, **circuit breaking**, and fallback/error handling. This makes the gateway the main boundary between public traffic and internal services.

3. **Service discovery**
   All Spring services register with the **Eureka server**, which acts as the internal service registry. The gateway and inter-service clients rely on discovery instead of hardcoded service locations, so runtime topology is dynamic.

4. **Authentication boundary**
   **auth-service** is responsible for credential handling and JWT token issuance/validation. It contains the login/register controllers, JWT filter/provider, Spring Security configuration, and a `User` entity/repository for authentication data. Other services trust the token rather than re-authenticating users locally.

5. **User profile subsystem**
   **user-service** stores user profile data separate from authentication data. It manages profile updates, password-change related workflows, and user-facing metadata such as owner profile information. The presence of Feign clients and a registration listener suggests profile creation/synchronization is coordinated with auth-related flows rather than duplicated manually.

6. **Inventory/tool subsystem**
   **tool-service** owns tool listings, categories, and search-related logic. It includes `Tool`, `Category`, repositories, controllers, and services such as `GeocodingService`, which implies location-aware tool discovery. The README’s PostGIS reference indicates this service is the geospatial boundary for radius-based and location-filtered search.

7. **Booking/subscription lifecycle**
   **booking-service** models the rental workflow and booking state transitions. Its domain includes `Booking`, `BookingStatus`, request/response DTOs, availability/conflict views, and dashboard metrics. This is the service that coordinates request creation, approval, updates, and completion, so it is the core transactional workflow for renting tools.

8. **Asynchronous notifications**
   **notification-service** is decoupled from booking and user flows through **RabbitMQ**. It consumes `NotificationEvent` messages and delegates to `EmailService`, so notifications are event-driven rather than synchronous API calls. This keeps user-facing booking actions responsive while notification delivery happens out of band.

9. **Synchronous service-to-service calls**
   Several services use **Feign-style REST clients** to fetch data from neighboring domains:
   - booking-service calls tool-service and user-service
   - tool-service calls user-service
   - auth-service and user-service also coordinate around registration/profile sync  
   These calls are used for enriching responses and validating ownership/profile context without duplicating data locally.

10. **Caching and state support**
    **Redis** is configured in booking-service and tool-service, indicating caching or short-lived state support for performance-sensitive flows such as availability checks, session-like data, or query acceleration. It is an auxiliary store, not the primary system of record.

11. **Frontend composition**
    The frontend is a **React SPA** organized by feature: auth, tools, bookings, dashboards, and common UI. It uses a central Axios config, an auth context, protected routes, custom hooks, and feature-specific service wrappers to talk to the gateway rather than directly to backend services.

12. **Data ownership and boundaries**
    The architecture follows a **database-per-service** style. auth-service, user-service, booking-service, and tool-service each maintain their own persistence model, which reduces coupling and keeps lifecycle rules local to the service that owns them.

13. **Infrastructure and deployment**
    The repo is containerized with per-service **Dockerfiles** and a top-level **docker-compose.yaml** for local stack orchestration. Maven wrappers are used for each Java service, and the frontend is a separate Node-based application. The main runtime dependencies that shape the architecture are Spring Boot, Eureka, RabbitMQ, Redis, PostgreSQL/PostGIS, and React.

14. **Primary request/data flow**
    A typical user journey is: **React frontend → gateway → domain service**. For example, browsing tools goes through the gateway into tool-service; creating a booking goes through the gateway into booking-service, which may consult tool-service/user-service and emit a RabbitMQ event; notification-service consumes that event and sends email; profile or ownership data is served from user-service. This combination of synchronous API calls and asynchronous events is the central architectural pattern of the system.

Main entry points: [`gateway`](https://github.com/praveen8848/toolshare_application/tree/main/gateway) (Gateway), [`booking-service`](https://github.com/praveen8848/toolshare_application/tree/main/booking-service) (Booking Service), [`user-service`](https://github.com/praveen8848/toolshare_application/tree/main/user-service) (User Service), [`eureka-server`](https://github.com/praveen8848/toolshare_application/tree/main/eureka-server) (Eureka Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_react_spa["React SPA<br/>frontend"]
  node_api_routes["App Routes<br/>frontend routing<br/>[AppRoutes.js]"]
  node_axios_auth["API Client<br/>frontend api<br/>[axiosConfig.js]"]
end

subgraph group_edge["Edge"]
  node_gateway["Gateway<br/>edge proxy"]
  node_gateway_filters["Gateway Filters<br/>edge filters"]
  node_gateway_config["Gateway Config<br/>edge config"]
end

subgraph group_services["Domain Services"]
  node_auth_service["Auth Service<br/>identity service"]
  node_auth_security["Auth Security<br/>identity security"]
  node_user_service["User Service<br/>profile service"]
  node_user_listener["Reg Listener<br/>profile sync"]
  node_tool_service["Tool Service<br/>inventory service"]
  node_geocoding["Geocoding<br/>location logic"]
  node_booking_service["Booking Service<br/>rental workflow"]
  node_booking_logic["Booking Logic<br/>workflow core"]
  node_notification_service["Notification Service<br/>async notifier"]
end

subgraph group_infra["Infra"]
  node_eureka[("Eureka Server<br/>registry")]
  node_rabbitmq["RabbitMQ<br/>message broker"]
  node_redis[("Redis<br/>cache")]
  node_postgres[("PostgreSQL/PostGIS<br/>datastore")]
end

node_react_spa -->|"renders"| node_api_routes
node_react_spa -->|"calls API"| node_axios_auth
node_axios_auth -->|"requests"| node_gateway
node_gateway -->|"applies"| node_gateway_filters
node_gateway -->|"routes"| node_gateway_config
node_gateway -->|"discovers"| node_eureka
node_auth_service -->|"secures"| node_auth_security
node_auth_service -->|"registers"| node_eureka
node_auth_service -->|"stores"| node_postgres
node_auth_service -->|"syncs user"| node_user_service
node_user_service -->|"consumes"| node_user_listener
node_user_service -->|"registers"| node_eureka
node_user_service -->|"stores"| node_postgres
node_user_service -->|"publishes/consumes"| node_rabbitmq
node_tool_service -->|"uses"| node_geocoding
node_tool_service -->|"registers"| node_eureka
node_tool_service -->|"stores"| node_postgres
node_tool_service -->|"caches"| node_redis
node_booking_service -->|"drives"| node_booking_logic
node_booking_service -->|"registers"| node_eureka
node_booking_service -->|"stores"| node_postgres
node_booking_service -->|"caches"| node_redis
node_booking_service -->|"publishes"| node_rabbitmq
node_notification_service -->|"consumes"| node_rabbitmq
node_notification_service -->|"registers"| node_eureka
node_gateway -->|"routes auth"| node_auth_service
node_gateway -->|"routes user"| node_user_service
node_gateway -->|"routes tools"| node_tool_service
node_gateway -->|"routes bookings"| node_booking_service
node_gateway -.-> node_notification_service

click node_react_spa "https://github.com/praveen8848/toolshare_application/tree/main/frontend"
click node_api_routes "https://github.com/praveen8848/toolshare_application/blob/main/frontend/src/routes/AppRoutes.js"
click node_axios_auth "https://github.com/praveen8848/toolshare_application/blob/main/frontend/src/config/axiosConfig.js"
click node_gateway "https://github.com/praveen8848/toolshare_application/tree/main/gateway"
click node_gateway_filters "https://github.com/praveen8848/toolshare_application/tree/main/gateway/src/main/java/com/toolsharing/gateway/filter"
click node_gateway_config "https://github.com/praveen8848/toolshare_application/tree/main/gateway/src/main/java/com/toolsharing/gateway/config"
click node_eureka "https://github.com/praveen8848/toolshare_application/tree/main/eureka-server"
click node_auth_service "https://github.com/praveen8848/toolshare_application/tree/main/auth-service"
click node_auth_security "https://github.com/praveen8848/toolshare_application/tree/main/auth-service/src/main/java/com/toolsharing/auth_service/security"
click node_user_service "https://github.com/praveen8848/toolshare_application/tree/main/user-service"
click node_user_listener "https://github.com/praveen8848/toolshare_application/blob/main/user-service/src/main/java/com/toolsharing/user_service/listener/UserRegistrationListener.java"
click node_tool_service "https://github.com/praveen8848/toolshare_application/tree/main/tool-service"
click node_geocoding "https://github.com/praveen8848/toolshare_application/blob/main/tool-service/src/main/java/com/toolsharing/tool_service/service/GeocodingService.java"
click node_booking_service "https://github.com/praveen8848/toolshare_application/tree/main/booking-service"
click node_booking_logic "https://github.com/praveen8848/toolshare_application/blob/main/booking-service/src/main/java/com/toolsharing/booking_service/service/BookingService.java"
click node_notification_service "https://github.com/praveen8848/toolshare_application/tree/main/notification-service"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_react_spa,node_api_routes,node_axios_auth toneBlue
class node_gateway,node_gateway_filters,node_gateway_config toneAmber
class node_auth_service,node_auth_security,node_user_service,node_user_listener,node_tool_service,node_geocoding,node_booking_service,node_booking_logic,node_notification_service toneMint
class node_eureka,node_rabbitmq,node_redis,node_postgres toneRose
```

## Components

### Frontend

React client and feature UI

- [React SPA](https://github.com/praveen8848/toolshare_application/tree/main/frontend): frontend · Feature-based client UI and route composition · `frontend`
- [App Routes](https://github.com/praveen8848/toolshare_application/blob/main/frontend/src/routes/AppRoutes.js): frontend routing · Protects pages and wires feature views · `frontend/src/routes/AppRoutes.js`
- [API Client](https://github.com/praveen8848/toolshare_application/blob/main/frontend/src/config/axiosConfig.js): frontend api · Central Axios/auth context used by feature services · `frontend/src/config/axiosConfig.js`

### Edge

Public entry and routing layer

- [Gateway](https://github.com/praveen8848/toolshare_application/tree/main/gateway): edge proxy · Single entry point with routing, JWT, logging, rate limiting, and fallback handling · `gateway`
- [Gateway Filters](https://github.com/praveen8848/toolshare_application/tree/main/gateway/src/main/java/com/toolsharing/gateway/filter): edge filters · JWT auth, logging, circuit breaking, and error handling · `gateway/src/main/java/com/toolsharing/gateway/filter`
- [Gateway Config](https://github.com/praveen8848/toolshare_application/tree/main/gateway/src/main/java/com/toolsharing/gateway/config): edge config · Route, security, rate limit, and client setup · `gateway/src/main/java/com/toolsharing/gateway/config`

### Domain Services

Business-domain Spring Boot services

- [Auth Service](https://github.com/praveen8848/toolshare_application/tree/main/auth-service): identity service · Credentials, JWT issuance, and auth persistence · `auth-service`
- [Auth Security](https://github.com/praveen8848/toolshare_application/tree/main/auth-service/src/main/java/com/toolsharing/auth_service/security): identity security · JWT filter, token provider, and Spring Security · `auth-service/src/main/java/com/toolsharing/auth_service/security`
- [User Service](https://github.com/praveen8848/toolshare_application/tree/main/user-service): profile service · User profiles, password workflows, and registration sync · `user-service`
- [Reg Listener](https://github.com/praveen8848/toolshare_application/blob/main/user-service/src/main/java/com/toolsharing/user_service/listener/UserRegistrationListener.java): profile sync · Consumes registration events and coordinates profile creation · `user-service/src/main/java/com/toolsharing/user_service/listener/UserRegistrationListener.java`
- [Tool Service](https://github.com/praveen8848/toolshare_application/tree/main/tool-service): inventory service · Tools, categories, search, and geospatial discovery · `tool-service`
- [Geocoding](https://github.com/praveen8848/toolshare_application/blob/main/tool-service/src/main/java/com/toolsharing/tool_service/service/GeocodingService.java): location logic · Location-aware tool lookup support · `tool-service/src/main/java/com/toolsharing/tool_service/service/GeocodingService.java`
- [Booking Service](https://github.com/praveen8848/toolshare_application/tree/main/booking-service): rental workflow · Booking lifecycle, availability, approval, and metrics · `booking-service`
- [Booking Logic](https://github.com/praveen8848/toolshare_application/blob/main/booking-service/src/main/java/com/toolsharing/booking_service/service/BookingService.java): workflow core · State transitions and booking operations · `booking-service/src/main/java/com/toolsharing/booking_service/service/BookingService.java`
- [Notification Service](https://github.com/praveen8848/toolshare_application/tree/main/notification-service): async notifier · Consumes events and sends email notifications · `notification-service`

### Infra

Shared runtime infrastructure

- [Eureka Server](https://github.com/praveen8848/toolshare_application/tree/main/eureka-server): registry · Service discovery registry for Spring services · `eureka-server`
- **RabbitMQ**: message broker · Async event bus between booking, user, and notifications
- **Redis**: cache · Short-lived state and query acceleration for booking/tool flows
- **PostgreSQL/PostGIS**: datastore · Service-owned persistence including geospatial data

## Connections

- React SPA → App Routes: renders · UI routes to feature pages
- React SPA → API Client: calls API · Frontend features use shared client/auth context
- API Client → Gateway: requests · All API traffic is sent through the gateway
- Gateway → Gateway Filters: applies · Cross-cutting edge concerns run at ingress
- Gateway → Gateway Config: routes · Gateway config defines downstream routing and policies
- Gateway → Eureka Server: discovers · Gateway resolves services through the registry
- Auth Service → Auth Security: secures · JWT and Spring Security boundary
- Auth Service → Eureka Server: registers · Service discovery registration
- Auth Service → PostgreSQL/PostGIS: stores · Auth data is persisted locally
- Auth Service → User Service: syncs user · Registration/profile coordination
- User Service → Reg Listener: consumes · Registration event handling and profile creation flow
- User Service → Eureka Server: registers · Service discovery registration
- User Service → PostgreSQL/PostGIS: stores · Profile data is persisted locally
- User Service → RabbitMQ: publishes/consumes · Event-driven profile coordination
- Tool Service → Geocoding: uses · Location-aware tool discovery
- Tool Service → Eureka Server: registers · Service discovery registration
- Tool Service → PostgreSQL/PostGIS: stores · Tool and category data are persisted locally
- Tool Service → Redis: caches · Supports performance-sensitive lookup flows
- Booking Service → Booking Logic: drives · Core rental workflow implementation
- Booking Service → Eureka Server: registers · Service discovery registration
- Booking Service → PostgreSQL/PostGIS: stores · Bookings are persisted locally
- Booking Service → Redis: caches · Supports availability and short-lived state
- Booking Service → RabbitMQ: publishes · Emits booking events for notifications
- Notification Service → RabbitMQ: consumes · Listens for notification events
- Notification Service → Eureka Server: registers · Service discovery registration
- Gateway → Auth Service: routes auth · Public auth requests are forwarded to auth-service
- Gateway → User Service: routes user · Profile requests are forwarded to user-service
- Gateway → Tool Service: routes tools · Tool browsing and management requests flow through the gateway
- Gateway → Booking Service: routes bookings · Booking requests flow through the gateway
- Gateway → Notification Service: Notifications are not directly exposed as a public API
