This project is for CS 5330. It is a full-stack web application for managing a database of an app that analyzes social media content through structured experiments. Users, posts, projects, fields, and analysis results are stored in a MySQL database, and exposed through a Flask REST API.
backend/
├── app.py # Flask backend
├── config.py # DB credentials
├── create_tables.sql # SQL script for DB setup
├── tests/ # Pytest unit and integration tests
└── requirements.txt # Python dependencies
frontend/
├── [React app files] # React frontend code
- Python 3.11 or 3.12
- MySQL Server
- Node.js + npm (for frontend)
- Git (optional)
-
Clone the repo and navigate to backend folder
git clone https://github.com/your-username/DBProject.git cd DBProject/backend -
Set up and activate virtual environment
python -m venv .venv .venv\Scripts\activate # On Windows source .venv/bin/activate # On Mac/Linux
-
Install dependencies
pip install -r requirements.txt
If encountering errors on Mac:
brew install pkg-config brew install mysql pip install -r requirements.txt
-
Set up your MySQL DB
-
Make sure MySQL is running.
-
Create a database titled db_project:
mysql -u root -p -e "CREATE DATABASE db_project;" -
Add connection settings in
config.py:MYSQL_HOST = 'localhost' MYSQL_USER = 'your_user' MYSQL_PASSWORD = 'your_password' MYSQL_DB = 'db_project'
-
Create a user (if 'your_user' is not root) and assign permissions:
mysql -u root -p -e "CREATE USER 'your_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON db_project.* TO 'your_user'@'localhost'; FLUSH PRIVILEGES;" -
Create tables by running
create_tables.sqlin backend:mysql -u your_user -p db_project < create_tables.sql
-
-
Run Flask app
python app.py
- Access at:
http://localhost:5050/
- Access at:
-
Create new terminal and navigate to frontend folder
cd frontend -
Install dependencies
npm install
-
Start React app
npm start
- Access at:
http://localhost:3000/
- Access at:
-
Create new terminal and navigate to backend folder
cd backend -
Activate virtual environment (if not already)
.venv\Scripts\activate # On Windows source .venv/bin/activate # On Mac/Linux
-
Run tests
pytest
| Endpoint | Method | Description |
|---|---|---|
/add-user |
POST | Add a new user |
/add-post |
POST | Add a new post |
/add-project |
POST | Add a new research project |
/add-analysisresult |
POST | Link post to a project's field/value |
/query/experiment-results |
GET | Get results for a given project |
| ... | ... | [Many more available in app.py] |
- Add a social media platform →
/add-socialmedia - Add a user on that platform →
/add-user - Add a post by that user →
/add-post - Add an institute →
/add-institute - Add a project under the institute →
/add-project - Add fields to the project →
/add-field - Add analysis results linked to a post →
/add-analysisresult - Query posts by:
- Social media →
/query/posts-by-media - Period of time →
/query/posts-by-time - Username of a certain media →
/query/posts-by-username - First/last name →
/query/posts-by-name
- Social media →
- Query results by project →
/query/experiment-results