Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/webank ob description #42

Merged
merged 13 commits into from
Oct 28, 2024
100 changes: 99 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,99 @@
# webank-OnlineBanking
# Webank Online Banking System
### An Online banking system middleware service
## Table of Contents
- [Project Overview](#project-overview)
- [Features](#features)
- [Technologies Used](#technologies-used)
- [Prerequisites](#prerequisites)
- [Installation Instructions](#installation-instructions)
- [Usage](#usage)
- [Project Documentation](#project-documentation)
- [Development and Contribution](#development-and-contribution)
- [License](#license)
- [Contact Information](#contact-information)
- [Acknowledgements](#acknowledgements)

---

## Project Overview

The **Webank Online Banking System** is a middleware service designed to connect the frontend applications with a core banking system, providing a seamless online banking experience for users. The system consists of various modules to manage key functionalities such as user registration, account management, OTP verification, and access control.

### Key Modules
- **OBS (Online Banking Service)**: Orchestrates requests for registration and OTP verification, forwarding them to the appropriate backend modules.
- **PRS (Personal Registration Service)**: Manages user registration and OTP verification.
- **DAS (Deposit Account Service)**: Handles account creation and balance management.
- **AAS (Account Access Service)**: Manages account access and authorization.
- **SMS Gateway**: Sends OTPs to users for verification purposes.

## Features
- **User Registration**: Users can register by providing their phone numbers and public keys.
- **OTP Verification**: Secure one-time passwords are sent to users’ phones to verify identity.
- **Account Management**: Once registration is complete, users can create bank accounts, check balances, and view transaction histories.
- **Scalable Microservices Architecture**: Each service is designed as an independent microservice, allowing for modularity and scalability.

## Technologies Used
- **Backend**: Spring Boot for the OBS, PRS, DAS, and AAS modules.
- **Database**: PostgreSQL (or any preferred database system) for secure data storage.
- **API Documentation**: OpenAPI for standardized API documentation.
- **Messaging and SMS**: Integrated SMS gateway for OTPs.

## Prerequisites
- **Java 11+**: Required to run the Spring Boot applications.
- **Maven**: Used for project dependency management.
- **Docker** (optional): For containerization and easier deployment.
- **PostgreSQL**: As the primary database for storing user and account data.

## Installation Instructions
1. **Clone the Repository**:
```bash
git clone https://github.com/yourusername/webank-online-banking-system.git
cd webank-online-banking-system
```
2. **Run Database Migration**:
- Ensure PostgreSQL is running and create necessary databases and tables (migration scripts are included in the `db/migrations` folder).

3. **Build and Run Services**:
```bash
mvn clean install
mvn spring-boot:run
```

5. **Access API Documentation**:
- The OpenAPI documentation will be available at `http://localhost:8080/swagger-ui.html` (or the port specified for each module).

## Usage
- **User Registration**:
- Make a `POST` request to `/register` with `phoneNumber` and `publicKey`.
- Receive an OTP on the provided phone number.
- **OTP Verification**:
- Verify OTP by making a `POST` request to `/verify-otp` with the OTP and public key.
- **Account Management**:
- Access endpoints for balance inquiries, transfers, and account details.

For a detailed guide on using each endpoint, refer to the [API Documentation](#project-documentation) section.

## Project Documentation
The architecture documentation and API specifications are available in the `docs` folder. The documentation includes:
- **Architecture Overview**: Detailed information on how OBS interacts with PRS, DAS, and AAS.
- **API Reference**: List of available endpoints, request payloads, and response formats.
- **Security Considerations**: Overview of authentication and data encryption practices.

## Development and Contribution
We welcome contributions! Please follow these steps:
1. Fork the repository and create a new branch for your feature or bug fix.
2. Follow our [contribution guidelines](CONTRIBUTING.md) for best practices.
3. Submit a pull request detailing your changes.

## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Contact Information
For questions or support, please reach out to:
- **Email**: [Adorsys]([email protected])
- **GitHub Issues**: [Submit an issue](https://github.com/ADORSYS-GIS/webank/issues)

## Acknowledgements
- Thanks to the adorsys development team for their contributions.
- Special thanks to the contributors and libraries that supported this project.
- Special thanks to the development team and contributors for their support and dedication in building this project.
13 changes: 5 additions & 8 deletions obs/obs-rest-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,25 @@
</dependency>

<!-- Swagger Annotations -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId>
<version>2.2.22</version>
<scope>compile</scope>
</dependency>


<!-- Spring Boot Starter for Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.1.4</version>
<scope>compile</scope>
</dependency>

<!-- Spring Boot Starter for Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
</dependencies>

</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018-2024 adorsys GmbH and Co. KG
* All rights are reserved.
*/

package com.adorsys.webank.obs.resource;

import com.adorsys.webank.obs.dto.RegistrationRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/api/registration")
public interface RegistrationResourceApi {

@Operation(summary = "Register a new bank account", description = "Accepts a phone number and public key for registration")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Registration successful"),
@ApiResponse(responseCode = "400", description = "Invalid input")
})
@PostMapping
ResponseEntity<String> registerAccount(
@RequestBody RegistrationRequest registrationRequest
);
}
14 changes: 13 additions & 1 deletion obs/obs-rest-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adorsys.webank</groupId>
<artifactId>obs-service-api</artifactId>
Expand All @@ -43,7 +48,14 @@
<version>${project.version}</version>
</dependency>

<!-- Test dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- Other existing dependencies -->
</dependencies>

</project>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.adorsys.webank.obs.resource;

import com.adorsys.webank.obs.dto.RegistrationRequest;
import com.adorsys.webank.obs.service.RegistrationServiceApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/registration")
public class RegistrationResource implements RegistrationResourceApi {

@Autowired
private RegistrationServiceApi registrationService;

@Override
@PostMapping
public ResponseEntity<String> registerAccount(@RequestBody RegistrationRequest registrationRequest) {
String result = registrationService.registerAccount(registrationRequest);
return ResponseEntity.ok(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.adorsys.webank.obs.resource;

import com.adorsys.webank.obs.dto.RegistrationRequest;
import com.adorsys.webank.obs.service.RegistrationServiceApi;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;

public class RegistrationResourceTest {

@InjectMocks
private RegistrationResource registrationResource; // Class under test

@Mock
private RegistrationServiceApi registrationService; // Mocked dependency

@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
}

@Test
void registerAccount_ShouldReturnSuccessfulResponse() {
// Arrange
RegistrationRequest registrationRequest = new RegistrationRequest();
registrationRequest.setPhoneNumber(1234567890);
registrationRequest.setPublicKey("testPublicKey");

String expectedResponse = "Registration successful";
when(registrationService.registerAccount(registrationRequest)).thenReturn(expectedResponse);

// Act
ResponseEntity<String> responseEntity = registrationResource.registerAccount(registrationRequest);

// Assert
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertEquals(expectedResponse, responseEntity.getBody());
}
}
1 change: 1 addition & 0 deletions obs/obs-service-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>


</dependencies>


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.adorsys.webank.obs.dto;

public class RegistrationRequest {

private int phoneNumber;
private String publicKey;

// Getters and Setters

public int getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(int phoneNumber) {
this.phoneNumber = phoneNumber;
}

public String getPublicKey() {
return publicKey;
}

public void setPublicKey(String publicKey) {
this.publicKey = publicKey;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.adorsys.webank.obs.service;

import com.adorsys.webank.obs.dto.RegistrationRequest;

public interface RegistrationServiceApi {
String registerAccount(RegistrationRequest registrationRequest);
}
1 change: 1 addition & 0 deletions obs/obs-service-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
</exclusions>
<scope>test</scope>
</dependency>

</dependencies>

</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.adorsys.webank.obs.serviceimpl;

import com.adorsys.webank.obs.dto.RegistrationRequest;
import com.adorsys.webank.obs.service.RegistrationServiceApi;
import org.springframework.stereotype.Service;

@Service
public class RegistrationServiceImpl implements RegistrationServiceApi {

@Override
public String registerAccount(RegistrationRequest registrationRequest) {
int phoneNumber = registrationRequest.getPhoneNumber();
String publicKey = registrationRequest.getPublicKey();

// Add logic for registering the account with phoneNumber and publicKey

return "Registration successful for phone number: " + phoneNumber; // Return message including the phone number
}
}
Loading