Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
3889c03
add git ignore to repo
bigsbug Jul 17, 2022
6e4fba1
init project
bigsbug Jul 17, 2022
d135386
remove SQLite db
bigsbug Jul 17, 2022
6dfd846
create SDK for Kucoin website
bigsbug Jul 17, 2022
c454d36
remove unless imports
bigsbug Jul 17, 2022
47b9675
fix typo
bigsbug Jul 17, 2022
a0ad163
remove logs
bigsbug Jul 17, 2022
47319b0
add new arg to raw_query
bigsbug Jul 17, 2022
629f7ab
impove the vars name in the raw_query
bigsbug Jul 17, 2022
e0ee09e
inital new apps
bigsbug Jul 17, 2022
07059ab
refector raw_query
bigsbug Jul 18, 2022
225089f
change privacy of generate_signature and add new parameters
bigsbug Jul 18, 2022
8e6d39b
add new mehod to convert dict to json
bigsbug Jul 18, 2022
bd8317a
new methods based on raw_query
bigsbug Jul 18, 2022
b92d34f
add default value to args of post_query
bigsbug Jul 18, 2022
bbfa66d
add default value to args of get_query and parse paramters
bigsbug Jul 18, 2022
7a3b1f4
interface of SDKs
bigsbug Jul 18, 2022
a62b461
add new imports and sorts them
bigsbug Jul 18, 2022
5868637
implements the abstracts
bigsbug Jul 18, 2022
e2e83ae
document the SDK
bigsbug Jul 18, 2022
42e0711
nomalize the url
bigsbug Jul 18, 2022
1dfe84a
register apps
bigsbug Jul 18, 2022
48714fe
add tools encryptor and decryptor data
bigsbug Jul 18, 2022
a3b8acb
add __init__ file to root
bigsbug Jul 18, 2022
fb6800f
fix key of the encryption
bigsbug Jul 18, 2022
fa0f538
models of accounts
bigsbug Jul 18, 2022
878a0eb
add releation to User model
bigsbug Jul 18, 2022
bcbf784
create custom user and register it
bigsbug Jul 20, 2022
2f4beb9
add user API
bigsbug Jul 20, 2022
b9afab5
add KucoinAccount API and models
bigsbug Jul 20, 2022
1ec5074
register models
bigsbug Jul 20, 2022
93988cb
add swagger to project
bigsbug Jul 20, 2022
dab6cfa
remvoe logs
bigsbug Jul 20, 2022
1137e25
improve name
bigsbug Jul 20, 2022
0b2cfe4
add migrations
bigsbug Jul 20, 2022
985149a
active user by default
bigsbug Jul 21, 2022
5e3b947
cache endpoints by headers
bigsbug Jul 21, 2022
df7bcd8
sdk api for get all acccounts
bigsbug Jul 21, 2022
43200df
a service to update accounts of users:
bigsbug Jul 21, 2022
fb6573c
add new endpoint to feach and show open position
bigsbug Jul 21, 2022
ab5c751
improve endpoints
bigsbug Jul 21, 2022
672f6c7
add migrations
bigsbug Jul 21, 2022
ca6d8a1
improve imports
bigsbug Jul 21, 2022
1f75872
add requiremtns to project
bigsbug Jul 21, 2022
841c319
set default db to postgres
bigsbug Jul 21, 2022
728159f
remove authentication session
bigsbug Jul 21, 2022
f50667e
remove encrypt key from settings
bigsbug Jul 21, 2022
35d4510
remove authentication session
bigsbug Jul 21, 2022
a6b3bca
load data from envs
bigsbug Jul 21, 2022
8758a89
add envs and confings
bigsbug Jul 21, 2022
faa830b
docrizing project
bigsbug Jul 21, 2022
d24dac4
fix path
bigsbug Jul 21, 2022
a9c6a7a
run celery worker and beat
bigsbug Jul 21, 2022
a8b47d9
add backend cache redis to django
bigsbug Jul 21, 2022
063d76d
fix load env path and imports
bigsbug Jul 21, 2022
6a31423
fix imports and paths
bigsbug Jul 21, 2022
48ef861
installer services
bigsbug Jul 21, 2022
f219fd5
add new dependancy
bigsbug Jul 21, 2022
719197e
add static path
bigsbug Jul 21, 2022
f678b18
fix base path
bigsbug Jul 21, 2022
1943106
change folder statics
bigsbug Jul 21, 2022
f2a6042
change folder statics
bigsbug Jul 21, 2022
5906821
add manager.py corsponding for django service
bigsbug Jul 21, 2022
46dc54d
add lookup field
bigsbug Jul 21, 2022
fe2e457
remove whitespaces
bigsbug Jul 21, 2022
7af57cf
Disable SandBox Mode
bigsbug Jul 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.pyc
__pycache__
*.swp
*.env
.vscode
*.sqlite
static/*
Empty file added __init__.py
Empty file.
5 changes: 5 additions & 0 deletions active_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set -o allexport
. ./config/gunicorn.dev.env
. ./config/django.dev.env
. ./config/postgres.dev.env
set +o allexport
Empty file added config/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions config/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for CryptoReader project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.dev")

application = get_asgi_application()
8 changes: 8 additions & 0 deletions config/django.dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# DJANGO CONFIG
REQUIREMENTS_FILE=/src/requirements/dev.txt # This Env Required For Building Dockerfile of Djanog Service
DJANGO_SETTINGS_MODULE=config.settings.dev
SECRET_KEY="i0cwcl!$e54^#0vh6q^)$!+l=_at##a%#0q2&!g$$dau*d2rg8"
ENCRYPT_KEY="f7DwTK5K6EwmA30THAxnXgBKy_v969ItANlVGhi4C-0="
ALLOWED_HOSTS="* localhost 127.0.0.1"
DEBUG=True # Default : False
APPEND_SLASH=True # Default : True
7 changes: 7 additions & 0 deletions config/gunicorn.dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Django & Nginx Service
DJANGO_IP="0.0.0.0"
DJANGO_PORT=8181

# gunicorn Service
WORKERS_COUNT=2
EXTRA_ARGS=""
28 changes: 28 additions & 0 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 80;

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://django;
}

location /static {
# path for static files
alias /statics/;
}
}

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream django {
server django:${DJANGO_PORT};
}
4 changes: 4 additions & 0 deletions config/postgres.dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# POSTGRES CONFIG
POSTGRES_DB=djangoCryptoReader
POSTGRES_USER=django
POSTGRES_PASSWORD=django-password
Empty file added config/settings/__init__.py
Empty file.
123 changes: 123 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
Django settings for CryptoReader project.

Generated by 'django-admin startproject' using Django 4.0.5.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-s#0r5^_%a3-4ts9ug==i4^xy&x2py@hq3_i+!k@2^i)l-v@c=9"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

AUTH_USER_MODEL = "accounts.User"
# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "config.urls.dev"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "config.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = "static/"

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
73 changes: 73 additions & 0 deletions config/settings/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from config.settings.base import *

import environ
import os

env = environ.Env()
environ.Env.read_env(os.path.join(BASE_DIR / "config/django.dev.env"))

SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")

ALLOWED_HOSTS = str(env("ALLOWED_HOSTS")).strip('"').strip().split()
APPEND_SLASH = env("APPEND_SLASH")

# encrypt key for encrypting and decrypting data
# generated with cryptography.fernet.Fernet.generate_key()
ENCRYPT_KEY = env("ENCRYPT_KEY")
# ENCRYPT_KEY = b"f7DwTK5K6EwmA30THAxnXgBKy_v969ItANlVGhi4C-0="

INSTALLED_APPS += [
"rest_framework",
"drf_spectacular",
"drf_spectacular_sidecar",
"cryptoreader.accounts",
"cryptoreader.api",
]


ROOT_URLCONF = "config.urls.dev"

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": env("POSTGRES_DB"),
"USER": env("POSTGRES_USER"),
"PASSWORD": env("POSTGRES_PASSWORD"),
"HOST": "postgres",
"PORT": "5432",
}
}

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://redis:6379/1",
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient"},
"KEY_PREFIX": "django_",
}
}

REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}

SPECTACULAR_SETTINGS = {
"TITLE": "Crypto Rader ",
"DESCRIPTION": "Crypot Reader Challnge From Nilva Co",
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
"SWAGGER_UI_DIST": "SIDECAR",
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
"REDOC_DIST": "SIDECAR",
}

STATIC_URL = "/static/"
STATIC_ROOT = BASE_DIR / "static"
STATICFILES_DIRS = []
Empty file added config/urls/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions config/urls/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""CryptoReader URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
]
27 changes: 27 additions & 0 deletions config/urls/dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.urls import include
from config.urls.base import *

from drf_spectacular.views import (
SpectacularAPIView,
SpectacularRedocView,
SpectacularSwaggerView,
)


urlpatterns += [
path(
"api/v1/",
include(("cryptoreader.api.urls", "API/V1")),
),
path("api/v1/schema/", SpectacularAPIView.as_view(), name="schema"),
path(
"api/v1/schema/swagger-ui/",
SpectacularSwaggerView.as_view(url_name="schema"),
name="swagger-ui",
),
path(
"api/v1/schema/redoc/",
SpectacularRedocView.as_view(url_name="schema"),
name="redoc",
),
]
16 changes: 16 additions & 0 deletions config/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for CryptoReader project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.dev")

application = get_wsgi_application()
Empty file added cryptoreader/__init__.py
Empty file.
Binary file added cryptoreader/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Empty file.
17 changes: 17 additions & 0 deletions cryptoreader/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.contrib import admin
from .models import KucoinAccount, User

# Register your models here.
class KucoinAccountModelAdmin(admin.ModelAdmin):
list_display = [
"user",
"type",
"currency",
"balance",
"available",
"holds",
]


admin.site.register(KucoinAccount, KucoinAccountModelAdmin)
admin.site.register(User)
6 changes: 6 additions & 0 deletions cryptoreader/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "cryptoreader.accounts"
Loading