# abhip47/nexdrive-backend architecture

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

- Interactive diagram: https://gitdiagram.com/abhip47/nexdrive-backend
- Repository: https://github.com/abhip47/nexdrive-backend

## Overview

1. This repo is a Spring Boot microservices system for “AppShala Drive,” a cloud document/media storage platform. The architecture is split into five deployable services plus shared platform infrastructure: API Gateway, Config Server, Eureka Server, User Service, User Group Service, and Storage Service.

2. The platform boundary is clearly service-oriented. Each service has its own Maven project, application entrypoint, tests, and domain model. That means deployment, scaling, and failure isolation happen per service rather than as one monolith.

3. `apiGateway` is the edge entrypoint. It sits in front of the backend services and is the place where client traffic is expected to be routed. In a diagram, it should be shown as the only public-facing service, with internal routing onward to the other services.

4. `eurekaServer` provides service discovery. The other services are designed to register and discover each other dynamically rather than hard-coding host locations. This is important for the cloud-native topology and horizontal scaling story.

5. `configserver` is the centralized configuration boundary. It externalizes service configuration so the runtime behavior of the services can be managed from one place instead of being embedded in each service. It is part of the platform control plane, not the business domain.

6. `userService` owns user lifecycle and profile-related business logic. Its structure includes a controller, service layer, repository, domain model, request/response payloads, validation/error handling, and a `MailService`. That suggests it handles user CRUD, user import/export or bulk operations, and user-facing notifications. It also defines a `UserDeletedEvent`, showing that user deletion is an event source for other services.

7. `userGroupService` owns groups, memberships, and authorization-like group membership rules. It has separate models for `UserGroup` and `Membership`, DTOs for requests/responses, repository and service layers, and enums for `MemberRole`, `GroupSortBy`, and `SortDirection`. It also contains a `UserServiceClient`, which indicates it calls back into the User Service for cross-service user information. The presence of `UserDeletedEventListener`/`Listner` indicates it reacts to user deletion events to clean up memberships.

8. `storageservice` is the storage integration layer. Its `S3config` and `PresignedUrlResponse` strongly indicate AWS S3 is the external persistence target for files, with the service generating presigned upload/download URLs rather than proxying file bytes itself. In the architecture diagram, this is the main boundary to an external cloud service.

9. The main business data flow is: client traffic enters the API Gateway, which routes to the appropriate service; User Service manages user records; User Group Service manages group/membership state and consults User Service when needed; Storage Service issues S3 presigned URLs for direct object storage access. The actual file content is therefore expected to move directly between the client and S3, while the Storage Service only handles authorization and URL issuance.

10. There is clear asynchronous coupling between services through domain events. User deletion is modeled as an event in User Service and consumed by User Group Service listeners, which implies eventual consistency for cross-service cleanup. This is a key architectural boundary: user state changes can propagate without synchronous orchestration.

11. There is also synchronous service-to-service communication via client abstractions. `GroupServiceClient` in User Service and `UserServiceClient` in User Group Service imply internal HTTP calls through service discovery rather than direct database sharing. That separation reinforces bounded contexts and avoids shared persistence.

12. The data layer appears service-local. Each business service has its own repository package, meaning each owns its own persistence boundary and schema. No shared database is visible in the tree, which is consistent with microservice isolation.

13. Common implementation patterns are Spring Boot controllers/services/repositories, payload DTOs for API contracts, enums for domain constraints, and global exception handling in User Service. These patterns make each service independently evolvable while keeping APIs explicit.

14. For an architecture diagram, the most important boxes and arrows are: public clients -> API Gateway; Gateway -> User Service / User Group Service / Storage Service; services -> Eureka for discovery; services -> Config Server for configuration; User Service -> User Group Service via events and client calls; Storage Service -> S3. The main boundary to emphasize is that the platform stores metadata in services but stores actual media in S3.

Main entry points: [`apiGateway/src/main/java/com/appShala/apiGateway/ApiGatewayApplication.java`](https://github.com/abhip47/nexdrive-backend/blob/main/apiGateway/src/main/java/com/appShala/apiGateway/ApiGatewayApplication.java) (API Gateway), [`userService/src/main/java/com/appshala/userService/Controller/UserController.java`](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Controller/UserController.java) (User API), [`userGroupService/src/main/java/com/appShala/userGroupService/Controller/UserGroupController.java`](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Controller/UserGroupController.java) (Group API), [`storageservice/src/main/java/com/appshala/storageservice/controller/StorageController.java`](https://github.com/abhip47/nexdrive-backend/blob/main/storageservice/src/main/java/com/appshala/storageservice/controller/StorageController.java) (Storage API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_edge["Edge"]
  node_clients(("Clients<br/>public callers"))
  node_gateway["API Gateway<br/>edge router"]
end

subgraph group_platform["Platform"]
  node_config["Config Server<br/>central config"]
  node_eureka["Eureka Server<br/>service discovery"]
end

subgraph group_users["User service"]
  node_user_api["User API<br/>controller layer"]
  node_user_core["User Logic<br/>service layer"]
  node_user_data[("User Store<br/>repository/model")]
  node_user_events(("User Events<br/>domain event"))
  node_user_mail["Mail Service<br/>notification<br/>[MailService.java]"]
end

subgraph group_groups["Group service"]
  node_group_api["Group API<br/>controller layer"]
  node_membership_api["Membership API<br/>controller layer"]
  node_group_core["Group Logic<br/>service layer"]
  node_membership_core["Membership Logic<br/>service layer"]
  node_group_data[("Group Store<br/>repository/model")]
  node_group_client["User Client<br/>internal client"]
  node_group_events(("Delete Listener<br/>event consumer"))
end

subgraph group_storage["Storage service"]
  node_storage_api["Storage API<br/>controller layer"]
  node_storage_core["Storage Logic<br/>service layer"]
end

subgraph group_external["External"]
  node_s3[("S3<br/>external object store")]
end

node_clients -->|"public traffic"| node_gateway
node_gateway -->|"routes"| node_user_api
node_gateway -->|"routes"| node_group_api
node_gateway -->|"routes"| node_storage_api
node_user_api -->|"uses"| node_user_core
node_user_core -->|"persists"| node_user_data
node_user_core -->|"notifies"| node_user_mail
node_user_core -->|"publishes"| node_user_events
node_group_api -->|"uses"| node_group_core
node_membership_api -->|"uses"| node_membership_core
node_group_core -->|"persists"| node_group_data
node_membership_core -->|"persists"| node_group_data
node_group_core -->|"calls"| node_group_client
node_group_events -->|"reacts"| node_group_core
node_user_events -.->|"event flow"| node_group_events
node_storage_api -->|"uses"| node_storage_core
node_storage_core -->|"issues URLs"| node_s3
node_gateway -.->|"discovers"| node_eureka
node_user_api -.->|"registers"| node_eureka
node_group_api -.->|"registers"| node_eureka
node_storage_api -.->|"registers"| node_eureka
node_gateway -.->|"loads config"| node_config
node_user_api -.->|"loads config"| node_config
node_group_api -.->|"loads config"| node_config
node_storage_api -.->|"loads config"| node_config
node_user_api -.->|"behind"| node_gateway
node_group_api -.->|"behind"| node_gateway
node_storage_api -.->|"behind"| node_gateway

click node_gateway "https://github.com/abhip47/nexdrive-backend/blob/main/apiGateway/src/main/java/com/appShala/apiGateway/ApiGatewayApplication.java"
click node_config "https://github.com/abhip47/nexdrive-backend/blob/main/configserver/src/main/java/com/appshala/configserver/ConfigserverApplication.java"
click node_eureka "https://github.com/abhip47/nexdrive-backend/blob/main/eurekaServer/src/main/java/com/appShala/eurekaServer/EurekaServerApplication.java"
click node_user_api "https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Controller/UserController.java"
click node_user_core "https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/ServcieImpl/UserServiceImpl.java"
click node_user_data "https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Repository/UserRepository.java"
click node_user_events "https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Event/UserDeletedEvent.java"
click node_user_mail "https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/ServcieImpl/MailService.java"
click node_group_api "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Controller/UserGroupController.java"
click node_membership_api "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Controller/MembershipController.java"
click node_group_core "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/UserGroupServiceImpl.java"
click node_membership_core "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/MembershipServiceImpl.java"
click node_group_data "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Repository/UserGroupRepository.java"
click node_group_client "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/client/UserServiceClient.java"
click node_group_events "https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/listener/UserDeletedEventListener.java"
click node_storage_api "https://github.com/abhip47/nexdrive-backend/blob/main/storageservice/src/main/java/com/appshala/storageservice/controller/StorageController.java"
click node_storage_core "https://github.com/abhip47/nexdrive-backend/blob/main/storageservice/src/main/java/com/appshala/storageservice/serviceImpl/StorageServiceImpl.java"

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_clients,node_gateway toneBlue
class node_config,node_eureka toneAmber
class node_user_api,node_user_core,node_user_data,node_user_events,node_user_mail toneMint
class node_group_api,node_membership_api,node_group_core,node_membership_core,node_group_data,node_group_client,node_group_events toneRose
class node_storage_api,node_storage_core toneIndigo
class node_s3 toneTeal
```

## Components

### Edge

Public entry and request routing

- **Clients**: public callers · Web, mobile, or API clients entering the platform
- [API Gateway](https://github.com/abhip47/nexdrive-backend/blob/main/apiGateway/src/main/java/com/appShala/apiGateway/ApiGatewayApplication.java): edge router · Single public-facing entrypoint that routes requests to backend services · `apiGateway/src/main/java/com/appShala/apiGateway/ApiGatewayApplication.java`

### Platform

Shared control-plane infrastructure

- [Config Server](https://github.com/abhip47/nexdrive-backend/blob/main/configserver/src/main/java/com/appshala/configserver/ConfigserverApplication.java): central config · Externalized configuration control plane for the services · `configserver/src/main/java/com/appshala/configserver/ConfigserverApplication.java`
- [Eureka Server](https://github.com/abhip47/nexdrive-backend/blob/main/eurekaServer/src/main/java/com/appShala/eurekaServer/EurekaServerApplication.java): service discovery · Registry used by services to discover each other dynamically · `eurekaServer/src/main/java/com/appShala/eurekaServer/EurekaServerApplication.java`

### User service

User lifecycle and profile domain

- [User API](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Controller/UserController.java): controller layer · HTTP boundary for user operations and imports · `userService/src/main/java/com/appshala/userService/Controller/UserController.java`
- [User Logic](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/ServcieImpl/UserServiceImpl.java): service layer · User lifecycle, validation, and orchestration logic · `userService/src/main/java/com/appshala/userService/ServcieImpl/UserServiceImpl.java`
- [User Store](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Repository/UserRepository.java): repository/model · User persistence boundary and domain model · `userService/src/main/java/com/appshala/userService/Repository/UserRepository.java`
- [User Events](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/Event/UserDeletedEvent.java): domain event · Publishes user deletion events consumed by other services · `userService/src/main/java/com/appshala/userService/Event/UserDeletedEvent.java`
- [Mail Service](https://github.com/abhip47/nexdrive-backend/blob/main/userService/src/main/java/com/appshala/userService/ServcieImpl/MailService.java): notification · User-facing email notification component · `userService/src/main/java/com/appshala/userService/ServcieImpl/MailService.java`

### Group service

Groups, memberships, and cross-user rules

- [Group API](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Controller/UserGroupController.java): controller layer · HTTP boundary for groups and memberships · `userGroupService/src/main/java/com/appShala/userGroupService/Controller/UserGroupController.java`
- [Membership API](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Controller/MembershipController.java): controller layer · HTTP boundary for membership operations · `userGroupService/src/main/java/com/appShala/userGroupService/Controller/MembershipController.java`
- [Group Logic](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/UserGroupServiceImpl.java): service layer · Group and membership orchestration logic · `userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/UserGroupServiceImpl.java`
- [Membership Logic](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/MembershipServiceImpl.java): service layer · Membership-specific business logic · `userGroupService/src/main/java/com/appShala/userGroupService/ServiceImpl/MembershipServiceImpl.java`
- [Group Store](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/Repository/UserGroupRepository.java): repository/model · Group and membership persistence boundary · `userGroupService/src/main/java/com/appShala/userGroupService/Repository/UserGroupRepository.java`
- [User Client](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/client/UserServiceClient.java): internal client · Synchronous calls from group service back to user service · `userGroupService/src/main/java/com/appShala/userGroupService/client/UserServiceClient.java`
- [Delete Listener](https://github.com/abhip47/nexdrive-backend/blob/main/userGroupService/src/main/java/com/appShala/userGroupService/listener/UserDeletedEventListener.java): event consumer · Consumes user deletion events for cleanup · `userGroupService/src/main/java/com/appShala/userGroupService/listener/UserDeletedEventListener.java`

### Storage service

Presigned URL access to object storage

- [Storage API](https://github.com/abhip47/nexdrive-backend/blob/main/storageservice/src/main/java/com/appshala/storageservice/controller/StorageController.java): controller layer · HTTP boundary for presigned URL operations · `storageservice/src/main/java/com/appshala/storageservice/controller/StorageController.java`
- [Storage Logic](https://github.com/abhip47/nexdrive-backend/blob/main/storageservice/src/main/java/com/appshala/storageservice/serviceImpl/StorageServiceImpl.java): service layer · Generates presigned upload and download URLs · `storageservice/src/main/java/com/appshala/storageservice/serviceImpl/StorageServiceImpl.java`

### External

Managed cloud dependency

- **S3**: external object store · AWS S3 holds actual file and media bytes

## Connections

- Clients → API Gateway: public traffic · Client requests enter through the gateway
- API Gateway → User API: routes · Gateway forwards user requests to the user service
- API Gateway → Group API: routes · Gateway forwards group requests to the group service
- API Gateway → Storage API: routes · Gateway forwards storage requests to the storage service
- User API → User Logic: uses · Controller delegates to service logic
- User Logic → User Store: persists · User logic reads and writes user records
- User Logic → Mail Service: notifies · User changes can trigger email notifications
- User Logic → User Events: publishes · User deletion emits a domain event
- Group API → Group Logic: uses · Controller delegates to group service logic
- Membership API → Membership Logic: uses · Controller delegates to membership service logic
- Group Logic → Group Store: persists · Group logic owns its persistence boundary
- Membership Logic → Group Store: persists · Membership logic stores membership state
- Group Logic → User Client: calls · Group service synchronously queries user service
- Delete Listener → Group Logic: reacts · User deletion events trigger membership cleanup
- User Events → Delete Listener: event flow · User service events are consumed asynchronously by group service
- Storage API → Storage Logic: uses · Controller delegates URL generation to storage logic
- Storage Logic → S3: issues URLs · Storage service generates presigned access for S3
- API Gateway → Eureka Server: discovers · Gateway resolves backend services through discovery
- User API → Eureka Server: registers · User service participates in service discovery
- Group API → Eureka Server: registers · Group service participates in service discovery
- Storage API → Eureka Server: registers · Storage service participates in service discovery
- API Gateway → Config Server: loads config · Gateway receives centralized configuration
- User API → Config Server: loads config · User service receives centralized configuration
- Group API → Config Server: loads config · Group service receives centralized configuration
- Storage API → Config Server: loads config · Storage service receives centralized configuration
- User API → API Gateway: behind · User API is only reachable through the gateway
- Group API → API Gateway: behind · Group API is only reachable through the gateway
- Storage API → API Gateway: behind · Storage API is only reachable through the gateway
