Skip to content

Commit 2ef553d

Browse files
committed
Init clean architecture
0 parents  commit 2ef553d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1773
-0
lines changed

.data/rest/http-client.env.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"local": {
3+
"api_url": "http://api.pingguardian.local"
4+
}
5+
}

.data/rest/rest-api.http

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POST {{api_url}}/api/auth/login
2+
Content-Type: application/x-www-form-urlencoded
3+
4+
username = test_user &
5+
password = secret
6+
7+
###

README.md

Whitespace-only changes.

config/__init__.py

Whitespace-only changes.

config/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for config project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
15+
16+
application = get_asgi_application()

config/settings.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
"""
2+
Django settings for config project.
3+
4+
Generated by 'django-admin startproject' using Django 5.0.4.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/5.0/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
from decouple import config, Csv
16+
17+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
18+
BASE_DIR = Path(__file__).resolve().parent.parent
19+
20+
ENVIRONMENT = config("ENVIRONMENT")
21+
22+
# Quick-start development settings - unsuitable for production
23+
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
24+
25+
# SECURITY WARNING: keep the secret key used in production secret!
26+
SECRET_KEY = "django-insecure-g6z%-qt1hor10d$pt=r&ny3eu!u%5)7*=itpz+8vja$0b6-z_d"
27+
28+
# SECURITY WARNING: don't run with debug turned on in production!
29+
DEBUG = True
30+
31+
ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=Csv())
32+
33+
34+
# Application definition
35+
36+
INSTALLED_APPS = [
37+
"django.contrib.admin",
38+
"django.contrib.auth",
39+
"django.contrib.contenttypes",
40+
"django.contrib.sessions",
41+
"django.contrib.messages",
42+
"django.contrib.staticfiles",
43+
"src.demo",
44+
"src.auth.infrastructure",
45+
]
46+
47+
MIDDLEWARE = [
48+
"django.middleware.security.SecurityMiddleware",
49+
"django.contrib.sessions.middleware.SessionMiddleware",
50+
"django.middleware.common.CommonMiddleware",
51+
"django.middleware.csrf.CsrfViewMiddleware",
52+
"django.contrib.auth.middleware.AuthenticationMiddleware",
53+
"django.contrib.messages.middleware.MessageMiddleware",
54+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
55+
]
56+
57+
ROOT_URLCONF = "config.urls"
58+
59+
TEMPLATES = [
60+
{
61+
"BACKEND": "django.template.backends.django.DjangoTemplates",
62+
"DIRS": [],
63+
"APP_DIRS": True,
64+
"OPTIONS": {
65+
"context_processors": [
66+
"django.template.context_processors.debug",
67+
"django.template.context_processors.request",
68+
"django.contrib.auth.context_processors.auth",
69+
"django.contrib.messages.context_processors.messages",
70+
],
71+
},
72+
},
73+
]
74+
75+
WSGI_APPLICATION = "config.wsgi.application"
76+
77+
78+
# Database
79+
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
80+
81+
DATABASES = {
82+
"default": {
83+
"ENGINE": "django.db.backends.postgresql",
84+
"NAME": config("DB_NAME"),
85+
"USER": config("DB_USER"),
86+
"PASSWORD": config("DB_PASSWORD"),
87+
"HOST": config("DB_HOST"),
88+
"PORT": "5432",
89+
}
90+
}
91+
92+
MIGRATION_MODULES = {
93+
"pingguardian_auth": "src.auth.infrastructure.persistence.database.migrations"
94+
}
95+
96+
# Password validation
97+
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
98+
99+
AUTH_PASSWORD_VALIDATORS = [
100+
{
101+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
102+
},
103+
{
104+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
105+
},
106+
{
107+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
108+
},
109+
{
110+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
111+
},
112+
]
113+
114+
AUTH_USER_MODEL = "pingguardian_auth.User"
115+
116+
# Internationalization
117+
# https://docs.djangoproject.com/en/5.0/topics/i18n/
118+
119+
LANGUAGE_CODE = "en-us"
120+
121+
TIME_ZONE = "UTC"
122+
123+
USE_I18N = True
124+
125+
USE_TZ = True
126+
127+
128+
# Static files (CSS, JavaScript, Images)
129+
# https://docs.djangoproject.com/en/5.0/howto/static-files/
130+
131+
STATIC_URL = "static/"
132+
133+
# Default primary key field type
134+
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
135+
136+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
137+
138+
139+
if ENVIRONMENT == "local" and DEBUG:
140+
import pydevd_pycharm
141+
142+
try:
143+
pydevd_pycharm.settrace(
144+
"host.docker.internal",
145+
port=3000,
146+
stdoutToServer=True,
147+
stderrToServer=True,
148+
suspend=False,
149+
)
150+
except Exception:
151+
pass

config/urls.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.contrib import admin
2+
from django.urls import path
3+
from ninja import NinjaAPI
4+
5+
api = NinjaAPI()
6+
7+
api.add_router("/demo", "src.demo.infrastructure.ui.api.demo_router")
8+
api.add_router("/auth", "src.auth.infrastructure.ui.api.auth_router")
9+
10+
urlpatterns = [
11+
path("admin/", admin.site.urls),
12+
path("api/", api.urls),
13+
]

config/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for config project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
15+
16+
application = get_wsgi_application()

manage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
4+
import os
5+
import sys
6+
7+
8+
def main():
9+
"""Run administrative tasks."""
10+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
11+
try:
12+
from django.core.management import execute_from_command_line
13+
except ImportError as exc:
14+
raise ImportError(
15+
"Couldn't import Django. Are you sure it's installed and "
16+
"available on your PYTHONPATH environment variable? Did you "
17+
"forget to activate a virtual environment?"
18+
) from exc
19+
execute_from_command_line(sys.argv)
20+
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)