This project implements a to-do list using FastAPI.
The following dependencies are expected to be installed:
MacOS users are recommended to use Homebrew, a package manager that simplifies the installation of software on MacOS and Linux systems, to easily install the required dependencies for this project. If Homebrew is not yet installed, follow the instructions on its homepage.
Once Homebrew is installed, the project dependencies can be installed by running the following command in the terminal:
brew install python3 postgresql pre-commit pdm
Before the project setup, follow these steps for database setup:
-
Start the PostgreSQL service. The command may vary depending on the operating system:
brew services start postgresql
-
Connect to the default
postgres
database:psql postgres
-
If the
postgres
user does not exist, create a new user namedpostgres
with passwordpostgres
:CREATE USER postgres WITH PASSWORD 'postgres';
If the
postgres
user already exists, set the password for this user to 'postgres':ALTER USER postgres WITH PASSWORD 'postgres';
-
Create two databases named
planner
andplanner_test
owned by thepostgres
user:CREATE DATABASE planner OWNER postgres; CREATE DATABASE planner_test OWNER postgres;
planner
is used for the main application, whileplanner_test
is used for running tests. -
Set the timezone of the databases to UTC:
ALTER DATABASE planner SET timezone TO 'UTC'; ALTER DATABASE planner_test SET timezone TO 'UTC';
-
Exit the PostgreSQL shell:
\q
After the database setup, the following steps are followed to set up the project:
-
Clone the repository:
git clone https://github.com/lmiguelvargasf/planner.git
-
Navigate into the project directory:
cd planner
-
Install the project dependencies using PDM:
pdm install
-
Install the pre-commit hooks for the repository:
pre-commit install
-
Copy the
.env.example
file to.env
:cp .env.example .env
Open the
.env
file and replace the placeholders in theDATABASE_URL
with the appropriate values. The connection string should reflect the values used in the Database Setup section. For example:DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/planner
In this example,
postgres
is the username and password,localhost
is the host,5432
is the port (default PostgreSQL port), andplanner
is the database. -
Run the project:
pdm run start
-
Access the application by clicking on the following link:
localhost:8000
. The following response should be seen:{"status": "up"}
pytest
is used for testing.
To enhance the testing capabilities, the following plugins are integrated with pytest
:
pytest-asyncio
- to facilitate testing of code that uses theasyncio
library.pytest-mock
- to ease mocking.
Execute the following command to run the tests:
pdm run test
It is encouraged the use of Jupyter notebooks for data analysis and exploration to facilitate interactive development and data visualization.
- Storage: Please place all notebooks in the
./notebooks
directory. - Naming Convention: Name the notebooks using the format
YYYY-MM-DD_brief_description.ipynb
. This convention organizes notebooks chronologically and provides a quick insight into their contents.
To maintain a clean repository, the nbstripout
pre-commit hook is used to strip outputs from Jupyter notebooks, which can significantly reduce file sizes.
JupyterLab can be launched using the following command:
dotenv run jupyter lab --notebook-dir=./notebooks
It can also be initiated through pdm scripts:
pdm run lab
Executing either command starts the JupyterLab server, enabling access to notebooks via the web interface.