Skip to content

Instantly share code, notes, and snippets.

@EGOR-IND
Last active August 31, 2021 07:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EGOR-IND/e13db2d9bcbb221d46741ec3644e800c to your computer and use it in GitHub Desktop.
Save EGOR-IND/e13db2d9bcbb221d46741ec3644e800c to your computer and use it in GitHub Desktop.
GSoC'21 Project Report - Fineract-CN Mobile Wallet

Google Summer of Code 2021

apchelogo gsoc_logo mifos_logo



Fineract-CN Mobile Wallet

Fineract-CN Mobile Wallet is an Android-based framework for digital wallet use cases based on top of the Apache Fineract-CN platform, it is a new framework that is added to our list of great projects this year. The tagert of this project is to create a framework that follows the clean architecture, a core library module which can be used as a dependency in any other wallet based project and a reference application to demonstrate all these use cases.

Project Mentors:

Project Architecture



The whole project follows clean architecture which is currently the best choice for KMM(Kotlin Multi-platform Mobile). I haven't used KMM in this project but still we're making the project more KMM-sided, so that we can use KMM in future. The project contains mainly three layers of architecture.

  • The Presentation Layer: The presentation layer is the user layer, the graphical interface that captures the user’s events and shows the results. It also performs operations such as verifying that there are no formatting errors in the user’s data entry and formatting data to be displayed in a certain way.

  • The Domain Layer: This is the layer where we apply the bussiness rules, like, recieving data from user and performing necessary operations.

  • The Data Layer: In this layer is where the data is and where it can be accessed. Here we write the logic to make network requests, fetching data from database, and repository, i.e., a layer that performs the logic of data access.

Work Done

  • Created data layer in core library
  • Created domain layer in core library
  • Created unit tests for the usecases in doamin layer
  • Created Presentation Layer for android app

1. Created data layer in core library[Pull Request - link]

The data layer in Fineract-cn mobile wallet is divided between repository and data source(data -> network).

  • Data Source: The data source is made up of the network services and entities. The network services are made by Ktor client, Ktor is an asynchronous framework for creating microservices, web applications, and more, and we needed Ktor client for making requests to the APIs. Ktor client is asynchronous, main-safe and best choice for KMM projects. The entities are simple data classes that holds data for data layer. The services created using ktor clint uses entities and kotlinx serialization to store data in data layer. The below given steps describes the whole process,

    • Ceate the Ktor http client and pass suitable engine to it, in our case android engine.
    • Add kotlinx serialization's json serialization feature to the JsonFeature of Ktor http client.
    • Make the entities serializable using @Serializable, so that ktor can directly store data in entities parameter corresponding to json data keys.
    • Create services using Ktor request methods and http client.
  • Repository: The Repository layer is the one that performs the logic of data access. In our project architecture, our data layer repository implements the repository interface located in domain layer. I will give the explanation behind it later in domain layer portion. Our repository uses API manager that provides every service we created and through that repository perform various data operations.

2. Created domain layer in core library[Pull Request - link]

The domain layer implements the bussiness rules, our domain is consists of repository interface, models and use cases. The reason behind making an interface of repository, and implementing it in data layer is that the implemented repository is one of the most unstable class, and the usecases are supposed to be the most stable as the clean architecture is a use case driven architecture.

  • Models: The models are simple data classes that are almost similar to our entities, only difference between models and entities is that entities are made to map the data from network to an object, and models typically represents a real world object that is related to the problem or domain space.

  • Use cases: A use case can be represented as a bussiness rule, they are responsible for all the interactions that happens between the presentation layer and data layer. Right now, the domain layer contains use cases for

    • creating, updating and fetching customers
    • fetching deposit accounts and products
    • fetching journal entries
    • authenticating and registering the client Currently, the use cases handles the mapping between entities and models, executing the repository methods of particular events and returns the result for presentation layer.

3. Created tests for core library[Pull Request - link]

The tests in the core library tests the full process of the core library, from initiating the coroutines for uses cases to fetching data using Ktor services. I used a mock Ktor client that uses mock engine for mocking the responses for the requests and a mock API manager that actually provides Ktor client for making requests.

  • Mock Ktor Http Client: Ktor provides a brilliant feature of mock engine for testing the services created. By passing mock engine we can set responses for all the requests made by services. So, I used mock engine and a mock data object, that holds various responses for the requests, for making a mock Ktor client.

  • Mock API Manager: The original API manager is the one that was providing Ktor services to the repository. In API manager's createAuthenticatedService() method the Ktor client is getting initialized so to use the mock client I had to make the class open for overriding createAuthenticatedService() in MockApiManager to pass mock client to the services.

I used JUnit, coroutine-test and kotlin-test for building the unit tests. For the lint checking and formatting I used ktlint, ktlint is a kotlin linter with a built-in formatter and it's very easy to use, just enter gradlew ktlintCheck for checking the kotlin formatting of your code and gradlew ktlintFormat for formatting the code. So, all this together completes the testing part of the core library.

4. Created Presentation Layer for android app[Pull Request - link]

The Presentation Layer of Fineract-CN Mobile Wallet mainly contains the UI controller(activities and fragments for android app) and ViewModels for data persistence in android app. As I mentioned earlier, clean architecture is a usecase driven architecture and that's why the UI is made according to the usecases. So the the Presentation Layer currently fulfills the UI for,

  • Authentication Usecase: The UI for the authentication usecase consists of a login fragment that allows client to authenticate themselves before using the wallet service.
Login Screen
  • Registration Usecase: The UI for the registration usecase consists of a fragment for sign up procedure to allow client submit the required information for making an account.
Sign Up Screen
  • Client's Personal Info Usecase: This UI fulfills the requirement for displaying the client's personal info that client submitted during sign up.
Personal Info Screen
  • Client's Account Info Usecase: This UI fulfills the requirement for displaying the client's account info that was generated after the client registered on the app.
Account Info Screen
  • Transfer Usecase: This UI covers the interface for transfer usecase, which basically allows client to transfer money via VPA or phone number. The UI for this usecase is still pending becuase we use Payment Hub for tranfer operations and the Payment Hub integration is still pending.
Transfer Screen
  • Transaction History Usecase: This UI covers the interface to display the transactions made by client's account.
Transaction History Screen
  • Splash and Home Screen: The Splash and Home screen UI are the components to make the whole application flow smooth and presentable.
Splash Screen Home Screen Navigation Drawer

The End Product

Here is a sample of the end product and how the whole application flow works,

End Product

To test the Fineract-CN Mobile Wallet Application visit this link - APK

Future Goals

It was an amazing experience working with the Mifos Initiative on Fineract-CN Mobile Wallet and I believe we achieved a lot during this GSoC journey but still, I think there's a lot of scope of improvements and for adding new features, some of them are given below,

  • First necessary feature is Payment Hub integration.
  • Second necessary feature is Fineract-CN self service API integration.
  • As Fineract-CN Mobile Wallet was made while keeping KMM in mind, so the third big upgrade in the project can be the IOS app support.
  • Other features to expand the scope of the app could be Standing Instructions generation, KYC, Reciept generation, FAQ page, Invoices, dark theme support, etc.

I hope to continue working with the Mifos Initiative in the future and complete this task and help the other community members from my experience.

Conclusion

The Google Summer of Code journey with the Mifos Initiative has been pretty amazing and challenging both. I had a great time learning new things and working with other community members in a collaborative environment to develop and work on an amazing project. I would like to thank Ed Cable especially for always being available and managing all the things, my mentor Devansh Aggarwal for their guidance and support, and Fintecheando team for providing all the required things and helping me with all my doubts.

Thank You
Regards
Kinar Sharma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment