Skip to content

gasimovv21/currencyApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

75 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CurrencyApp

CurrencyApp is a comprehensive backend application for managing users, currency accounts, transactions, and currency conversions. Built with Django Rest Framework, the app supports secure user management and real-time currency exchange using external APIs.


Key Features

  • User Registration and Authentication: Secure user registration and login functionality.
  • Currency Account Management:
    • Default PLN account creation upon registration.
    • Create, edit, and delete additional currency accounts.
    • Protection against deletion of default PLN accounts or accounts with non-zero balances.
  • Currency Conversion:
    • Real-time exchange rates fetched from the NBP API.
    • Support for multiple currencies (e.g., USD, EUR, GBP).
    • Automatic updates for account balances during conversions.
  • Transaction and History Tracking:
    • Detailed logs of all transactions and account activities (deposits, withdrawals).
    • Filter transactions by user and date.
  • Deposits:
    • Deposit money into specific currency accounts.
    • Maintain a history of deposits for better financial tracking.

Technologies

  • Backend: Django, Django Rest Framework
  • Database: SQLite (default), with support for other databases via Django settings
  • Real-Time API: Integration with NBP API for live currency exchange rates

Installation and Setup

Prerequisites

  • Python 3.11
  • pip

Installation Steps

  1. Clone the repository:

    git clone https://github.com/gasimovv21/currencyApp.git
  2. Install Expo into the frontend file by saving own project files:

    cd currencyApp/currencyApp/frontend
    mkdir ../temp-frontend
    move * ../temp-frontend/
    cd ..
    npx create-expo-app@latest frontend --template blank
    xcopy temp-frontend\* frontend\ /E /Y
    cd frontend
    npm install
    Remove-Item -Recurse -Force ../temp-frontend
  3. Install backend dependencies:

    cd ..
    pip install -r requirements.txt
  4. Set up and activate a virtual environment:

    cd ..
    python -m venv venv
  • Go to an IDE, open project folder and on terminal (bash) activate:
    source venv/Scripts/Activate  # Windows
    source venv/bin/activate      # Linux/Mac
  1. Run migrations:
    python manage.py makemigrations
    python manage.py migrate
  • (In the case of error: try it on new bash terminal)
  1. Set up the frontend:
  • Check your IPv4 address to set baseURL for running the server on your local network.
    ipconfig
  • Look for your "Wireless LAN adapter Wi-Fi" section, and note your IPv4 address (e.g., 192.168.x.x).
  • Open the App.js file and insert your IPv4 address at the specified location on line 17.
  1. Start the Django development server and the Expo:
  • Start API server using your IPv4 address:
    python manage.py runserver <your_IPv4_here>:8000
  • Start Expo Inside frontend:
    npx expo start
  1. Access the API: Open http://<your_IPv4_here>:8000/api/ in your browser or Postman.

Running the Backend in Docker

Requirements

Instructions

  1. Clone the repository:
    git clone https://github.com/gasimovv21/currencyApp
    cd currencyApp
    
  2. Build and run the Docker containers::
  • Find file below and uncomment "psycopg2-binary".
    ./currencyApp/currencyApp/requirements.txt
    
  • Find file below and comment DATABASES commented for Docker and Comment default DATABASES.
    ./currencyApp/currencyApp/currencyApp/settings.py
    
  • Now ready to compose up.
    docker-compose up --build
    
  1. Run migrations in Docker console:

    python manage.py migrate
  2. Create superuser for django administrations:

    python manage.py createsuperuser
  3. Access the API: The backend will be available at::

    http://localhost:8000
    
    Test endpoints by navigating to:
    
    http://localhost:8000/api/
    
  4. Stop the Docker containers: To stop and remove containers, networks, and volumes created by docker-compose, run::

    docker-compose down --volumes
    

Usage

User Management

  • Register a new user using the /api/register/ endpoint.
  • Log in to manage your accounts and transactions securely.

Currency Account Management

  • Each user starts with a PLN account by default.
  • Create additional accounts for supported currencies like USD, EUR, and GBP.
  • Manage account balances, view transaction histories, and handle deposits.

Currency Conversion

  • Convert currencies using real-time exchange rates fetched from the NBP API.
  • Ensure sufficient funds are available in the source account.

Deposit Management

  • Deposit money into any of your accounts.
  • Track all deposits using the deposit history endpoints.

API Endpoints

User Management

Method Endpoint Description
POST /api/register/ Register a new user
POST /api/login/ Login a user
POST /api/logout/ Logout a user
GET /api/users/ List all users
GET /api/users/<id>/ Get user details
PUT /api/users/<id>/ Update user details
DELETE /api/users/<id>/ Delete a user

Currency Accounts

Method Endpoint Description
GET /api/currency-accounts/ List all currency accounts
GET /api/currency-accounts/<id>/ Get details of a specific account
POST /api/currency-accounts/ Create a new currency account
PUT /api/currency-accounts/<id>/ Update a currency account
DELETE /api/currency-accounts/<id>/ Delete a currency account
GET /api/currency-accounts/user/<id>/ Get accounts for a specific user

Transactions

Method Endpoint Description
POST /api/currency-accounts/convert/<id>/ Convert between currencies
GET /api/currency-accounts/convert/<id>/ View transaction history for a user

Deposits

Method Endpoint Description
POST /api/currency-accounts/deposit/<id>/ Deposit money into a currency account
GET /api/currency-accounts/deposit/<id>/ View deposit history for a user

Account History

Method Endpoint Description
GET /api/currency-accounts/history/<id>/ View account history for a user

Notes

  • Default Currency Account: Each user automatically gets a PLN account upon registration.
  • Real-time Exchange Rates: The app fetches live exchange rates using the NBP API.
  • Password Security: All user passwords are securely hashed using Django’s built-in utilities.

Future Improvements

  • Add JWT authentication for more robust session handling.
  • Build a frontend app using React or Vue.js.
  • Implement automated testing for all endpoints.

Database Design

View Database Design


Use Case Diagram

View Use Case Diagram


Class Diagram

Show Class Diagram


License

This project is licensed under the MIT License. See the LICENSE file for more details.


Authors πŸ‘¨πŸ’» πŸ‘¨πŸ’» πŸ‘¨πŸ’»

  • Ahmet Eren Artam - 41155 | Recep Enes Karatekin - 40796 | Eltun Gasimov - 41160

About

CurrencyApp is a comprehensive backend application for managing users, currency accounts, transactions, and currency conversions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors