Hello Readers!
This is a just learning project for me using boilerplate code from Faraday Academy.
Repo link of this project from Faraday Academy: https://github.com/faraday-academy/fast-api-lms
This project is a learning management system where professors (supervisors) can manage student (users) and students (users) can see their courses.
The project will be similar to the project from Faraday Academy but with more advances from where the Repo is left by Faraday Academy.
- Install
git
,podman
,postgresql
,poetry
andvirtualenv
on your development environment.
Command$ sudo dnf install git podman postgresql poetry virtualenv
- Ensure that
podman
service is enabled and started.
CommandSample output$ sudo systemctl enable podman.service
CommandCreated symlink /etc/systemd/system/default.target.wants/podman.service → /usr/lib/systemd/system/podman.service.
$ sudo systemctl start podman.service
- Clone the repository to the local storage.
CommandSample output$ git clone https://github.com/sdglitched/fast-api-lms.git
Cloning into 'fast-api-lms'... remote: Enumerating objects: 79, done. remote: Counting objects: 100% (79/79), done. remote: Compressing objects: 100% (60/60), done. remote: Total 79 (delta 25), reused 61 (delta 15), pack-reused 0 Receiving objects: 100% (79/79), 41.84 KiB | 209.00 KiB/s, done. Resolving deltas: 100% (25/25), done.
- Download the official
postgres
image fromdocker.io/library/quay.io
OCI images repository and start a container with your preferred settings.
CommandSample output$ podman pull docker.io/library/postgres:latest
Command (Keep as /home/Trying to pull docker.io/library/postgres:latest... Getting image source signatures Copying blob c200c670beef done | Copying blob 13808c22b207 done | Copying blob e59e71301578 done | Copying blob 30258475ebe6 done | Copying blob dc0c37c3ab3c done | Copying blob 80df7455ae43 done | Copying blob d051a616a810 done | Copying blob 87c27dce0c4d done | Copying blob 9dae96d37274 done | Copying blob 9b9e5e72a98e done | Copying blob 73301da916ba done | Copying blob 673a1691030a done | Copying blob 16d03b1cb8d8 done | Copying blob 9d680d6449b5 done | Copying config d60dc4bd84 done | Writing manifest to image destination d60dc4bd84c0a07f26f1eb9feefcc94d1dbb3a2d478a0b705aa5e7311353108b
user
/fast-api-lms/db:)Command$ podman run \ --name <CONTAINER-NAME> \ --env POSTGRES_USER=<DATABASE-USERNAME> \ --env POSTGRES_PASSWORD=<DATABASE-PASSWORD> \ --env POSTGRES_DB=<DATABASE-NAME> \ --env PGDATA=/var/lib/postgresql/data/pgdata \ --volume <MOUNT-LOCATION>:/var/lib/postgresql/data:Z \ --publish 5432:5432 \ --restart unless-stopped \ --detach postgres:latest
Sample output$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3f766ea080a9 docker.io/library/postgres:latest postgres 3 minutes ago Up 3 minutes 0.0.0.0:5432->5432/tcp lms_container
- Create a virtual environment in the said directory and activate it.
CommandSample output$ virtualenv venv
Commandcreated virtual environment CPython3.12.2.final.0-64 in 433ms creator CPython3Posix(dest=/home/`user`/fast-api-lms/venv, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(extra_search_dir=/usr/share/python-wheels,download=False, pip=bundle, via=copy, app_data_dir=/home/`user`/.local/share/virtualenv) added seed packages: pip==23.2.1 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Sample output$ source venv/bin/activate
(venv) $
- Install the project dependencies.
CommandSample output(venv) $ poetry check
CommandAll set!
Sample output(venv) $ poetry install
Installing dependencies from lock file Package operations: 19 installs, 0 updates, 0 removals • Installing idna (3.4) • Installing sniffio (1.3.0) • Installing typing-extensions (4.8.0) • Installing annotated-types (0.6.0) • Installing anyio (3.7.1) • Installing greenlet (3.0.0) • Installing markupsafe (2.1.3) • Installing pydantic-core (2.10.1) • Installing click (8.1.7) • Installing h11 (0.14.0) • Installing mako (1.2.4) • Installing pydantic (2.4.2) • Installing sqlalchemy (2.0.22) • Installing starlette (0.27.0) • Installing alembic (1.12.1) • Installing fastapi (0.103.2) • Installing psycopg2-binary (2.9.9) • Installing sqlalchemy-utils (0.41.1) • Installing uvicorn (0.23.2)
- Run the development server.
Command
uvicorn main:app --reload