Skip to content

TatyOko28/crypto_exchange

Repository files navigation

Crypto Exchange Platform

A cryptocurrency exchange platform with advanced features, including real-time exchange rates, an OTC (Over-the-Counter) market, wallet management, and a secure verification process


Platform Architecture and Functional Modules

Homepage

  • Real-Time Exchange Rates: Display exchange rate trends between various national currencies and cryptocurrencies.
  • News Section: Integrates the latest cryptocurrency news from various sources, providing links and summaries for quick access to market updates.

OTC Market Trading List

  • Active Orders: Shows all active buy and sell orders.
  • Buy Orders: Users can view all orders selling cryptocurrencies.
  • Sell Orders: Users can view all demand orders to buy cryptocurrencies.
  • Initiating Trades: Users can click on any order to view detailed information and proceed with transactions.

Personal Homepage (Wallet Information)

  • Balance Display: Shows the user's account balance on the platform.
  • Transaction History: Lists all historical transactions of the user, with filters to view bought or sold orders.
  • Transaction Security Code: Users set and manage their own transaction security code for transaction confirmation.
  • Customer Service Window: Provides instant help to resolve any platform-related issues.

Development and Deployment Workflow

Local Setup Options

You can set up the project locally using either Docker (recommended for consistent environments) or manual Python commands.


Using Docker

Prerequisites:

  1. Install Docker and Docker Compose.
  2. Clone the repository:
    git clone https://github.com/username/project.git
    cd project

Database Configuration:

Before starting, ensure your database settings are correctly configured:

  1. Check the database settings in .env.docker:

    • POSTGRES_DB
    • POSTGRES_USER
    • POSTGRES_PASSWORD
    • POSTGRES_HOST
    • POSTGRES_PORT
  2. If you need to modify these settings, update them in:

    • .env.docker for Docker environment
    • .env.local for local development
    • docker-compose.yml (ensure the database service configuration matches)

Note: If you change database credentials, ensure they match across all configuration files.

Steps:

  1. For Docker, copy .env.docker to .env:

    cp .env.docker .env
  2. Start the containers:

    docker-compose down -v  # Clean start by removing volumes
    docker-compose up -d --build  # Build and start containers in detached mode
  3. Verify containers are running:

    docker-compose ps  # All containers should show status "running"
  4. Wait for the database to be ready:

    docker-compose logs db  # Check if PostgreSQL is ready to accept connections
  5. Apply migrations in the correct order:

    # First, apply Django's default migrations
    docker-compose exec web python manage.py migrate auth
    docker-compose exec web python manage.py migrate contenttypes
    docker-compose exec web python manage.py migrate admin
    docker-compose exec web python manage.py migrate sessions
    
    # Then, apply third-party app migrations
    docker-compose exec web python manage.py migrate django_celery_beat
    
    # Finally, apply all project app migrations
    docker-compose exec web python manage.py migrate authentication
    docker-compose exec web python manage.py migrate wallet
    docker-compose exec web python manage.py migrate market
    docker-compose exec web python manage.py migrate news
    docker-compose exec web python manage.py migrate rates
    docker-compose exec web python manage.py migrate support
    
    # Alternative: apply all migrations at once
    docker-compose exec web python manage.py migrate

    Then, check that the tables are created correctly

    docker-compose exec db psql -U postgres -d crypto_exchange_1 -c '\dt'
    
  6. Create a superuser:

    # First, ensure the database is ready and migrations are applied
    docker-compose logs db  # Verify database is running
    docker-compose exec db psql -U postgres -d crypto_exchange_1 -c '\dt'  # Verify tables exist
    
    # Then create the superuser
    docker-compose exec web python manage.py createsuperuser
  7. Access the application:


To stop the application later

docker-compose down

To restart it quickly next time

docker-compose down
docker-compose up -d

Using Python Locally (Without Docker)

Prerequisites:

  1. Install Python 3.9+ and PostgreSQL.
  2. Set up a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows, use venv\Scripts\activate

Steps:

  1. Clone the repository:

    git clone https://github.com/username/project.git
    cd project
  2. For local development, copy .env.local to .env:

    cp .env.local .env

    Note: This configuration uses "localhost" as PostgreSQL host for local development.

  3. Install dependencies:

    pip install -r requirements.txt
  4. Apply migrations and create a superuser:

    python manage.py migrate
    python manage.py createsuperuser
  5. Run the development server:

    python manage.py runserver
  6. Access the application:


Testing the Application

Using Docker:

  1. Run all tests:

    docker-compose exec web python manage.py test
  2. Check test coverage:

    docker-compose exec web coverage run manage.py test
    docker-compose exec web coverage report

Using Python Locally:

  1. Run all tests:

    python manage.py test
  2. Run tests for specific apps:

    python manage.py test authentication
    python manage.py test wallet
  3. Generate test coverage report:

    coverage run manage.py test
    coverage report
    coverage html  # Generates an HTML report

Production Deployment

Using Docker (Recommended):

  1. Secure environment variables with a service like AWS Secrets Manager or create a secure .env file.
  2. Update docker-compose.prod.yml for production settings.
  3. Deploy the application:
    docker-compose -f docker-compose.prod.yml up --build

Features

  • WebSocket: Real-time updates for exchange rates.
  • Swagger/OpenAPI: Interactive API documentation.
  • Email Notifications: Alerts and notifications for user activities.
  • Security: JWT-based authentication and transaction security code.

Support

For questions or assistance, contact tatyoko28@gmail.com.


Screenshots

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5 Screenshot 6 Screenshot 7 Screenshot 8 Screenshot 9 Screenshot 10 Screenshot 11 Screenshot 12 Screenshot 13

Environment Configuration

The project uses two different configuration files depending on the execution mode:

For Local Development (py manage.py runserver)

  1. Ensure PostgreSQL is running locally on your machine
  2. Copy .env.local to .env:
    cp .env.local .env
    This configuration uses:
    • POSTGRES_HOST=localhost
    • REDIS_URL=redis://localhost:6379/0

For Docker Development (docker-compose up)

  1. Copy .env.docker to .env:
    cp .env.docker .env
    This configuration uses:
    • POSTGRES_HOST=db (Docker service name)
    • REDIS_URL=redis://redis:6379/0 (Docker service name)

Important Notes:

  • Never use 'db' as host when running locally with py manage.py runserver
  • Never use 'localhost' as host when running with Docker
  • If you switch between Docker and local development:
    # For local development
    cp .env.local .env
    
    # For Docker
    cp .env.docker .env

Technologies Used

Backend

  • Python 3.9+: Core programming language
  • Django 4.2+: Web framework
  • Django REST Framework: API development
  • Celery: Asynchronous task processing
  • Channels: WebSocket support
  • PostgreSQL: Primary database
  • Redis: Caching and message broker

Security & Authentication

  • JWT: Token-based authentication
  • Argon2: Password hashing
  • Django CORS Headers: Cross-Origin Resource Sharing
  • Django Rate Limit: API rate limiting

Testing & Quality

  • Pytest: Testing framework
  • Factory Boy: Test data generation
  • Coverage: Code coverage reporting
  • Flake8: Code linting
  • Black: Code formatting
  • isort: Import sorting

Documentation

  • Swagger/OpenAPI: API documentation
  • drf-yasg: Swagger generator

File Storage & Processing

  • AWS S3: Cloud storage
  • Pillow: Image processing
  • Whitenoise: Static files serving

Monitoring & Logging

  • Sentry: Error tracking
  • Django Debug Toolbar: Development debugging

Task Scheduling

  • django-celery-beat: Periodic task scheduling

Development & Deployment

  • Docker: Containerization
  • Docker Compose: Multi-container orchestration
  • Python Dotenv: Environment variables management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages