Bank is a huge project. It is a management system to support the virtual economy in summer camp for more than 130 users every year.
Here is a table of content:
Idea
Bank is a web app that holds individual accounts of more than 130 users with different permissions. It allows it’s users to issue and transfer money and live within the virtual economic system in the Summer Physical and Mathematical School (SPMS).
Features
From Student account students can:
- See their current balance and transaction history.
- See their attendance counters and the required number of attendance for each type of activity.
- Request to transfer money to a fellow student.
- See files from the global cloud.
Staff members have different permissions and can do much more:
- See balance, attendance and transaction history for any student in the camp.
- Create transactions to issue virtual currency to any student or group of students.
- Each transaction should have one of 12 types (e.g. Seminar, Activity-winners, Generic Help, e.t.c.)
- Each of the 12 types of transactions has different logic applied to it.
- After creation transactions could be altered, canceled or used as a template for new ones.
- Charge money from students for fines and purchases.
- Increment students’ attendance counters.
- Add files to the global cloud.
- Approve money transfers for students.
- See aggregated statistics on the current market state in the camp.
- Generate reports with detailed per-student statistics on balances and attendance.
There is also a role of Bank Manager, who, in addition to regular staff actions, can also:
- See transaction history for each staff member.
- Cancel transactions of other staff members.
- See an aggregate table of all transactions happen and sort it on different columns.
From the technical side bank also has:
- API for Mobile App!
- Scripts for automatic deployment.
- Automatic tax charging with cron.
Tech
Bank is written in Python and relies deeply on Django-Framework. Besides that, I also used:
- Nginx and uwsgi as a server.
- Docker and Docker Compose for containerization and deployment.
- JQuery for AJAX and lazy-load of some pages.
- Bootstrap for frontend work.
- PostgreSQL is the database.
Data Model
Data Model for transactions can be difficult to grasp, but it provides great flexibility and tolerance to changes in economy game rules.
Principal Data Model looks like this:
Here:
- (A) - Is abstract classes (not a table).
- (S) - Static tables. Populated when app is deployed and then never changed.
- (M) - Regular tables.
- (D) - Django provided User model.
API
In 2018 one guy offered me to make an Android application for the student interface of Bank. I agreed and developed the following REST API endpoints to serve application needs:
POST: /bank_api/login – checks user credentials and returns session.
GET: /bank_api/user – checks the session info and returns user and transactions information for the logged in user.
GET: /bank_api/users – returns basic info about all students in the system.
POST: /bank_api/add_transaction – checks validity of transaction and adds money transfer request into the DB.
Project succeeded and Android application functioned on SPMS session in 2018.
There is also a couple of endpoints for data exportation for external analysis. They are only available to users with a Bank Manager role.
GET: /bank_api/money – returns information about all money transactions in the system.
GET: /bank_api/counters – returns information about all counter transactions in the system.
Deployment
In 2019 I decided to automate deployment process and dockerize the application.
Now it can be deployed with a single docker-compose up
command.
More detailed information about an exact deployment and setup procedure can be found in GitHub repo readme.
Achievements and Metrics
App was successfully deployed and used on every session of Summer Physical and Mathematical School since 2016. During that period it:
- Was used by more than 400 students and 100 staff members.
- Processed over 10 000 individual transactions.
- Eliminated paperwork related to the economics game completely.
- Allowed SPMS to be run by smaller number of people, by eliminating bank specialist role.
- Was mentioned in grant application that resulted in over $1500 donation to the SPMS program.