Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend initial commit #1

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,26 @@ info.zip
.gitlab-ci.yml

# postgres local storage
postgres-data/
postgres-data/

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 2 additions & 2 deletions alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[alembic]
# path to migration scripts
# Use forward slashes (/) also on windows to provide an os agnostic path
script_location = src/utils/migrations
script_location = backend/utils/migrations

# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
Expand All @@ -13,7 +13,7 @@ script_location = src/utils/migrations

# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = . src
prepend_sys_path = . backend

# timezone to use when rendering the date within the migration file
# as well as the filename.
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/account/crud.py → backend/account/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import Optional
from uuid import UUID

from src.utils.database import db_manager
from src.wordle.constants import GameStatus
from backend.utils.database import db_manager
from backend.wordle.constants import GameStatus


async def get_random_word_id_from_db() -> int:
Expand Down
2 changes: 1 addition & 1 deletion src/account/schemas.py → backend/account/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import BaseModel

from src.wordle.dtos import UserGameSession
from backend.wordle.dtos import UserGameSession


class UserInfoResponse(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions src/account/services.py → backend/account/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from datetime import datetime
from typing import Optional

from src.account.crud import (
from backend.account.crud import (
create_game_session,
get_random_word_id_from_db,
update_game_session_finish_time,
)
from src.wordle.constants import GameStatus
from backend.wordle.constants import GameStatus


async def create_new_game_session(owner_id: Optional[int] = None) -> uuid.UUID:
Expand Down
8 changes: 4 additions & 4 deletions src/account/views.py → backend/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from fastapi import APIRouter, Depends

from src.account.schemas import UserInfoResponse
from src.auth.constants import API_RESPONSES
from src.auth.dependencies import validate_access_token
from src.auth.service import get_current_active_auth_user
from backend.account.schemas import UserInfoResponse
from backend.auth.constants import API_RESPONSES
from backend.auth.dependencies import validate_access_token
from backend.auth.service import get_current_active_auth_user

router = APIRouter()

Expand Down
16 changes: 8 additions & 8 deletions src/app.py → backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from src.account.views import router as account_router
from src.auth.views import router as auth_router
from src.leaderboard.views import router as leaderboard_router
from src.security import cors_settings
from src.utils.database import db_manager
from src.utils.rsa_keys_manager import keys_manager
from src.wordle.crud import remove_not_used_game_sessions
from src.wordle.views import router as wordle_router
from backend.account.views import router as account_router
from backend.auth.views import router as auth_router
from backend.leaderboard.views import router as leaderboard_router
from backend.security import cors_settings
from backend.utils.database import db_manager
from backend.utils.rsa_keys_manager import keys_manager
from backend.wordle.crud import remove_not_used_game_sessions
from backend.wordle.views import router as wordle_router


@asynccontextmanager
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/auth/constants.py → backend/auth/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass

from src.account.schemas import GameSessionResponse, UserInfoResponse
from src.auth.schemas import JWTResponse
from backend.account.schemas import GameSessionResponse, UserInfoResponse
from backend.auth.schemas import JWTResponse


@dataclass(init=False, repr=False, eq=False, frozen=True, match_args=False)
Expand Down
2 changes: 1 addition & 1 deletion src/auth/crud.py → backend/auth/crud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
from typing import Any, Dict, Optional

from src.utils.database import db_manager
from backend.utils.database import db_manager


async def add_user(
Expand Down
16 changes: 8 additions & 8 deletions src/auth/dependencies.py → backend/auth/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
from fastapi import Request, Response
from jwt.exceptions import InvalidTokenError

from src.auth.constants import token_types
from src.auth.crud import (
from backend.auth.constants import token_types
from backend.auth.crud import (
get_user_by_username,
)
from src.auth.exceptions import HTTP401Unauthorized
from src.auth.schemas import UserRegistration
from src.auth.security import OAuth2PasswordBearerWithCookie
from src.auth.service import (
from backend.auth.exceptions import HTTP401Unauthorized
from backend.auth.schemas import UserRegistration
from backend.auth.security import OAuth2PasswordBearerWithCookie
from backend.auth.service import (
get_access_refresh_tokens,
get_current_active_auth_user,
get_remove_tokens_headers,
)
from src.auth.utils import decode_jwt, password_check, username_check
from src.exceptions import HTTP400BadRequest
from backend.auth.utils import decode_jwt, password_check, username_check
from backend.exceptions import HTTP400BadRequest

oauth2_scheme = OAuth2PasswordBearerWithCookie(token_url='/auth/tokens')

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/auth/security.py → backend/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fastapi.security import OAuth2
from password_strength import PasswordPolicy

from src.auth.exceptions import HTTP401Unauthorized
from backend.auth.exceptions import HTTP401Unauthorized


class OAuth2PasswordBearerWithCookie(OAuth2):
Expand Down
16 changes: 8 additions & 8 deletions src/auth/service.py → backend/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
from fastapi import Response
from starlette.datastructures import MutableHeaders

from src.auth.config import auth_config, cookie_config
from src.auth.constants import token_types
from src.auth.crud import (
from backend.auth.config import auth_config, cookie_config
from backend.auth.constants import token_types
from backend.auth.crud import (
add_user,
get_user_by_id,
get_user_by_username,
)
from src.auth.exceptions import HTTP401Unauthorized
from src.auth.schemas import (
from backend.auth.exceptions import HTTP401Unauthorized
from backend.auth.schemas import (
JWTResponse,
UserAuthentication,
UserRegistration,
ValidatedUserAuthentication,
)
from src.auth.utils import (
from backend.auth.utils import (
encode_jwt,
hash_password,
validate_password,
)
from src.exceptions import HTTP400BadRequest
from src.utils.models.models import User
from backend.exceptions import HTTP400BadRequest
from backend.utils.models.models import User


async def get_current_active_auth_user(
Expand Down
8 changes: 4 additions & 4 deletions src/auth/utils.py → backend/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import bcrypt
import jwt

from src.auth.config import auth_config
from src.auth.constants import user_data_validation
from src.auth.security import password_policy
from src.utils.rsa_keys_manager import keys_manager
from backend.auth.config import auth_config
from backend.auth.constants import user_data_validation
from backend.auth.security import password_policy
from backend.utils.rsa_keys_manager import keys_manager


def username_check(
Expand Down
10 changes: 5 additions & 5 deletions src/auth/views.py → backend/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
)
from starlette.responses import JSONResponse

from src.auth.config import cookie_config
from src.auth.constants import API_RESPONSES
from src.auth.dependencies import validate_refresh_token, validate_user_creation
from src.auth.schemas import (
from backend.auth.config import cookie_config
from backend.auth.constants import API_RESPONSES
from backend.auth.dependencies import validate_refresh_token, validate_user_creation
from backend.auth.schemas import (
JWTResponse,
UserAuthentication,
UserRegistration,
ValidatedUserAuthentication,
)
from src.auth.service import (
from backend.auth.service import (
auth_user,
confirm_user,
get_access_refresh_tokens,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/leaderboard/crud.py → backend/leaderboard/crud.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import List

from src.leaderboard.constants import NUMBER_PRECISION
from src.leaderboard.schemas import UserStats
from src.utils.database import db_manager
from backend.leaderboard.constants import NUMBER_PRECISION
from backend.leaderboard.schemas import UserStats
from backend.utils.database import db_manager


async def get_user_stats(user_id: int) -> UserStats:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from src.leaderboard.crud import get_leaderboard_stats, get_user_stats
from src.leaderboard.schemas import LeaderboardResponse
from backend.leaderboard.crud import get_leaderboard_stats, get_user_stats
from backend.leaderboard.schemas import LeaderboardResponse


async def get_leaderboard_info(
Expand Down
8 changes: 4 additions & 4 deletions src/leaderboard/views.py → backend/leaderboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

from fastapi import APIRouter, Depends

from src.auth.dependencies import validate_access_token
from src.auth.service import get_current_active_auth_user
from src.leaderboard.schemas import LeaderboardResponse
from src.leaderboard.services import get_leaderboard_info
from backend.auth.dependencies import validate_access_token
from backend.auth.service import get_current_active_auth_user
from backend.leaderboard.schemas import LeaderboardResponse
from backend.leaderboard.services import get_leaderboard_info

router = APIRouter()

Expand Down
4 changes: 2 additions & 2 deletions src/main.py → backend/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uvicorn

from src.app import app
from src.config import settings
from backend.app import app
from backend.config import settings

if __name__ == '__main__':
uvicorn.run(
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from asyncpg import create_pool

from src.config import settings
from backend.config import settings


async def load_words_from_file(file_path: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/utils/database.py → backend/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from asyncpg import Pool, create_pool
from asyncpg.connection import Connection

from src.config import settings
from backend.config import settings


class _DatabaseManager:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from alembic import context
from sqlalchemy import engine_from_config, pool

from src.config import settings
from src.utils.models.models import Base
from backend.config import settings
from backend.utils.models.models import Base

config = context.config

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy.dialects.postgresql import UUID as PGUUID
from sqlalchemy.ext.declarative import declarative_base

from src.wordle.constants import GameStatus
from backend.wordle.constants import GameStatus

Base = declarative_base()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/wordle/crud.py → backend/wordle/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from typing import List
from uuid import UUID

from src.utils.database import db_manager
from src.wordle.dtos import GameSessionInfo, UserGameSession
from backend.utils.database import db_manager
from backend.wordle.dtos import GameSessionInfo, UserGameSession


async def get_word_id_by_word(word: str) -> int:
Expand Down
8 changes: 4 additions & 4 deletions src/wordle/dependencies.py → backend/wordle/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from src.exceptions import HTTP400BadRequest
from src.wordle.constants import MAX_WORD_LENGTH
from src.wordle.crud import check_game_session_exists, get_word_id_by_word
from src.wordle.schemas import WordleRequestCheckWord
from backend.exceptions import HTTP400BadRequest
from backend.wordle.constants import MAX_WORD_LENGTH
from backend.wordle.crud import check_game_session_exists, get_word_id_by_word
from backend.wordle.schemas import WordleRequestCheckWord


async def validate_word_data(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/wordle/schemas.py → backend/wordle/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import BaseModel, Field

from src.wordle.constants import GameStatus, WordTypes
from backend.wordle.constants import GameStatus, WordTypes


class WordleResponseCheckWord(BaseModel):
Expand Down
8 changes: 4 additions & 4 deletions src/wordle/services.py → backend/wordle/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

from fastapi import HTTPException, status

from src.wordle import constants as con
from src.wordle.crud import (
from backend.wordle import constants as con
from backend.wordle.crud import (
add_attempt,
finish_game_by_session_id,
get_game_session_info_by_session_id,
get_game_sessions_by_user_id,
)
from src.wordle.dtos import UserGameSession
from src.wordle.schemas import (
from backend.wordle.dtos import UserGameSession
from backend.wordle.schemas import (
WordleResponseCheckWord,
WordleResponseCheckWordFinish,
)
Expand Down
Loading
Loading