🚨 FOR ANYONE IN CEN3031 WORKING ON AN ISSUE FROM HERE AS YOUR OPEN SOURCE CONTRIBUTION, FEEL FREE TO FORK AND WORK ON THE ISSUE WITHOUT ASKING 🚨
Studygatchi is an open-source Chrome/Firefox extension that encourages productivity and studying through combining Tamagotchi-style pet mechanics and gachapon/gambling!
We use a Django REST backend, PostgreSQL database, and a React frontend powered with Vite.
Check out UF OSC's other projects here: https://ufosc.org/projects/
The fastest way to get the full stack running locally is by using Docker Compose.
- Docker Desktop or Docker Engine with the
docker-composeplugin. - Make sure you have Node.js (version 18+ or 20+) installed on your machine.
- tmux or similar will be nice to have if you are running both the frontend and backend simultaneously.
-
To setup the project, first fork the OSC repo. Then clone:
# To clone git clone https://github.com/[INSERT YOUR GITHUB USERNAME HERE]/Studygatchi.git cd Studygatchi/
-
Configure your environment variables
Copy the
.env-examplein the project's root and name the copy.env. You may change the fields inside if you wish. -
Start the backend
docker compose up --build
-
Start the frontend
cd frontend/ npm install npm run devYou can type 'o' into the Vite prompt to open the project in your default browser. Note that it will be a regular webpage, not an extension.
-
Access the services:
- Frontend: http://localhost:5173
- Backend: http://localhost:8000/
- PostgreSQL database: localhost:5432
Run your tests locally with the .venv active by doing the following:
cd backend/
pytestYou can also run them in Docker if you prefer:
docker compose exec backend pytest- If you're having issues connecting to the backend, make sure that the PostgreSQL service is running on your system. You might need to do this manually with
sudo systemctl status postgresql. Verify that your credentials in.envandsettings.pymatch the fields in PostgreSQL.
If you prefer to run the backend directly on your host machine without containerizing.
Make sure you have Node.js (version 18+ or 20+) installed on your machine.
-
To setup the project, first fork the OSC repo. Then clone:
# To clone git clone https://github.com/[INSERT YOUR GITHUB USERNAME HERE]/Studygatchi.git cd Studygatchi/
-
Install the dependencies:
cd frontend npm install
Start the development server:
npm run devInside your terminal, enter 'o' to open the project in your browser.
To create a production build for later importation as a Chrome extension:
npm run buildThis will generate the build files in the build directory.
This guide expects that you have Python (At least 3.12.0) installed.
- For macOS users, if Python was installed via either Homebrew or the official Python installer, you may need to use
python3andpip3instead ofpythonandpip.
-
To setup the project, first fork the OSC repo. Then clone:
# To clone git clone https://github.com/[INSERT YOUR GITHUB USERNAME HERE]/Studygatchi.git cd Studygatchi/
-
Install
uv# Windows Powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS and Linux curl -LsSf https://astral.sh/uv/install.sh | sh
You may need to restart your shell before
uvappears on your path. -
Create a virtual environment
uv venv .venv --python 3.12 # You can also forgo uv and do it the old fashioned way if you prefer # python -m venv .venv
-
Activate the virtual environment
# macOS and Linux source .venv/bin/activate # Windows Powershell source .venv\Scripts\Activate.ps1
-
Install the dependencies
cd backend uv pip install -r requirements.txt # If you skipped uv # pip install -r requirements.txt
-
Install PostgreSQL (version 17)
- Note: This might take a long time.
- Windows: https://www.postgresql.org/download/windows/
- Linux: https://www.postgresql.org/download/linux/
- We will use this to be able to connect Django with Postgres!
-
Access the PostgreSQL shell, logged in as the superuser
cd <directory you installed it to>/17/bin psql -U postgres
When prompted for a password, use the password you put in the install wizard.
-
Run the following SQL commands:
CREATE USER <myprojectuser> WITH PASSWORD '<your_secure_password>'; CREATE DATABASE studygatchi_db OWNER <myprojectuser>; GRANT ALL PRIVILEGES ON DATABASE studygatchi_db TO <myprojectuser>; \q
Replace
<myprojectuser>with whatever username you want; same for the password -
Create a file called
settings.pyin the backend directory and copy and paste the contents ofsettings_template.txtintosettings.py.cd backend/ cp settings_template.txt settings.py -
In
settings.py, go to where it saysDATABASES, and insert your info from step 6 into the corresponding places. -
Go back to the root of the project
cd ../ -
Run the following commands with the venv active to apply migrations:
python manage.py makemigrations python manage.py migrate
-
Test the connection by running this command
python manage.py runserver
If you see the following message, cool stuff, it's working!
WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead. For more information on production servers see: https://docs. djangoproject.com/en/6.0/howto/deployment/
- This guide assumes an installation that uses
systemd. If you're using something else like OpenRC or runit, tweak thesystemctlcommands accordingly.
-
To setup the project, first fork the OSC repo. Then clone:
# To clone git clone https://github.com/[INSERT YOUR GITHUB USERNAME HERE]/Studygatchi.git cd Studygatchi/
-
Install
uvandpostgresqlpacman -Syu uv postgresql
-
Create a virtual environment
uv venv .venv --python 3.12 # You can also forgo uv and do it the old fashioned way if you prefer # python -m venv .venv
-
Activate the virtual environment
source .venv/bin/activate -
Install the dependencies
cd backend uv pip install -r requirements.txt # If you skipped uv # pip install -r requirements.txt
-
Initialize the database cluster
sudo -u postgres initdb -D /var/lib/postgres/data
-
Start the PostgreSQL service
sudo systemctl start postgresql
- It's optional, but recommended that you have PostgreSQL run at startup so you don't need to manually start it every time you want to contribute:
sudo systemctl enable postgresql -
Access the PostgreSQL shell, logged in as the superuser:
psql -U postgres
-
Run the following SQL commands:
CREATE USER <myprojectuser> WITH PASSWORD '<your_secure_password>'; CREATE DATABASE studygatchi_db OWNER <myprojectuser>; GRANT ALL PRIVILEGES ON DATABASE studygatchi_db TO <myprojectuser>; \q
Replace
<myprojectuser>with whatever username you want, and likewise for the password. -
In the backend directory, create a file called
settings.pywith the contents ofsettings_template.txt.cd backend/ cp settings_template.txt settings.py -
In
settings.py, go to where it saysDATABASES, and insert your info from step 6 into the corresponding places. -
Go back to the root of the project
cd ../ -
Run the following commands with the venv active to apply migrations:
python3 manage.py makemigrations python3 manage.py migrate
-
Test the connection by running this command:
python manage.py runserver
If you see the following message, cool stuff, it's working!
WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead. For more information on production servers see: https://docs. djangoproject.com/en/6.0/howto/deployment/
- Open Chrome and navigate to
chrome://extensions/. - Enable "Developer mode" using the toggle switch in the top right corner.
- Click "Load unpacked" and select the
builddirectory.
public/: Contains static files and themanifest.json.src/: Contains the React app source code.vite.config.ts: Vite configuration file.tsconfig.json: TypeScript configuration file.package.json: Contains the project dependencies and scripts.
When making a pull request to the frontend, you must follow these rules to ensure your PR is not automatically rejected:
- Pull requests must be made to the
devbranch, NOTmain. - Pull requests must include an image of the changes made to the frontend.
This project uses GitHub Actions to run tests on backend endpoints. Whenever you make a push to your fork, there will be two jobs that run under the Python Application workflow:
buildbuild-addtl
build consists of tests that are required to pass for code to be submittable. By default this runs all tests with the required header, but it is your responsibility to update this to run tests relevant to the feature you are working on.
You can do this by going to backend/quickstart/tests.py and marking the relevant test class with the @pytest.mark.required decorator.
build-addtl will run all the tests available in the testing suite, disregarding any test gating. It is not required to have all tests in build-addtl pass and build-addtl will be skipped on PRs.