Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
de34aa1
Feature flask s3 end to end process (#53)
danielpnorris Sep 16, 2023
e085109
Update Chatbot AI disclaimer (#55)
CRussoDeakin Sep 17, 2023
1a69eaa
Moved tests for aws stuff
SDzartov Sep 17, 2023
00cda25
moved aws tests
SDzartov Sep 17, 2023
2203b6b
Feature front responsive footer (#56)
Aditya-Rajgor Sep 17, 2023
1a045f4
Add latest pr manually
SDzartov Sep 17, 2023
6dac965
Created anomaly detection model (#54)
PradiptaDutta63 Sep 17, 2023
27b0256
Feature front news responsive (#58)
Aditya-Rajgor Sep 17, 2023
917eefc
Home Responsive Completed (#59)
itsboxy Sep 18, 2023
f557e9c
Added the function for chatbot to fetch the data from the CSV (#60)
axeshpatel Sep 18, 2023
dd3d2cf
Update transactions_ut.db
SDzartov Sep 19, 2023
4627d8d
added path
SDzartov Sep 19, 2023
fdab88b
fixed pathing issue for new chatbot.
SDzartov Sep 19, 2023
cc26e09
Removed outside db
SDzartov Sep 19, 2023
6b93754
Feature flask aws replacement (#62)
SDzartov Nov 5, 2023
30d2dc4
Update requirements.txt
SDzartov Nov 5, 2023
72c2eba
Update requirements.txt
SDzartov Nov 5, 2023
99d2932
Update requirements.txt
SDzartov Nov 5, 2023
fa8b56a
Update requirements.txt
SDzartov Nov 5, 2023
42f7b4f
Update requirements.txt
SDzartov Nov 5, 2023
19a6f12
Onboarding Environment
chris-gao-36 Nov 13, 2023
b2605c2
Update README.md (#64)
Jezza12345 Nov 14, 2023
df8991e
Feature flask dashboard 2.0 (#66)
SDzartov Nov 16, 2023
73330eb
Added foundation code for dolfin_analytica data science dashboard. (#67)
SDzartov Nov 16, 2023
e72f75f
Update README.md
SDzartov Nov 16, 2023
3d7be57
Update README.md
SDzartov Nov 16, 2023
d6bebd8
Update README.md
SDzartov Nov 16, 2023
f085e02
expenditure_visualization_prototype (#69)
userstarwind Nov 16, 2023
e4ba714
expenditure_pattern_visualization_web_prototype (#70)
userstarwind Nov 17, 2023
48a580a
Added CSS for highlighting active pages
benD02 Nov 17, 2023
f03ceb8
feature_FRONT_update_login (#71)
chris-gao-36 Nov 18, 2023
323c0af
Fixed db commit bug
SDzartov Nov 18, 2023
68ec82f
Added loading page template and Flask logic (#72)
alkatra Nov 18, 2023
5630d8d
Create auto_kmeans.py (#75)
userstarwind Nov 19, 2023
66fe50a
Added Geo Lock middleware restricting DolFin to Australia (#73)
alkatra Nov 19, 2023
5f2d173
Update user_database.db
Was8gm Nov 20, 2023
c0db6bf
update
Was8gm Nov 20, 2023
8420100
Feature front das hv2 css (#81)
SDzartov Nov 20, 2023
aa8ad8d
New Branch with the latest DolFin (#80)
Was8gm Nov 20, 2023
d3b5d18
Create reinforcement_cloud.py (#82)
939781369 Nov 20, 2023
481ac3f
styled login page (#83)
fbhatti97 Nov 20, 2023
2f2b18c
Address fields to registration page
benD02 Nov 20, 2023
2164bb7
conflict solved
deaselWeasel Nov 20, 2023
08a75cb
Revert "conflict solved"
deaselWeasel Nov 20, 2023
26a3acd
Feature new test user data (#88)
userstarwind Nov 21, 2023
754dd5d
Create auto_setup_fake_account.py (#87)
userstarwind Nov 21, 2023
daa81ad
Updated user datbase with test users (#93)
wongaid Nov 22, 2023
48c617d
Extend Jiangjun Kai's expenditure_ Pattern_ Visualization_ Prototype …
Was8gm Nov 22, 2023
b7709df
Feature front login responsive (#90)
Aditya-Rajgor Nov 22, 2023
0c0016d
Feature front article content creation (#91)
washyking Nov 22, 2023
e3f9225
Design and functionality adjustments to FAQ page (#84)
damonrimanic Nov 22, 2023
f2fae5c
Fixed db bug
SDzartov Nov 22, 2023
e106220
Feature front chatbot css (#95)
Aditya-Rajgor Nov 23, 2023
ac96240
Implementing cleaning of user transaction data (#94)
Jensen-T Nov 23, 2023
8d8250e
Update FAQ.html (#96)
SDzartov Nov 23, 2023
85c67f5
fixed links on navbar
SDzartov Nov 23, 2023
103c8e6
Added initial page structure to project (#97)
SDzartov Nov 23, 2023
9ffad8c
Merge branch 'feature_FRONT_navbar_design-' into develop
benD02 Nov 24, 2023
f59d772
Merge branch 'feature_FLASK_AddressFields' into develop
benD02 Nov 24, 2023
bd5b90c
Add files via upload
mazyhehe Nov 24, 2023
47d142b
register styled (#106)
Aditya-Rajgor Nov 24, 2023
3363fac
fixed the faq responsive (#105)
Aditya-Rajgor Nov 24, 2023
53d7a0c
Update .gitignore
SDzartov Nov 25, 2023
e1e7203
Update .gitignore
SDzartov Nov 25, 2023
aa9e3de
Create .gitignore
SDzartov Nov 25, 2023
c707c6b
Delete transactions_ut.db
SDzartov Nov 25, 2023
560fdc2
Feature front update profile (#101)
denicahh Nov 25, 2023
c0036a4
Feature flask update profile (#100)
denicahh Nov 25, 2023
f199b63
Feature front resetpw (#99)
denicahh Nov 25, 2023
8c968c7
Added CSS for highlighting active pages (#103)
benD02 Nov 25, 2023
22d8af4
Address fields to registration page (#104)
benD02 Nov 25, 2023
6052f78
Feature back user database entries (#98)
Apparmar Nov 25, 2023
9761491
Added logging of Registration and Login attempts to Database (#74)
alkatra Nov 25, 2023
d189c23
Feature front register new styled (#109)
Aditya-Rajgor Nov 25, 2023
5617fd4
Update .gitignore
SDzartov Nov 25, 2023
eb4d1fa
Update .gitignore
SDzartov Nov 25, 2023
28215b4
Update .gitignore
SDzartov Nov 25, 2023
9ced845
Delete .DS_Store
SDzartov Nov 25, 2023
dc3f329
Delete config.py
SDzartov Nov 25, 2023
9b9d32b
Update reinforced_cloud.py
mazyhehe Nov 26, 2023
49cbf6d
Added GCP setup (#118)
SDzartov Nov 27, 2023
df621b0
Update app.py
SDzartov Nov 27, 2023
b5f28f0
Update requirements.txt
SDzartov Nov 27, 2023
eaf6c26
Update requirements.txt
SDzartov Nov 27, 2023
94e555e
Update requirements.txt
SDzartov Nov 27, 2023
eab1f1e
Update requirements.txt
SDzartov Nov 27, 2023
5b80173
Update app.py
SDzartov Nov 27, 2023
96d4c71
Update app.py
SDzartov Nov 27, 2023
70b7272
Update navbar.html
SDzartov Nov 27, 2023
6fb5938
Update
benD02 Nov 27, 2023
f5f5661
Update
benD02 Nov 27, 2023
cb270cf
redoing basiq API part1 (#120)
userstarwind Nov 28, 2023
2aca2d1
NOT FINISHED Front/Back end development for the profile page
benD02 Nov 28, 2023
ffb67d0
Updated Footer (#115)
ywaliatin Nov 29, 2023
3d49a8a
Added CSS for Dashboard + Responsiveness for added elements (#122)
damonrimanic Nov 29, 2023
8e03cd4
Added audit logs to user database and to audit.txt (#113)
alkatra Nov 29, 2023
a44a525
Added password hashing using bcrypt (#114)
alkatra Nov 29, 2023
040338b
Fixed register route duplication
wongaid Nov 29, 2023
45f446d
Feature flask implement random forest (#116)
mjsaeed Nov 29, 2023
82d10a0
fixed encode bytes conflicts (#126)
wongaid Nov 30, 2023
829ec99
add libs
SDzartov Nov 30, 2023
5b2b32d
Update requirements.txt
SDzartov Nov 30, 2023
1b94aa8
user_db mapping + upper limit to test csv ranges
wongaid Nov 30, 2023
358aec6
Feature_reconfigure_expenditure_cluster_model_into_callable_unction (…
939781369 Dec 1, 2023
68dab47
New total_balance variable (#124)
jack-gen Dec 1, 2023
0aca470
Feature front register res (#125)
Aditya-Rajgor Dec 1, 2023
b6bf1d9
Survey (#127)
washyking Dec 1, 2023
77b5faf
Feature redo basiq api part2 (#129)
userstarwind Dec 1, 2023
a14eba2
BE: Session [] variables are to be used across the application (#117)
chris-gao-36 Dec 2, 2023
cc65caa
Added support for Address Fields in Backend & Database (#112)
alkatra Dec 2, 2023
9bc77c5
Revert "Added support for Address Fields in Backend & Database (#112)"
SDzartov Dec 2, 2023
63300b7
Revert "BE: Session [] variables are to be used across the applicatio…
SDzartov Dec 2, 2023
9201b84
BE: Add a /signout route and process to remove the session informatio…
chris-gao-36 Dec 2, 2023
2a82cdf
GCP deployment working & tested
SDzartov Dec 3, 2023
bebcc41
Update .gitignore
SDzartov Dec 3, 2023
ffd5f4a
Added client-side Address Validation to the Register Form using Addre…
Jezza12345 Dec 3, 2023
057f1e7
Merge branch 'develop' of https://github.com/DataBytes-Organisation/N…
benD02 Dec 6, 2023
efd98d3
Merge branch 'develop' of https://github.com/DataBytes-Organisation/N…
benD02 Dec 6, 2023
bfb7286
Merge branch 'develop' of https://github.com/DataBytes-Organisation/N…
SDzartov Dec 6, 2023
2c79561
Revert "Merge branch 'develop' of https://github.com/DataBytes-Organi…
SDzartov Dec 6, 2023
7af1242
Revert to 2/12
SDzartov Dec 7, 2023
0d6d11c
Merge branch 'develop' of https://github.com/DataBytes-Organisation/N…
SDzartov Dec 7, 2023
cace3c3
Undo damaged develop
SDzartov Dec 7, 2023
803457f
Added client-side Address Validation to the Register Form using Addre…
Jezza12345 Dec 7, 2023
4fee403
Create test.txt
SDzartov Dec 7, 2023
b4981e9
Actively Pull data from Basiq API (#149)
wongaid Dec 7, 2023
6b6c333
New HTML Article (#148)
JamieChau16 Dec 7, 2023
62e0b63
reconfigure_wordcloud_into_callable_function (#142)
userstarwind Dec 7, 2023
a01bd58
Add files via upload (#146)
jack-gen Dec 7, 2023
44cadd1
feature_optimized_expenditure_cluster_model_with_annotation (#139)
userstarwind Dec 7, 2023
89d761a
FLASK analytica login page (#141)
washyking Dec 7, 2023
35288b0
Update main.yml
SDzartov Dec 7, 2023
b269074
AddressValidation server-side flask changes (#150)
GayatrideviPakki Dec 7, 2023
f5e415a
Expense_Categorisation_example_code (#151)
939781369 Dec 7, 2023
0c57fcb
Feature frontend Update (#138)
benD02 Dec 7, 2023
d50489d
ignored problematic PR files.
SDzartov Dec 7, 2023
a510223
Update user_database.db
SDzartov Dec 7, 2023
cd5db5d
review
SDzartov Dec 7, 2023
6d67ea3
audit resolved (#140)
Aditya-Rajgor Dec 7, 2023
abc3f74
Create Bill_Payment_Reminders_Table_Output.ipynb (#152)
JamieChau16 Dec 7, 2023
59f51ec
Redesigned the News page (#157)
GimsaraK Dec 8, 2023
2bbf5a2
Feature flask feedback prototype (#155)
benD02 Dec 8, 2023
a5cf323
connect expenditure visualization model (#158)
userstarwind Dec 8, 2023
365d85f
Update functions.py
SDzartov Dec 8, 2023
03ce690
Footer for Analytica (#160)
damonrimanic Dec 8, 2023
af5f0ca
Flask survey page json (#154)
washyking Dec 8, 2023
2a360f4
Create Random_Forest_Model.ipynb
KailasThonnithodi-2002 Dec 8, 2023
fe8ad90
Revert "Create Random_Forest_Model.ipynb"
KailasThonnithodi-2002 Dec 8, 2023
4e29146
random forest model
KailasThonnithodi-2002 Dec 8, 2023
94d5810
another predictive model
KailasThonnithodi-2002 Dec 8, 2023
946a548
chatbot final (#163)
atacolak Dec 8, 2023
8f8f2ae
Feature flask feedback prototype (#161)
benD02 Dec 8, 2023
9277189
Build Data Analysis Models: Savings Goals Predictions (#164)
jack-gen Dec 8, 2023
af69da6
updated faq page (#166)
fbhatti97 Dec 9, 2023
0dce4af
background color fixed (#167)
Aditya-Rajgor Dec 9, 2023
1fdde40
Feature front new add valid fix (#168)
Aditya-Rajgor Dec 9, 2023
74f812c
Feature flask feedback prototype (#169)
benD02 Dec 9, 2023
7e713bc
Merge branch 'develop' of https://github.com/DataBytes-Organisation/N…
KailasThonnithodi-2002 Dec 9, 2023
fe62a78
Revert "Merge branch 'develop' of https://github.com/DataBytes-Organi…
KailasThonnithodi-2002 Dec 9, 2023
7c09f75
Updated file structure for api folder
SDzartov Dec 10, 2023
ba62bbd
argon2id Password Hashing (#170)
wongaid Dec 10, 2023
0ecd874
Feature flask feedback prototype (#171)
benD02 Dec 10, 2023
3a2bdcf
Returned to argon hashes
wongaid Dec 10, 2023
540cc4a
revert fe62a78 (which was also a reversion) (#174)
wongaid Dec 10, 2023
40873c3
Restored chatbot state prior to rollback (#180)
atacolak Dec 11, 2023
e059ce4
Feature platform tf gcp (#175)
markbond08 Dec 11, 2023
fad2992
Added a new article to the News Page (#179)
GimsaraK Dec 11, 2023
d8a7640
Add files via upload (#178)
mazyhehe Dec 11, 2023
d59263c
Feature front analtyica nav2 (#173)
Apparmar Dec 11, 2023
87db64b
Task Complete (#176)
sentientyougert Dec 11, 2023
1b634ca
Feature gaya3 cs be (#181)
GayatrideviPakki Dec 11, 2023
cd61144
Task Complete (#182)
sentientyougert Dec 11, 2023
7b7f7bb
Implemented the Dynamic Tips Section in the Login Page (#183)
GimsaraK Dec 11, 2023
0c3e9e0
2.0 Dashboard CSS (#172)
damonrimanic Dec 11, 2023
6068bfb
Swap to python logging system (#184)
wongaid Dec 11, 2023
1f34463
Ai s build user data analysis models (#186)
Jensen-T Dec 12, 2023
f30b5c9
Feature flask random forest model (#188)
mjsaeed Dec 12, 2023
53c2bbd
Update dash2.html (#189)
userstarwind Dec 13, 2023
a07ca25
Add files via upload
AndreWakwale1 Dec 15, 2023
a9f59a5
Update README.md
userstarwind Mar 2, 2024
9e37a53
Update README.md
userstarwind Mar 2, 2024
34cffca
feature_t1_setup (#193)
userstarwind Mar 2, 2024
74e8ee6
Update README.md
userstarwind Mar 4, 2024
fbe9dc9
Update README.md (#194)
denicahh Mar 8, 2024
0f6a410
Flash message on page invalid login
Benbradhurst Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
AWS_COGNITO_CLIENT_SECRET: ${{ secrets.AWS_COGNITO_CLIENT_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
API_KEY: ${{ secrets.API_KEY}}

steps:
- name: Checkout code
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
neo_dolfin/transactions_ut.db
Neo_Dolfin/.DS_Store
neo_dolfin/protean-aria-405907-0f8cb84fda97.json
neo_dolfin/audit.txt
neo_dolfin/logs/dolfin.log
neo_dolfin/logs/dolfin-app.log
neo_dolfin/logs/dolfin-basiq.log
neo_dolfin/logs/dolfin-users.log
101 changes: 43 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# NE0 DolFin
Updated: 29/08/2023
Updated: 3/4/2024

## Branch Management
### Authorised Code Owners:
* Shane Dzartov (@SDzartov)
* Jackson Thompson (@thompsonjac)
* Christopher Russo (@CRussoDeakin)

* JUNKAI JIANG (userstarwind)
* HEERA MOHANADAS (hmm007)
* GIMSARA KENULA ELGIRIYAGE (GimsaraK)
* AIDEN JOHN WILTSHIRE (AiderRate)

### GitHub Management
#### Branch Structure
##### master
Expand Down Expand Up @@ -70,66 +71,38 @@ git push origin your-branch-name --force
### Requirements:
* IDE, like *Visual Studio Code*
* Python Version == **3.11**
* AWS CLI installed on your local machine.
* GitHub Desktop (RECOMMENDED)

## {NEW} MFA CONFIG SET UP
* In order for the SignIn route to function post MFA, you must ensure that your AWS CLI is installed and you have a configure file:
### Deploy Neo_Dolfin to ***Localhost***
* Pull this repo and select this branch, if you are unconfident in your GIT bash skills, please download GitHub Desktop: https://desktop.github.com/
* Once you have the repo folder open in your IDE, do the following in the BELOW ORDER:
* Open a terminal window and move into the neo_dolfin directory via the terminal command: ```cd <path/to>/GitHub/NEO_Dolfin/neo_dolfin```
* (**NOTE: INSERT YOUR PATH AS REQUIRED, YOUR PATH MAY DIFFER**)
* Initiate a new *venv* env using the following terminal command: ```python -m venv venv```
* Activate the *venv* env using the following terminal command: ```venv\scripts\activate``` or ```source venv/bin/activate``` if using a mac
* Install the required libraries into the *venv* env using the following terminal command: ```pip install -r requirements.txt```
* To run the flask application, use the following terminal command: ```python app.py```
* Navigate to ```127.0.0.8000``` in your web browser.

** __Newer Mac "Illegal Hardware" resolution__

### MAC OS
* Ensure that you have an AWS Credentials file in your root directory
* If you have not done this, use the AWS CLI and run the command ```aws configure``` to configure an AWS Profile.
* After that, open the configure file via the command: ```nano ~/.aws/credentials.```. Make sure the code matches the below example and press ```CNTRL+O``` , ```ENTER``` , ```CNTRL+X ```
* Ensure that your AWS credentials file is in the correct format. The format is given below:
```
[default]
aws_access_key_id=<>
aws_secret_access_key=<>
```
* Verify with the command: ```aws configure list```

### WINDOWS
#Method 1
* * Ensure that you have an AWS Credentials file in your root directory
* If you have not done this, use the AWS CLI and run the command ```aws configure``` to configure an AWS Profile.
* Move into that directory via: ```cd %userprofile%\.aws ```
* After that, open the configure file via the command: ```nano credentials```. Make sure the code matches the below example and press ```CNTRL+O``` , ```ENTER``` , ```CNTRL+X ```
* Ensure that your AWS credentials file is in the correct format. The format is given below:
```
[default]
aws_access_key_id=<>
aws_secret_access_key=<>
```
* Verify with the command: ```aws configure list```


#Method 2 - Use the proceedure below if you don't have the AWS CLI installed Or a ```cd %userprofile%\.aws ``` directory and credentials file does not exist
* * Install the latest version of the AWS CLI for Windows from: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
* * Ensure that you have an AWS Credentials file in your root directory (%userprofile%/.aws/configure)
* If you do not have a configure file, use the AWS CLI from the command prompt via running the command ```aws configure``` to configure an AWS Profile.
* Press Enter to accept the default options for AWS Access Key ID, AWS Secret Access Key, Default region name, Default output format.
* Change directory into your user profile directory ```cd %userprofile% ```
* Make a directory called .aws via the following command: ```mkdir .aws ```
* Move into that directory via: ```cd .aws ```
* Create the 'configure' file (with no extension - ie: configure) using notepad, Visual Studio Code or another text editor. Make sure the code matches the below, save the file and close the text editor
```
[default]
aws_access_key_id=<>
aws_secret_access_key=<>
```
* Verify with the command: ```aws configure list```
It is possible to run DolFin on a Mac, however if you are using a newer Mac with Apple Silicon you may receive an “Illegal Hardware Instruction” error on running the “python app.py” command. To resolve this error perform the following steps:
* Install MiniForge from this link - https://github.com/conda-forge/miniforge
* Rerun the command “pip install requirements.txt”

These steps will ensure you have the correct python dependencies for the M1/M2/M3 chipset.

### Deploy to ***Localhost***
### Deploy Dolfin_Analytica to ***Localhost***
* Pull this repo and select this branch, if you are unconfident in your GIT bash skills, please download GitHub Desktop: https://desktop.github.com/
* Once you have the repo folder open in your IDE, do the following in the BELOW ORDER:
* Open a terminal window and move into the neo_dolfin directory via the terminal command: ```cd <path/to>/GitHub/dolfin_fe/neo_dolfin```
* Open a terminal window and move into the neo_dolfin directory via the terminal command: ```cd <path/to>/GitHub/NEO_Dolfin/dolfin_analytica```
* (**NOTE: INSERT YOUR PATH AS REQUIRED, YOUR PATH MAY DIFFER**)
* Initiate a new *venv* env using the following terminal command: ```python -m venv venv```
* Initiate a new *venv* env using the following terminal command: ```python -m venv venv2```
* Activate the *venv* env using the following terminal command: ```venv\scripts\activate```
* Inside your IDE, create a new file inside your neo_dolfin folder called: ```.env``` (**MAKE SURE TO INCLUDE THE "." AT THE BEGINNING**)
* Ask one of the team leads for the credentials, that you must paste into the .env file and then save the file.
* Install the required libraries into the *venv* env using the following terminal command: ```pip install -r requirements.txt```
* To run the flask application, use the following terminal command: ```python app.py```
* Navigate to ```127.0.0.1``` in your web browser.
* Navigate to ```127.0.0.5000``` in your web browser.


### {NEW} Testing
We have testing scripts enabled for this application.
Expand All @@ -139,5 +112,17 @@ We have testing scripts enabled for this application.
**PLEASE RUN THE PYTEST AND ATTACH THE LOG TEXT/SCREENSHOT TO YOUR PULL REQUEST**
***Warnings are OKAY, Fails will result in the PULL request not being reviewed.***

## EC2 Deployment
***WORK IN PROGRESS***
## GCP Deployment

The GCP deployment deploys the following infrastrcuture using Terraform:

- VPC
- Cloud SQL database
- VM running a containerised version of anomaly detection

### Requirements:
* GCP command line tools
* Terraform
* Docker desktop

[Further instructions](dolfin_infra/Readme.md) can be found in the dolfin_infra folder
21 changes: 21 additions & 0 deletions dolfin_analytica/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Ignore virtual environment
venv2\Lib\
venv2/

# Ignore .env file
.env

# Ignore the qr.png file
qr.png

# pycache
.pytest_cache
test/__pycache__
__pycache__
.DS_store

# my chages
test.html
changes.txt
snippets.txt
white_arrow.png
112 changes: 112 additions & 0 deletions dolfin_analytica/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
from flask import Flask, render_template, request, redirect, url_for, session
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine, inspect
import secrets
import bcrypt
import os
import time
import datetime

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def landing():
if request.method == 'POST':
# Access form data using request.form
username = request.form['username']
password = request.form['password']

if username == 'dsuser':
if password == 'dolfin123':

# After processing the data, you can redirect to the /loading route
return redirect(url_for('loading'))

return render_template('landing.html')

# SQL Database Configure
app.config['SECRET_KEY'] = secrets.token_hex(16)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(os.path.dirname(os.path.abspath(__file__)), 'db/user_database.db')

# SQL Database Configure
db = SQLAlchemy(app)

class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(80), unique=True, nullable=False)
password = db.Column(db.String(255), nullable=False)

class UserTestMap(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
userid = db.Column(db.String(80), unique=True, nullable=False)
testid = db.Column(db.Integer, nullable=False)

class UserAuditLog(db.Model):
timestamp = db.Column(db.DateTime, primary_key=True, default=datetime.datetime.now)
username = db.Column(db.String(80), nullable=False)
action = db.Column(db.String(80), nullable=False)
message = db.Column(db.String(255), nullable=False)

try:
with app.app_context():
db.create_all()
except Exception as e:
print("Error creating database:", str(e))

#Logging authentication and output to txt file
def add_user_audit_log(username, action, message):
new_log = UserAuditLog(username=username, action=action, message=message)
print(new_log)
db.session.add(new_log)
db.session.commit()
with open("audit.txt", 'a') as file:
file.write(f"[{new_log.timestamp}] [user-{action}] username: {username}: {message}\n")


#LOGIN ROUTE
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':

input_username = request.form['username']
input_password = request.form['password']

# Retrieve the user from the database
user = User.query.filter_by(username=input_username).first()

# Check if the user exists and the password is correct with stored hash
if user and bcrypt.checkpw(input_password.encode('utf-8'), user.password):
# Successful login, set a session variable to indicate that the user is logged in
session['user_id'] = user.username

# If successful, check if test user or real user.
row = UserTestMap.query.filter_by(userid = input_username).first()
testId = 0
if row != None:
testId = row.testid
print('######### test id:', testId)

#Successful login
add_user_audit_log(input_username, 'login-success', 'User logged in successfully.')
# redirect to main.
return redirect('/main')

## Otherwise:
# log un-successful authentication challenge
add_user_audit_log(input_username, 'login-fail', 'User login failed.')
return 'Login failed. Please check your credentials.'

return render_template('login.html') # Create a login form in the HTML template


@app.route('/loading')
def loading():
return render_template('loading.html')

@app.route('/main')
def main():
return render_template('main.html')

if __name__ == '__main__':
app.run(debug=True)
4 changes: 4 additions & 0 deletions dolfin_analytica/audit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[2023-12-05 14:12:27.042636] [user-login-fail] username: genie: User login failed.
[2023-12-05 14:12:41.626831] [user-login-success] username: tester: User logged in successfully.
[2023-12-05 14:12:54.632698] [user-login-success] username: django: User logged in successfully.
[2023-12-05 14:13:13.296527] [user-login-success] username: richard: User logged in successfully.
Binary file added dolfin_analytica/db/transactions_ut.db
Binary file not shown.
Binary file added dolfin_analytica/db/user_database.db
Binary file not shown.
7 changes: 7 additions & 0 deletions dolfin_analytica/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
blinker==1.7.0
click==8.1.7
Flask==3.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
Werkzeug==3.0.1
Loading