The project is a set of APIs for crypto exchange and related functionalities.
- Prerequisites
- Installation
- Running the App Manually
- Running the App via Docker (incomplete!)
- Configuration
- Load Data
- Testing
Before you begin, ensure you have the following installed on your machine:
- Python 3.12+
- pip (Python package installer)
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/hamidrasti/xcrypto.git cd xcrypto
-
Set up a virtual environment (optional but recommended):
python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`
-
Install the Python dependencies:
pip install -r requirements/development.txt
Once the dependencies are installed, you can run the Django project manually.
-
Run the Application:
- Use the django server to run the app:
python manage.py runserver
- By default, the app will be available at: http://127.0.0.1:8000
-
Access the Interactive API Docs:
- This project provides interactive API documentation using Swagger UI:
- Go to http://127.0.0.1:8000/api/schema/swagger/ for the Swagger UI documentation.
- Alternatively, visit http://127.0.0.1:8000/api/schema/redoc for ReDoc documentation.
- You can also import the
X Crypto.postman_collection.json
to Postman.
If you'd like to run the app using Docker, follow these steps:
-
Build the Docker Image:
docker compose build
-
Run the Docker Container:
- Use the following command to start the application with Docker:
docker compose up -d
- This will start the Django project along with any other services defined in your docker-compose.yml file (e.g., databases, caching services, etc.).
-
Stopping the Container:
docker compose down
-
Accessing the Application:
- The app will be available at http://localhost:8000 (or the port defined in your Docker setup).
- Access the API docs at:
- You can also import the
X Crypto.postman_collection.json
to Postman.
- You can define environment variables in a .env file or in the docker-compose.yml file for configuration purposes (e.g., database credentials, API keys).
- Make sure to adapt the Docker and Python settings as needed for production use (e.g., setting up proper logging, configuring uwsgi, etc.).
You can load fixtures provided for users, cryptos and orders using:
python manage.py loaddata
Now we have two users with this info:
-
admin
{ "username": "admin", "password": "pass123456" }
-
hamid
{ "username": "hamid", "password": "pass" }
Execute this command:
pytest
or this:
python manage.py test
Run this commands to get coverage report:
coverage run --source='.' manage.py test
coverage report