A web app where users can post about what they learned today.
- About
- Technologies Used
- Project Structure
- Getting Started
- DailyRecall Setup Guide
- Directory Structure & Installation
- Django Backend Setup
- PostgreSQL Setup
- Migrations in Django
- Key Commands
- Workflow
- PgAdmin Database Viewing
- Conclusion
DailyRecall is a platform designed for users to log and share what they learned each day. The app is built with a Django backend and a React frontend, with TypeScript integration for enhanced development.
- Backend: Django, Python
- Frontend: React, TypeScript
- Database: PostgreSQL
- Other Tools: PgAdmin, dotenv for environment variables
DailyRecall/
│
├── DailyRecall_server/
│ ├── manage.py
│ ├── settings.py
│ └── ...
├── client/
│ └── src/
│ └── public/
└── README.md
Before setting up the project, ensure you have the following installed on your machine:
- Python 3.x
- Node.js
- PostgreSQL (version 16 or later)
- PgAdmin (should be downloaded at the same time you download Postgres)
This guide walks you through setting up the DailyRecall project on your local machine.
- First clone the repo and move into the folder
git clone <DailyRecall-url>
cd DailyRecall
-
Navigate to the following directory (root address)
C:\Users\<your-name>\...\DailyRecall>
-
Setup Virtual Environment:
-
Create a virtual environment:
python -m venv envir
-
Activate the virtual environment:
.\envir\Scripts\activate
Note: Always keep the virtual environment activated when working on the backend to avoid package conflicts.
-
-
Navigate to the server directory:
C:\Users\<'your name'>\...\DailyRecall\DailyRecall_server>
-
Install required backend packages using the requirements.txt file:
pip install -r requirements.txt
-
Setup Frontend:
-
First, change directory to the client folder:
cd client
-
Install all necessary packages for React and TypeScript:
npm install
-
Move back to the root directory:
cd..
Note: Always keep the virtual environment activated when working on the backend to avoid package conflicts.
-
-
Download & Install PostgreSQL (version 16):
- PostgreSQL Downloads
- Make sure to save your password somewhere secure during installation, as it will be needed for future use.
-
Configure Database Connection:
- Inside the DailyRecall_server directory, create a
.env
file (where thesettings.py
file is located).
- Inside the DailyRecall_server directory, create a
-
Add the following parameters to the
.env
file:SECRET_KEY=<"ill give you the secret key"> DB_NAME=DailyRecall DB_USER=postgres DB_PASSWORD=<"--your--pgadmin--password--"> DB_HOST=127.0.0.1 DB_PORT=5432
Ensure that the
DB_NAME
matches the database name you created in PgAdmin. -
PgAdmin Setup:
- Create the PostgreSQL database via PgAdmin, matching the
DB_NAME
. - Team members can connect to the database via PgAdmin by creating a new server connection with shared credentials.
- Create the PostgreSQL database via PgAdmin, matching the
Django migrations help keep the database schema in sync with the models in the code.
-
makemigrations:
- Purpose: Generate migration files based on changes made to models.
- Who runs it?
- Only the developer making model changes should run
makemigrations
. The resulting migration files are committed to version control.
- Only the developer making model changes should run
-
migrate:
- Purpose: Apply the changes in the migration files to the database.
- Who runs it?
- Every developer after pulling the latest migration files from version control should run
migrate
to update their local database.
- Every developer after pulling the latest migration files from version control should run
-
When someone changes the models, they:
- Run
makemigrations
. - Commit the resulting migration files to version control.
- Run
-
After pulling the latest changes:
- Every team member should run
migrate
to apply any new changes to their local development database.
- Every team member should run
- Make sure that every team member has the necessary access to the shared PostgreSQL database (if working with a centralized database).
- For local databases, each member can connect to their own PostgreSQL instance via PgAdmin after running
migrate
to view their tables.
- makemigrations: Run by the person making changes to the models, and the migration files are shared via version control.
- migrate: Run by every team member to apply the changes to their database.
- PgAdmin: Team members can connect to PostgreSQL using shared credentials or individual local databases.