This project is a RESTful API for management of medical clinics, developed using FastAPI. It includes database management with PostgreSQL, dependency management with Poetry, and containerization with Docker Compose. The following steps contain commands to be executed only in a Linux terminal. For Windows, I recommend using Git Bash.
Before running the application, ensure you have the following installed:
- Python 3.12.3: Download Python 3.12.3
- Poetry: Installation Guide
- Docker: Docker Installation
- Docker Compose: Docker Compose Installation
Start by cloning the repository to your local machine and then access the directory:
git clone https://github.com/lucassaporetti/lifemed.git
cd lifemed
To ensure dependencies are managed correctly, create a Python virtual environment and activate it:
python3.9 -m venv venv
source venv/bin/activate
This isolates your Python environment from the global environment, preventing version conflicts.
Use Poetry for dependency management. Install the required Python dependencies:
poetry install
Build and run the Docker containers with:
docker-compose up --build
This command builds the Docker images and starts the PostgreSQL container. It also ensures the database is initialized with lifemed_db schema.
To start the FastAPI application, leave docker running and open another terminal tab. Just use the makefile command on it:
make run
Or, if you want, use Uvicorn command. You can run it directly with:
uvicorn lifemed_api.components.api.api:app --reload
Once the application is running, you can access the API documentation at:
Swagger UI: http://127.0.0.1:8000/swagger
ReDoc: http://127.0.0.1:8000/docs
These URLs provide interactive documentation for testing and exploring the API.
To facilitate testing, you can generate a JWT token directly via the API. This token will be valid for 1 hour.
Send a GET request to the /generate_token
route:
curl -X GET "http://localhost:8000/generate_token
Port Conflicts: Ensure that no other services are using the ports specified in the docker-compose.yml (e.g., port 5432 for PostgreSQL).
Docker Logs: If the database fails to initialize correctly, check Docker logs for errors.
Feel free to contribute to the project by submitting issues or pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.