Melton App Backend
Melton App is an app used by the members of Melton Foundation. This is also the first time I got an opportunity to get involved in an open source project, potentially used by a few hundred people, right from the inception phase.
The core features of the application included:
- User Management
- Ability for members to buy 'items' from a store using points.
- Content management for admins for writing posts that are visible to all members.
I mostly worked only on the backend part. So I will describe each of these from the API perspective and not the Mobile app. Along with API, admin users also get access to a dashboard (which directly talks to database and services) where certain actions can be done.
User management was the most complex part of the whole application, because of its interactions in various use cases. User management can be again split into:
- Registration and Authentication system
- User profile
- User Directory
Registration and Authentication system
A melton user can register using an email. This email is stored in the database and a notification email is sent to admins for approval. If the user is found to be an actual Melton fellow, once the admin approves the user becomes active in the system. A user can login to the application using either Google Sign-in or Apple Sign-in depending on the phone being used. On backend side Google Oauth and Apple Oauth is used to verify whether the user's email is registered and activated by the admin (manually). Apart from the login, the application also picks up the profile picture of the user from Google account and stores it in an S3 bucket as the default profile picture. The admins also have a login system using password for the Django dashboard.
Since this is a REST API, we need to verify every request being made. So once the first login is successful, a token is generated and sent the app. All future calls from the app should have this token. The token also has a timeout limit, if no request is made within a set amount of time, the token is considered invalid and the user has to login again.
This set of API allows the user to view or edit their profile. Apart from few details like the email Id used to register, most of the details can be updated by the user any number of time. Another requirement was for the admins to be able to award 'Points' to Melton fellows upon completion of certain tasks. The admins can login to the dashboard and view or edits Points of different users either in bulk or individually. These points will be used for transaction on Store (described below).
The users also have the ability to search or browse other Melton fellows and see their profile (slightly limited information is made public). The app shows a list of all users or filtered list of users based on search keyword (search is enabled on Name, Email). Once the user picks any particular profile, all the details for the seleted profile is retrieved. Since there can be lot of users, the first API retrieving all or subset of users does not have all the fields. Only when a particular profile is selected all the data is retrieved based on its ID.
Admins can add 'Items' to the Store that can be bought with the 'Points', awarded to Melton fellows on completing tasks. The users can view all the items present in the store. Based on their available points the system ensures that only valid transactions are possible. Each transaction is also stored in database for record keeping. Once an admin deems that the 'Item' in store is not valid, he/she can disable the item in the dashboard and prevent it from being accessible to users.
Admins can create posts on the dashboard that are then shown to the users. These posts can be rich text including images. Its written as markdown, so only plain text is stored in database, but a preview of markdown rendered is shown as and when admin is typing. Thanks to the library, 'django-markdownx' all the functionality required to render markdown was easily available. The images uploaded to the post are again stored in S3 bucket automatically. Admins can also add tags to each post to give more information about the post. Users can also search for a post using keyword which will be searched in post's title, description and tags.
- App Website: https://meltonapp.com/
- API Doc: https://meltonapp.com/api/docs/
- Github Link for Backend: https://github.com/melton-foundation/Melton-App-Server
- Github Link for Frontend: https://github.com/melton-foundation/Melton-App-Client-Flutter