Skip to content
Open

mm #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
353 commits
Select commit Hold shift + click to select a range
ad6cedb
delete get_diagnostic
christinejahn Dec 2, 2024
b33d6e8
Update student_routes.py
mmikanguyen Dec 2, 2024
9851f48
organizing/cleaning up routes based on matrix
christinejahn Dec 2, 2024
ad08262
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
9f18e5f
updating description for POST route
christinejahn Dec 2, 2024
39accb5
creating a separate folder for tech support analyst persona
christinejahn Dec 2, 2024
2a13929
updating to 'run system logs'
christinejahn Dec 2, 2024
439af94
update to 'view advisor feedback'
christinejahn Dec 2, 2024
383c6c3
Update community_routes.py
mmikanguyen Dec 2, 2024
9a6c5c7
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
mmikanguyen Dec 2, 2024
6605645
removing warehouse manager
christinejahn Dec 2, 2024
441d598
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
e782243
initial renaming for our project's readme
christinejahn Dec 2, 2024
70e97cf
Update nav.py
mmikanguyen Dec 2, 2024
a883e1a
Update 20_Student_Kevin_Home.py
mmikanguyen Dec 2, 2024
e6173b5
including team fontenators!
christinejahn Dec 2, 2024
f328dbb
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
5a649a0
SyncSpace description in ReadMe
christinejahn Dec 2, 2024
68d3e8b
more updates to describe our readme
christinejahn Dec 2, 2024
48f89f7
more updates to description
christinejahn Dec 2, 2024
ca8d909
creating blueprint for co-op advisor persona
christinejahn Dec 2, 2024
7f4b2bf
updating to input view professional events
christinejahn Dec 2, 2024
0d47339
updating to include access to alumni networks
christinejahn Dec 2, 2024
fd934f5
updating to connect to correct data source
christinejahn Dec 2, 2024
921dc26
updating to fit 'ticket overview' button
christinejahn Dec 2, 2024
4790847
updating sarah's home page
christinejahn Dec 2, 2024
b3a27de
3
xavieryu18 Dec 2, 2024
d49a06b
3
xavieryu18 Dec 2, 2024
0ba140f
Update SyncSpace-data.sql
mmikanguyen Dec 2, 2024
659f53a
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
mmikanguyen Dec 2, 2024
59a0277
3
xavieryu18 Dec 2, 2024
c414ba4
Update 10_Co-op_Advisor_Home.py
xavieryu18 Dec 2, 2024
d365859
Delete SyncSpace.sql
mmikanguyen Dec 2, 2024
b0cf97f
file name change
mmikanguyen Dec 2, 2024
22c66fe
qqq
xavieryu18 Dec 2, 2024
0e631a6
Update SyncSpace.sql
mmikanguyen Dec 2, 2024
7041128
Update SyncSpace.sql
mmikanguyen Dec 2, 2024
98c7501
Update SyncSpace.sql
mmikanguyen Dec 2, 2024
068cadb
22
xavieryu18 Dec 2, 2024
1ae7e85
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 2, 2024
3f4c77c
Update SyncSpace-data.sql
mmikanguyen Dec 2, 2024
1015f19
Update SyncSpace-data.sql
mmikanguyen Dec 2, 2024
c68c70c
223
xavieryu18 Dec 2, 2024
9f74d29
Update SyncSpace-data.sql
xavieryu18 Dec 2, 2024
411f258
updating to fit our tickets resource
christinejahn Dec 2, 2024
4df4165
222
xavieryu18 Dec 2, 2024
881ec51
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 2, 2024
ff3beba
e22e
xavieryu18 Dec 2, 2024
35c8768
updating PUT statement
christinejahn Dec 2, 2024
a6a1624
Update community_routes.py
mmikanguyen Dec 2, 2024
f9b6db9
cleaning up PUT route
christinejahn Dec 2, 2024
1b82428
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
3a8c523
updating more PUT route
christinejahn Dec 2, 2024
57ada31
Update community_routes.py
mmikanguyen Dec 2, 2024
0acfbf7
renaming the descriptions
christinejahn Dec 2, 2024
873956b
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
66f6851
Update community_routes.py
mmikanguyen Dec 2, 2024
61d5134
Update 22_Housing.py
mmikanguyen Dec 2, 2024
b411a58
Update 22_Housing.py
mmikanguyen Dec 2, 2024
cd9888a
updating POST route
christinejahn Dec 2, 2024
0ecd8cf
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
6d432c0
reformatting
christinejahn Dec 2, 2024
96c7342
updating description notes
christinejahn Dec 2, 2024
518faee
updating streamlit pages
christinejahn Dec 2, 2024
05259c3
updating routes and rest_entry.py
mmikanguyen Dec 2, 2024
db03c27
renaming page
christinejahn Dec 2, 2024
269a3fa
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 2, 2024
5f8ee3e
updating page name
christinejahn Dec 2, 2024
01cc6ad
adjusting name in home page of app
christinejahn Dec 2, 2024
b3db9ed
updating system logs page
christinejahn Dec 2, 2024
7957b62
renaming
christinejahn Dec 2, 2024
4d20969
updating nav.py with systemlogs
christinejahn Dec 2, 2024
b0f0938
renaming
christinejahn Dec 2, 2024
fe6d65d
renaming to ticket overview
christinejahn Dec 2, 2024
bcebf5b
updating links in nav
christinejahn Dec 2, 2024
5e8c115
more renaming to fit tech support analyst role
christinejahn Dec 2, 2024
91213b0
updating emojis
christinejahn Dec 2, 2024
232e0f2
inputting system health dashboard into nav.py
christinejahn Dec 2, 2024
01ce2f3
updates to pages
christinejahn Dec 2, 2024
7e6e948
adjusting pages
christinejahn Dec 2, 2024
46659da
updates
mmikanguyen Dec 2, 2024
e678166
updating syncspace description
christinejahn Dec 2, 2024
5e1fa1f
update intro of readme
christinejahn Dec 2, 2024
208eb67
updating descriptions
christinejahn Dec 2, 2024
88238d4
deleting duplicates
christinejahn Dec 2, 2024
6703e06
inputting test page for now
christinejahn Dec 2, 2024
2d63ca5
renaming
christinejahn Dec 2, 2024
ffadf51
updae
mmikanguyen Dec 2, 2024
894e95f
Update docker-compose.yaml
mmikanguyen Dec 2, 2024
8cca30d
renaming file name
christinejahn Dec 2, 2024
5ff1386
m
mmikanguyen Dec 3, 2024
259514a
m
mmikanguyen Dec 3, 2024
b287d7c
,
mmikanguyen Dec 3, 2024
4c16406
update
mmikanguyen Dec 3, 2024
837ec70
data updates
mmikanguyen Dec 3, 2024
15d293c
1
xavieryu18 Dec 3, 2024
baaee70
1
xavieryu18 Dec 3, 2024
8828add
nn
xavieryu18 Dec 3, 2024
50a6357
housing and carpool pages
mmikanguyen Dec 3, 2024
a63c04c
updating about page
christinejahn Dec 3, 2024
2136c44
renaming
christinejahn Dec 3, 2024
373c148
housing
mmikanguyen Dec 3, 2024
2b85e24
222
xavieryu18 Dec 3, 2024
1cb814d
233
xavieryu18 Dec 3, 2024
2608bdd
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 3, 2024
148a9c6
222
xavieryu18 Dec 3, 2024
996bf8d
333
xavieryu18 Dec 3, 2024
9ae1889
updates
mmikanguyen Dec 3, 2024
1d02ca1
title change
mmikanguyen Dec 3, 2024
08b5e2d
Update 02_SyncSpace-data.sql
xavieryu18 Dec 3, 2024
d47c137
renaming
mmikanguyen Dec 3, 2024
9ce817b
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 3, 2024
002fcc9
1222
xavieryu18 Dec 3, 2024
9f5c506
222
xavieryu18 Dec 3, 2024
a9ef3a6
222
xavieryu18 Dec 3, 2024
eb45ca1
22
xavieryu18 Dec 4, 2024
90342e1
Update 22_Housing_Carpool.py
mmikanguyen Dec 4, 2024
6976ff8
Update 22_Housing_Carpool.py
mmikanguyen Dec 4, 2024
d1d5db7
updates
mmikanguyen Dec 4, 2024
dfab456
kevin updates
mmikanguyen Dec 4, 2024
65bea84
updats
mmikanguyen Dec 4, 2024
412ed23
u
mmikanguyen Dec 4, 2024
5036704
rerouting pages
mmikanguyen Dec 4, 2024
d9524b1
update
mmikanguyen Dec 4, 2024
be7c155
m m n m blkhvjnm,
mmikanguyen Dec 4, 2024
fd8144f
m
mmikanguyen Dec 4, 2024
37346d2
Update rest_entry.py
mmikanguyen Dec 4, 2024
aae97cf
Update rest_entry.py
mmikanguyen Dec 4, 2024
c902502
updating streamlit page
christinejahn Dec 4, 2024
587563f
removing duplicates
christinejahn Dec 4, 2024
1c2d5c8
renaming
christinejahn Dec 4, 2024
7fda868
testing a version of streamlit page
christinejahn Dec 4, 2024
0dad909
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 4, 2024
1e21211
u
xavieryu18 Dec 4, 2024
9a03eb6
uuu
xavieryu18 Dec 4, 2024
d671a3c
Update community_routes.py
mmikanguyen Dec 4, 2024
2077be1
Update community_routes.py
mmikanguyen Dec 4, 2024
b6beadf
nnn
xavieryu18 Dec 4, 2024
56ecd7b
u
xavieryu18 Dec 4, 2024
d77b7bf
updates
mmikanguyen Dec 4, 2024
88167c5
u
xavieryu18 Dec 4, 2024
038ce54
advisor comms
mmikanguyen Dec 4, 2024
7890d2a
Fixed errors in Home.py and updated my pages
pchamarthi14 Dec 4, 2024
7e293d0
888
xavieryu18 Dec 4, 2024
d14902c
kebin-aviosr
mmikanguyen Dec 4, 2024
b7b4fa7
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 4, 2024
624b617
updates
mmikanguyen Dec 4, 2024
028b105
upate
mmikanguyen Dec 4, 2024
62e2d09
feeback form code
mmikanguyen Dec 4, 2024
6902ab0
testing url
christinejahn Dec 4, 2024
50e9266
updates
mmikanguyen Dec 4, 2024
15a6bd7
updatw
mmikanguyen Dec 4, 2024
f92b8de
testing this streamlit page
christinejahn Dec 4, 2024
f5fe919
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 4, 2024
d757224
inputting persona
christinejahn Dec 4, 2024
4a33967
Sarah Student Changes
pchamarthi14 Dec 4, 2024
264952c
sarah changes
pchamarthi14 Dec 4, 2024
0b391c3
Sarah fixes
pchamarthi14 Dec 4, 2024
a48a903
222
xavieryu18 Dec 4, 2024
a3439f3
debugging
christinejahn Dec 4, 2024
1a3ec0d
cleaning
christinejahn Dec 4, 2024
d7c102f
testing my streamlit page
christinejahn Dec 4, 2024
3bc0a0a
222
xavieryu18 Dec 4, 2024
146dae1
Sarah Changes
pchamarthi14 Dec 4, 2024
18befce
sarah changes
pchamarthi14 Dec 4, 2024
f45c811
upfate
xavieryu18 Dec 4, 2024
5638ba2
kevin updates
mmikanguyen Dec 4, 2024
1910a36
Update rest_entry.py
mmikanguyen Dec 4, 2024
f770c17
button
mmikanguyen Dec 4, 2024
729f735
re-ordering
christinejahn Dec 4, 2024
1eed14d
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 4, 2024
991c668
88
xavieryu18 Dec 4, 2024
1aaf863
2
xavieryu18 Dec 4, 2024
e8d5136
Update 02_Ticket_Overview.py
mmikanguyen Dec 4, 2024
797ffad
2
xavieryu18 Dec 4, 2024
ea46da4
dddd
xavieryu18 Dec 5, 2024
21baa5f
tickets overview updares
mmikanguyen Dec 5, 2024
723b785
Update 02_Ticket_Overview.py
mmikanguyen Dec 5, 2024
79fa28a
debugging
yupark04 Dec 5, 2024
d672156
feedback_id
yupark04 Dec 5, 2024
13ccab1
Misordered Function Arguments
yupark04 Dec 5, 2024
927817b
ticket overview
mmikanguyen Dec 5, 2024
a615d6d
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
yupark04 Dec 5, 2024
df3bd22
sql fix
pchamarthi14 Dec 5, 2024
f02fa90
TEST
christinejahn Dec 5, 2024
2f1382d
Delete .env copy.template
christinejahn Dec 5, 2024
932b1ab
file change
pchamarthi14 Dec 5, 2024
4ce50ab
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
yupark04 Dec 5, 2024
63e3a1c
Update 21_Advisor_Rec.py
mmikanguyen Dec 5, 2024
06d1ce0
Update michael_routes.py
mmikanguyen Dec 5, 2024
644119a
Update 22_Housing_Carpool.py
mmikanguyen Dec 5, 2024
f782969
deleting lines
mmikanguyen Dec 5, 2024
0863065
Update kevin_routes.py
mmikanguyen Dec 5, 2024
87f6bb8
changes
mmikanguyen Dec 5, 2024
953c65c
Sad logo
mmikanguyen Dec 5, 2024
35c764f
Update .env.template
mmikanguyen Dec 5, 2024
d247cf2
deleting template files
mmikanguyen Dec 5, 2024
a8d3959
Update student2_routes.py
mmikanguyen Dec 5, 2024
0cbd744
updating
christinejahn Dec 5, 2024
0ce97ba
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 5, 2024
a9e5800
updates
christinejahn Dec 5, 2024
1c8f59d
removing template data files
mmikanguyen Dec 5, 2024
019ce49
Update 02_SyncSpace-data.sql
mmikanguyen Dec 5, 2024
d50af14
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 5, 2024
8062d33
upa
mmikanguyen Dec 5, 2024
d946db3
updating
christinejahn Dec 5, 2024
66f6e34
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 5, 2024
a7da9f9
deleting
christinejahn Dec 5, 2024
25422ba
updating name
christinejahn Dec 5, 2024
f60e7be
update
christinejahn Dec 5, 2024
e98d139
Update 24_Edit_Profile.py
mmikanguyen Dec 5, 2024
40952a4
update
christinejahn Dec 5, 2024
9da8d57
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 5, 2024
7a75d6c
Update README.md
mmikanguyen Dec 5, 2024
48065fc
111
xavieryu18 Dec 5, 2024
d1eb481
Update 24_Edit_Profile.py
mmikanguyen Dec 5, 2024
269c2fd
Update nav.py
mmikanguyen Dec 5, 2024
184af5a
update for consistency
christinejahn Dec 5, 2024
7bd5793
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 5, 2024
f5f62ba
delete empty space
christinejahn Dec 5, 2024
5184f64
Update Home.py
mmikanguyen Dec 5, 2024
4491330
Update Home.py
mmikanguyen Dec 5, 2024
1cd736b
update
christinejahn Dec 5, 2024
ca79cd6
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
christinejahn Dec 5, 2024
e005568
page rerouting
mmikanguyen Dec 5, 2024
23d8ba2
Update nav.py
mmikanguyen Dec 5, 2024
cf7e126
changes
pchamarthi14 Dec 5, 2024
7052cd5
change
pchamarthi14 Dec 5, 2024
0217551
sarah updates
mmikanguyen Dec 5, 2024
c903c3c
updates
mmikanguyen Dec 5, 2024
6da74a0
Update 30_Student_Sarah_Home.py
mmikanguyen Dec 5, 2024
5b2a8f9
sarah updates
mmikanguyen Dec 5, 2024
0ff6f70
name changing
mmikanguyen Dec 5, 2024
409cae5
more sarah code
mmikanguyen Dec 5, 2024
fc4244d
sarah updates
mmikanguyen Dec 5, 2024
2599757
final
xavieryu18 Dec 5, 2024
b82b01f
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 5, 2024
2634fab
Fixes
xavieryu18 Dec 5, 2024
38ec836
update
christinejahn Dec 5, 2024
5955600
Fixes
xavieryu18 Dec 5, 2024
ec4e63f
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 5, 2024
7fbb097
fixes
xavieryu18 Dec 5, 2024
35ae1b2
update
christinejahn Dec 5, 2024
1414fae
sidebar
mmikanguyen Dec 5, 2024
0f7d7f3
event button
xavieryu18 Dec 5, 2024
decf63b
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 5, 2024
ae20b11
updates
mmikanguyen Dec 5, 2024
0059bcb
Merge branch 'main' of https://github.com/mmikanguyen/SyncSpace
xavieryu18 Dec 5, 2024
ae5b4d9
Update 14_Create_Event.py
mmikanguyen Dec 5, 2024
1f63f69
Update README.md
mmikanguyen Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 13 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# Fall 2024 CS 3200 Project Template Repository
# Fall 2024 CS 3200 SyncSpace Repository

This repo is a template for your semester project. It includes most of the infrastructure setup (containers) and sample code and data throughout. Explore it fully and ask questions.
# Welcome to our guidebook for everything and anything SyncSpace!
This guidebook is inclusive of the details of our project and all the information you need to build/start the containers. We hope you enjoy exploring!

By Team Fontenators: Christine Ahn, Praytusha Chamarthi, Mika Nguyen, Yugeun Park, Xavier Yu

## About SyncSpace
Our app SyncSpace is a data-driven virtual community that aims to connect students going on co-ops and internships, helping them make the most of their experience. Students often feel isolated or overwhelmed when relocating for work, facing the challenges of finding housing, arranging transportation, and locating familiar faces nearby. SyncSpace solves this by using curated feedback, data, and shared interests/community forums to match students with ‘co-op buddies’ in their area, helping them form connections, navigate new cities, and share resources for housing and commuting.

Designed for students and co-op advisors, SyncSpace offers real-time data insights that help students connect with each other and thrive professionally. With personalized interest-based groups, housing and transportation forums, and a hub for professional events, students can access networking, guidance, and new friendships anytime they need it. Co-op advisors and system admin staff can effortlessly organize and track engagement, while gaining valuable data on student satisfaction, activity trends, and engagement levels. By building a vibrant, supportive community, we hope to empower students to make meaningful connections and maximize their co-op and internship experiences.

## Link to our demo
https://youtu.be/8xzt0m0avSg

## Prerequisites

Expand All @@ -17,12 +28,6 @@ Currently, there are three major components which will each run in their own Doc
- Flask REST api in the `./api` directory
- SQL files for your data model and data base in the `./database-files` directory

## Suggestion for Learning the Project Code Base

If you are not familiar with web app development, this code base might be confusing. You will probably want two versions though:
1. One version for you to explore, try things, break things, etc. We'll call this your **Personal Repo**
1. One version of the repo that your team will share. We'll call this the **Team Repo**.


### Setting Up Your Personal Repo

Expand All @@ -32,15 +37,6 @@ If you are not familiar with web app development, this code base might be confus
1. Set up the `.env` file in the `api` folder based on the `.env.template` file.
1. Start the docker containers.

### Setting Up Your Team Repo

Before you start: As a team, one person needs to assume the role of *Team Project Repo Owner*.

1. The Team Project Repo Owner needs to fork this template repo into their own GitHub account **and give the repo a name consistent with your project's name**. If you're worried that the repo is public, don't. Every team is doing a different project.
1. In the newly forked team repo, the Team Project Repo Owner should go to the **Settings** tab, choose **Collaborators and Teams** on the left-side panel. Add each of your team members to the repository with Write access.
1. Each of the other team members will receive an invitation to join. Obviously accept the invite.
1. Once that process is complete, each team member, including the repo owner, should clone the Team's Repo to their local machines (in a different location than your Personal Project Repo).

## Controlling the Containers

- `docker compose up -d` to start all the containers in the background
Expand All @@ -49,30 +45,11 @@ Before you start: As a team, one person needs to assume the role of *Team Projec
- `docker compose stop` to "turn off" the containers but not delete them.


## Handling User Role Access and Control

In most applications, when a user logs in, they assume a particular role. For instance, when one logs in to a stock price prediction app, they may be a single investor, a portfolio manager, or a corporate executive (of a publicly traded company). Each of those *roles* will likely present some similar features as well as some different features when compared to the other roles. So, how do you accomplish this in Streamlit? This is sometimes called Role-based Access Control, or **RBAC** for short.

The code in this project demonstrates how to implement a simple RBAC system in Streamlit but without actually using user authentication (usernames and passwords). The Streamlit pages from the original template repo are split up among 3 roles - Political Strategist, USAID Worker, and a System Administrator role (this is used for any sort of system tasks such as re-training ML model, etc.). It also demonstrates how to deploy an ML model.

Wrapping your head around this will take a little time and exploration of this code base. Some highlights are below.

### Getting Started with the RBAC
1. We need to turn off the standard panel of links on the left side of the Streamlit app. This is done through the `app/src/.streamlit/config.toml` file. So check that out. We are turning it off so we can control directly what links are shown.
1. Then I created a new python module in `app/src/modules/nav.py`. When you look at the file, you will se that there are functions for basically each page of the application. The `st.sidebar.page_link(...)` adds a single link to the sidebar. We have a separate function for each page so that we can organize the links/pages by role.
1. Next, check out the `app/src/Home.py` file. Notice that there are 3 buttons added to the page and when one is clicked, it redirects via `st.switch_page(...)` to that Roles Home page in `app/src/pages`. But before the redirect, I set a few different variables in the Streamlit `session_state` object to track role, first name of the user, and that the user is now authenticated.
1. Notice near the top of `app/src/Home.py` and all other pages, there is a call to `SideBarLinks(...)` from the `app/src/nav.py` module. This is the function that will use the role set in `session_state` to determine what links to show the user in the sidebar.
1. The pages are organized by Role. Pages that start with a `0` are related to the *Political Strategist* role. Pages that start with a `1` are related to the *USAID worker* role. And, pages that start with a `2` are related to The *System Administrator* role.


## Deploying An ML Model (Totally Optional for CS3200 Project)

*Note*: This project only contains the infrastructure for a hypothetical ML model.

1. Build, train, and test your ML model in a Jupyter Notebook.
1. Once you're happy with the model's performance, convert your Jupyter Notebook code for the ML model to a pure python script. You can include the `training` and `testing` functionality as well as the `prediction` functionality. You may or may not need to include data cleaning, though.
1. Check out the `api/backend/ml_models` module. In this folder, I've put a sample (read *fake*) ML model in `model01.py`. The `predict` function will be called by the Flask REST API to perform '*real-time*' prediction based on model parameter values that are stored in the database. **Important**: you would never want to hard code the model parameter weights directly in the prediction function. tl;dr - take some time to look over the code in `model01.py`.
1. The prediction route for the REST API is in `api/backend/customers/customer_routes.py`. Basically, it accepts two URL parameters and passes them to the `prediction` function in the `ml_models` module. The `prediction` route/function packages up the value(s) it receives from the model's `predict` function and send its back to Streamlit as JSON.
1. Back in streamlit, check out `app/src/pages/11_Prediction.py`. Here, I create two numeric input fields. When the button is pressed, it makes a request to the REST API URL `/c/prediction/.../...` function and passes the values from the two inputs as URL parameters. It gets back the results from the route and displays them. Nothing fancy here.


4 changes: 3 additions & 1 deletion api/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ SECRET_KEY=someCrazyS3cR3T!Key.!
DB_USER=root
DB_HOST=db
DB_PORT=3306
DB_NAME=northwind
DB_NAME=SyncSpace
MYSQL_ROOT_PASSWORD=<put a good password here>


File renamed without changes.
35 changes: 35 additions & 0 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'''
from flask import Flask
from backend.db_connection import init_app
from backend.advisor.co_op_advisor_routes import advisor
from backend.students.student_routes import students



app = Flask(__name__)

init_app(app)



@@ -15,6 +17,7 @@ init_app(app)

# Register blueprints
app.register_blueprint(advisor, url_prefix='/api')
app.register_blueprint(tech_support_analyst, url_prefix='/api')
app.register_blueprint(students, url_prefix='/api')



# Register blueprints
app.register_blueprint(advisor, url_prefix='/api/advisor')
app.register_blueprint(tech_support_analyst, url_prefix='/api/tech_support_analyst')
app.register_blueprint(students, url_prefix='/api/students')


if __name__ == '__main__':
app.run(host='0.0.0.0', port=4000)
'''



Empty file added api/backend/__init__.py
Empty file.
1 change: 1 addition & 0 deletions api/backend/advisor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This can be empty, just needs to exist
271 changes: 271 additions & 0 deletions api/backend/advisor/co_op_advisor_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from datetime import datetime

from backend.db_connection import db

advisor = Blueprint('advisor', __name__)


@advisor.route('/advisor/tasks', methods=['GET'])
def get_all_tasks():
query = '''
SELECT
t.TaskID,
s.StudentID,
s.Name as student_name,
t.Status as task_status,
t.Description,
t.Reminder,
t.DueDate
FROM Task t
JOIN Student s ON t.AssignedTo = s.StudentID
ORDER BY t.DueDate ASC


'''
cursor = db.get_db().cursor()
cursor.execute(query)
theData = cursor.fetchall()
response = make_response(jsonify(theData))
response.status_code = 200
return response



@advisor.route('/advisor/notifications', methods=['GET'])
def get_notifications():
try:
cursor = db.get_db().cursor()
query = '''
SELECT
s.Name as student_name,
t.Status as notification_status,
t.Reminder as date_assigned,
t.Description as description
FROM Task t
JOIN Student s ON t.AssignedTo = s.StudentID
ORDER BY t.Reminder DESC
'''
cursor.execute(query)
theData = cursor.fetchall()

response = make_response(jsonify(theData))
response.status_code = 200
return response
except Exception as e:
print(f"Database error: {str(e)}")
return jsonify({'error': 'Failed to fetch notifications'}), 500



@advisor.route('/advisor/tasks/<task_id>', methods=['PUT'])
def update_task_status(task_id):
try:
# Parse JSON data from request
data = request.json
new_status = data.get('status')

# Validate that status is provided
if not new_status:
return make_response(jsonify({"error": "Status is required"}), 400)

# Build the SQL query to update the task status
query = '''
UPDATE Task
SET Status = %s
WHERE TaskID = %s
'''
values = (new_status, task_id)

# Execute the query
cursor = db.get_db().cursor()
cursor.execute(query, values)

# Check if any rows were affected
if cursor.rowcount == 0:
db.get_db().rollback()
return make_response(jsonify({
"error": f"No task found with ID {task_id}"
}), 404)

db.get_db().commit()
print(f"Successfully updated status for task {task_id} to {new_status}") # Debug log

# Return success response
return make_response(jsonify({
"message": "Task status updated successfully",
"task_id": task_id,
"new_status": new_status
}), 200)

except Exception as e:
print(f"Error updating task status: {str(e)}") # Debug log
db.get_db().rollback()
return make_response(jsonify({"error": str(e)}), 500)


@advisor.route('/advisor/tasks/<task_id>/reminder', methods=['PUT'])
def update_task_reminder(task_id):
try:
# Get the new reminder date from request body
data = request.get_json()
new_reminder = data.get('reminder')

# Validate the reminder date format
try:
# Convert string to datetime object to validate format
reminder_date = datetime.strptime(new_reminder, '%Y-%m-%d')
except ValueError:
return jsonify({
'error': 'Invalid date format. Please use YYYY-MM-DD format'
}), 400

# Update using the correct column name (Reminder)
query = '''
UPDATE Task
SET Reminder = %s
WHERE TaskID = %s
'''
cursor = db.get_db().cursor()
cursor.execute(query, (reminder_date, task_id))
db.get_db().commit()

return jsonify({
'message': 'Task reminder updated successfully',
'task_id': task_id,
'new_reminder': new_reminder
}), 200

except Exception as e:
db.get_db().rollback()
return jsonify({'error': str(e)}), 500


@advisor.route('/advisor/events', methods=['POST'])
def create_event():
try:
data = request.get_json()
print("Received data:", data) # Log the received data

query = '''
INSERT INTO Events (
CommunityID,
Date,
Name,
Description
) VALUES (%s, %s, %s, %s)
'''

cursor = db.get_db().cursor()
print("Executing query:", query) # Log the query
cursor.execute(query, (
data.get('community_id'),
data.get('date'),
data.get('name'),
data.get('description')
))
db.get_db().commit()
print("Event created successfully") # Log success

return jsonify({
'message': 'Event created successfully'
}), 201

except Exception as e:
print(f"Error creating event: {str(e)}") # Log the error
db.get_db().rollback()
return jsonify({'error': str(e)}), 500

@advisor.route('/advisor/events/<event_id>', methods=['PUT'])
def update_event(event_id):
try:
data = request.get_json()

query = '''
UPDATE Events
SET CommunityID = %s,
Date = %s,
Name = %s,
Description = %s
WHERE EventID = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (
data.get('community_id'),
data.get('date'),
data.get('name'),
data.get('description'),
event_id
))
db.get_db().commit()

return jsonify({
'message': 'Event updated successfully'
}), 200

except Exception as e:
db.get_db().rollback()
return jsonify({'error': str(e)}), 500

@advisor.route('/advisor/events/<event_id>', methods=['DELETE'])
def delete_event(event_id):
try:
query = '''
DELETE FROM Events
WHERE EventID = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (event_id,))
db.get_db().commit()

return jsonify({
'message': 'Event deleted successfully'
}), 200

except Exception as e:
db.get_db().rollback()
return jsonify({'error': str(e)}), 500

@advisor.route('/advisor/events/<event_id>', methods=['GET'])
def get_event(event_id):
try:
query = '''
SELECT
EventID,
CommunityID,
Date,
Name,
Description
FROM Events
WHERE EventID = %s
'''

cursor = db.get_db().cursor()
cursor.execute(query, (event_id,))
event = cursor.fetchone()

if event:
# Convert the result to a dictionary with proper keys
event_dict = {
'EventID': event['EventID'],
'CommunityID': event['CommunityID'],
'Date': event['Date'].strftime('%Y-%m-%d') if event['Date'] else None,
'Name': event['Name'],
'Description': event['Description']
}
return jsonify(event_dict), 200
else:
return jsonify({'error': 'Event not found'}), 404

except Exception as e:
print(f"Error fetching event: {str(e)}") # Add debugging
return jsonify({'error': str(e)}), 500




Loading