Crypto-Buyer-API is a Django-based REST API that allows users to view, buy, and manage their balances of cryptocurrencies. It uses PostgreSQL as its database management system.
Before running the project, you'll need to have the following installed on your machine:
- Python 3
- PostgreSQL
- Docker (if running with Docker)
This project uses environment variables to store sensitive information such as database credentials. To run the project, you'll need to create a .env
file in the root directory of your project and add the required variables.
- Create a
.env
file in the root directory of your project:
touch .env
-
Open the
.env.sample
file and copy its contents, paste the contents of the.env.sample
file into the.env
file. -
Replace the default values of the variables with your own values.
POSTGRES_USER=your_postgres_username
POSTGRES_PASSWORD=your_postgres_password
POSTGRES_DB=your_database_name
POSTGRES_HOST=your_database_host
POSTGRES_PORT=your_database_port
ADMIN_FIRST_NAME=your_admin_first_name
ADMIN_LAST_NAME=your_admin_last_name
ADMIN_EMAIL=your_admin_email
ADMIN_PASSWORD=your_admin_password
Save the .env
file.
To run the project locally, follow these steps:
- Ensure that PostgreSQL is installed and running locally.
- Clone the repository to your local machine:
git clone https://github.com/fatemeh-mgsdi/crypto-buyer-api.git
cd crypto-buyer-api/
- Install the project's dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Create a superuser account:
python manage.py create_superuser
- Run the development server:
python manage.py runserver
Once the server is running, you can access the API at http://localhost:8000/.
To run the project using Docker, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/fatemeh-mgsdi/crypto-buyer-api.git
cd crypto-buyer-api/
- Build and start the Docker containers:
docker-compose build
docker-compose --env-file=.env up
Once the containers are running, you can access the API at http://localhost:8000/.
To run the tests, follow these steps:
- Activate the virtual environment:
source venv/bin/activate
- Ensure that the project's dependencies are installed:
pip install -r requirements.txt
- Run the tests:
python manage.py test
This will run all the tests in the project.
Once the tests have completed running, you should see a summary of the test results in your terminal.