Skip to content

Commit

Permalink
#24-backend-imp-crud-for-users-model (#109)
Browse files Browse the repository at this point in the history
* #24-backend: Put first fast-api crud

* #24-backend-imp-crud-24-backend-imp-crud-feature-auth-repo-changes: renamed auth to user repo and files

* 24-backend-imp-crud-for-users-model-feature-new-develop-docker-compose: add develop docker-compose to work out

* 24-backend-imp-crud-feature-create-profile: separate auth and user, correct names, structure, imports

* 24-backend-imp-crud-feature-create-profile: delete auth old files

* 24-backend-imp-crud-feature-create-profile: change some global exceptions and correct verify_jwt exceptions, get_current_user exceptions and change return

* 24-backend-imp-crud-feature-create-profile: add dev build extra

* 24-backend-imp-crud-feature-create-profile: rebuild all models

* 24-backend-imp-crud-feature-create-profile: push users image to storage

* 24-backend-imp-crud-feature-create-profile: technic push to refactor all models with new redis pub/sub communicator

* 24-backend-imp-24-backend-imp-crud-for-users-model: add develop docker and run app

* 24-backend-imp-24-backend-imp-crud-for-users-model: add redis cache pub/sub for models

* 24-backend-imp-crud-for-users-model: Recreate system to navigate pub/sub in classes

* 24-backend-imp-crud-for-users-model: Correct endpoints in user service for change_password_view

* 24-backend-imp-crud-for-users-model: Correct gh actions docker to dev docker-compose basic

* 24-backend-imp-crud-for-users-model: first code review corrections

* 24-backend-imp-crud-for-users-model: second code review corrections

* 24-backend-imp-crud-for-users-model: remove image from profile_service.py

* 224-backend-imp-crud-for-users-model: add schema to names

* 224-backend-imp-crud-for-users-model: removed all image from users/profiles this created in media urls

* 224-backend-imp-crud-for-users-model: remove delete profile because users do it with relations and profile image is not needed here

* 224-backend-imp-crud-for-users-model: cleanup

* 224-backend-imp-crud-for-users-model: returned read_version docs, removed abs from init cache handler, router remove unused import

* 24-backend-imp-crud-for-users-model: returned read_version docs, removed abs from init cache handler, router remove unused import
  • Loading branch information
radthenone authored Mar 22, 2024
1 parent 46ff705 commit 7b3a69d
Show file tree
Hide file tree
Showing 79 changed files with 2,072 additions and 560 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "backend/requirements.txt"
cache-dependency-path: "web/requirements.txt"
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
Expand Down
46 changes: 46 additions & 0 deletions README.DEV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Develop app

### enviroments:
backend/.env

````bash
POSTGRES_HOST=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=triplane
POSTGRES_DB=postgres-triplane
POSTGRES_PORT=5432

SECRET_KEY=test
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=300
REFRESH_TOKEN_EXPIRE_DAYS=365

CORS_ORIGINS=http://localhost:8083

MINIO_HOST_URL=minio:9000
MINIO_ACCESS_KEY=superuser
MINIO_SECRET_KEY=superuser
MINIO_SECURE=False

FASTAPI_HOST=localhost
FASTAPI_PORT=8000
DEBUG=0

CACHE_STORAGE_HOST=redis
CACHE_STORAGE_PORT=6379
CACHE_STORAGE_PASSWORD=redis
CACHE_STORAGE_DB=1
CACHE_STORAGE_EXP=86400
````

### start app
````bash
docker-compose -f docker-compose.dev.yml up --build -d
````

### debug
you can use:
````bash
python ./web/src/run_app.py
````

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Mobile, Web and Rest API
In our project, we use a configuration file that loads environment variables. This allows us to interact with them. The configuration file is located at:

```bash
src/backend/core/configs.py
src/web/core/configs.py
```

### Initializing Environment Variables
Expand Down
2 changes: 1 addition & 1 deletion backend/README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```bash
cd backend
cd web
```

```bash
Expand Down
11 changes: 11 additions & 0 deletions backend/docker/redis/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM redis:7.2

WORKDIR /redis

COPY init.sh ./

RUN chmod +x ./init.sh

EXPOSE 6379

CMD ["./init.sh"]
22 changes: 22 additions & 0 deletions backend/docker/redis/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# if any of the commands in your code fails for any reason, the entire script fails
set -o errexit
# fail exit if one of your pipe command fails
set -o pipefail
# exits if any of your variables is not set
set -o nounset

echo "Add sysctl vm.overcommit_memory=1"
echo "1" > /proc/sys/vm/overcommit_memory

export REDIS_PASSWORD="${CACHE_STORAGE_PASSWORD}"

echo "Starting redis server..."

echo "Redis server is up"

# Start redis server
redis-server --bind 0.0.0.0 --requirepass "${REDIS_PASSWORD}" --maxmemory 256mb --maxmemory-policy allkeys-lru --appendonly yes

echo "Redis server started"

16 changes: 16 additions & 0 deletions backend/docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.11 AS base

WORKDIR /app
ADD . /app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONBUFFERED 1

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY ./docker/web/backend.sh /backend.sh
RUN sed -i 's/\r$//g' /backend.sh && chmod +x /backend.sh

ENTRYPOINT ["/backend.sh"]
16 changes: 16 additions & 0 deletions backend/docker/web/backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# if any of the commands in your code fails for any reason, the entire script fails
set -o errexit
# fail exit if one of your pipe command fails
set -o pipefail
# exits if any of your variables is not set
set -o nounset

export FASTAPI_HOST=$FASTAPI_HOST
export FASTAPI_PORT=$FASTAPI_PORT

if [ "${FASTAPI_HOST}" = "localhost" ]; then
export FASTAPI_HOST=0.0.0.0
fi

uvicorn src.main:app --host "${FASTAPI_HOST}" --port "${FASTAPI_PORT}" --reload
4 changes: 3 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ select = [
"F404",
"TCH",
]
ignore = []
ignore = [
"PGH004",
]
fixable = ["ALL"]
unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
Expand Down
Binary file modified backend/requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/src/attraction/repositories/attraction_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
AttractionSchema,
AttractionSortedBy,
)
from src.core.common_schema import SortDirection
from src.common.schemas.common_schema import SortDirection

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion backend/src/attraction/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pydantic import BaseModel

from src.core.common_schema import SortDirection
from src.common.schemas.common_schema import SortDirection
from src.file.models.schemas import MediaRead


Expand Down
1 change: 1 addition & 0 deletions backend/src/attraction/services/geocoding_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from requests import Session
from requests.exceptions import HTTPError, RequestException

from src.core.configs import GEOCODES_CO_API_KEY

logger = logging.getLogger(__name__)
Expand Down
14 changes: 0 additions & 14 deletions backend/src/auth/constants.py

This file was deleted.

46 changes: 0 additions & 46 deletions backend/src/auth/exceptions.py

This file was deleted.

5 changes: 0 additions & 5 deletions backend/src/auth/interfaces/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions backend/src/auth/interfaces/repository.py

This file was deleted.

5 changes: 0 additions & 5 deletions backend/src/auth/repositories/__init__.py

This file was deleted.

68 changes: 0 additions & 68 deletions backend/src/auth/repositories/auth_repo.py

This file was deleted.

2 changes: 1 addition & 1 deletion backend/src/auth/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.auth.routes.router import router as auth_router
from src.auth.routes.auth_router import router as auth_router

__all__ = [
"auth_router",
Expand Down
Loading

0 comments on commit 7b3a69d

Please sign in to comment.