Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
Chart Analyzer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zeinab.rostom
Chart Analyzer
Commits
460139e0
Commit
460139e0
authored
Jul 26, 2025
by
ZeinabRm13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Register
parent
ebbdeac4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
59 additions
and
14 deletions
+59
-14
main.cpython-312.pyc
__pycache__/main.cpython-312.pyc
+0
-0
main.py
main.py
+15
-1
config.cpython-312.pyc
src/__pycache__/config.cpython-312.pyc
+0
-0
authentication_service.cpython-312.pyc
...rvices/__pycache__/authentication_service.cpython-312.pyc
+0
-0
authentication_service.py
src/application/services/authentication_service.py
+3
-2
config.py
src/config.py
+2
-1
sql_user_repository.cpython-312.pyc
...sqlserver/__pycache__/sql_user_repository.cpython-312.pyc
+0
-0
mappers.cpython-312.pyc
...ers/sqlserver/mappers/__pycache__/mappers.cpython-312.pyc
+0
-0
mappers.py
src/infrastructure/adapters/sqlserver/mappers/mappers.py
+23
-0
sql_user_repository.py
src/infrastructure/adapters/sqlserver/sql_user_repository.py
+16
-10
No files found.
__pycache__/main.cpython-312.pyc
View file @
460139e0
No preview for this file type
main.py
View file @
460139e0
...
@@ -2,12 +2,26 @@ from fastapi import FastAPI
...
@@ -2,12 +2,26 @@ from fastapi import FastAPI
from
src.infrastructure.api.fastapi.routes
import
auth
,
charts
from
src.infrastructure.api.fastapi.routes
import
auth
,
charts
from
fastapi.middleware.cors
import
CORSMiddleware
from
fastapi.middleware.cors
import
CORSMiddleware
app
=
FastAPI
(
from
sqlalchemy
import
create_engine
from
sqlalchemy.exc
import
OperationalError
app
=
FastAPI
(
debug
=
"True"
,
title
=
"Chart Analyzer API"
,
title
=
"Chart Analyzer API"
,
description
=
"API for analyzing charts and managing users."
,
description
=
"API for analyzing charts and managing users."
,
version
=
"1.0.0"
,
version
=
"1.0.0"
,
)
)
@
app
.
on_event
(
"startup"
)
async
def
startup_event
():
engine
=
create_engine
(
"postgresql+psycopg://chart_analyzer_user:chartanalyzer13@localhost:5432/chart_analyzer"
)
try
:
with
engine
.
connect
()
as
conn
:
print
(
"✅ Database connection successful"
)
print
(
f
"🔗 Connection string: postgresql+psycopg://chart_analyzer_user:chartanalyzer13@localhost:5432/chart_analyzer"
)
except
OperationalError
as
e
:
print
(
"❌ Database connection failed"
)
print
(
f
"Error: {e}"
)
# Configure CORS
# Configure CORS
app
.
add_middleware
(
app
.
add_middleware
(
CORSMiddleware
,
CORSMiddleware
,
...
...
src/__pycache__/config.cpython-312.pyc
View file @
460139e0
No preview for this file type
src/application/services/__pycache__/authentication_service.cpython-312.pyc
View file @
460139e0
No preview for this file type
src/application/services/authentication_service.py
View file @
460139e0
...
@@ -4,6 +4,7 @@ from jose import jwt
...
@@ -4,6 +4,7 @@ from jose import jwt
from
passlib.context
import
CryptContext
from
passlib.context
import
CryptContext
from
src.domain.ports.repositories.user_repository
import
UserRepositoryPort
from
src.domain.ports.repositories.user_repository
import
UserRepositoryPort
from
src.domain.entities.user
import
User
from
src.domain.entities.user
import
User
from
src.config
import
Settings
import
uuid
import
uuid
from
src.application.ports.authentication_service_port
import
AuthServicePort
from
src.application.ports.authentication_service_port
import
AuthServicePort
from
src.application.dtos.authentication
import
(
from
src.application.dtos.authentication
import
(
...
@@ -12,12 +13,12 @@ from src.application.dtos.authentication import (
...
@@ -12,12 +13,12 @@ from src.application.dtos.authentication import (
UserResponseDTO
,
UserResponseDTO
,
TokenResponseDTO
TokenResponseDTO
)
)
settings
=
Settings
()
class
AuthService
(
AuthServicePort
):
class
AuthService
(
AuthServicePort
):
def
__init__
(
def
__init__
(
self
,
self
,
user_repo
:
UserRepositoryPort
,
user_repo
:
UserRepositoryPort
,
secret_key
:
str
,
secret_key
:
str
=
settings
.
JWT_SECRET
,
algorithm
:
str
=
"HS256"
,
algorithm
:
str
=
"HS256"
,
expires_minutes
:
int
=
30
expires_minutes
:
int
=
30
):
):
...
...
src/config.py
View file @
460139e0
...
@@ -2,9 +2,10 @@
...
@@ -2,9 +2,10 @@
from
pydantic
import
ConfigDict
from
pydantic
import
ConfigDict
from
pydantic_settings
import
BaseSettings
from
pydantic_settings
import
BaseSettings
class
Settings
(
BaseSettings
):
class
Settings
(
BaseSettings
):
DATABASE_URL
:
str
=
"postgresql+psycopg://chart_analyzer_user:chartanalyzer13@localhost:5432/chart_analyzer"
DATABASE_URL
:
str
=
"postgresql+psycopg://chart_analyzer_user:chartanalyzer13@localhost:5432/chart_analyzer"
JWT_SECRET
:
str
=
"
a_very_secret_key
"
JWT_SECRET
:
str
=
"
zKReJQaoTK_F9Y2EIkDKZS1hgnfOZsplgzbjXY7IWyc
"
JWT_ALGORITHM
:
str
=
"HS256"
JWT_ALGORITHM
:
str
=
"HS256"
JWT_EXPIRE_MINUTES
:
int
=
30
JWT_EXPIRE_MINUTES
:
int
=
30
...
...
src/infrastructure/adapters/sqlserver/__pycache__/sql_user_repository.cpython-312.pyc
View file @
460139e0
No preview for this file type
src/infrastructure/adapters/sqlserver/mappers/__pycache__/mappers.cpython-312.pyc
0 → 100644
View file @
460139e0
File added
src/infrastructure/adapters/sqlserver/mappers/mappers.py
0 → 100644
View file @
460139e0
# src/infrastructure/adapters/sqlserver/mappers/mappers.py
from
src.domain.entities.user
import
User
as
UserEntity
from
src.infrastructure.adapters.sqlserver.models
import
User
as
UserModel
def
user_model_to_entity
(
model
:
UserModel
)
->
UserEntity
:
return
UserEntity
(
id
=
str
(
model
.
id
),
email
=
model
.
email
,
password_hash
=
model
.
password_hash
,
is_active
=
model
.
is_active
,
created_at
=
model
.
created_at
,
last_login
=
model
.
last_login
)
def
user_entity_to_model
(
entity
:
UserEntity
)
->
UserModel
:
return
UserModel
(
id
=
entity
.
id
,
email
=
entity
.
email
,
password_hash
=
entity
.
password_hash
,
is_active
=
entity
.
is_active
,
created_at
=
entity
.
created_at
,
last_login
=
entity
.
last_login
)
\ No newline at end of file
src/infrastructure/adapters/sqlserver/sql_user_repository.py
View file @
460139e0
# src/infrastructure/adapters/sql_user_repository.py
# src/infrastructure/adapters/sql
server/sql
_user_repository.py
from
sqlalchemy
import
select
from
sqlalchemy
import
select
from
src.domain.ports
import
UserRepositoryPort
from
src.domain.entities.user
import
User
from
sqlalchemy.ext.asyncio
import
AsyncSession
from
sqlalchemy.ext.asyncio
import
AsyncSession
from
pydantic
import
EmailStr
from
src.domain.ports
import
UserRepositoryPort
from
src.infrastructure.adapters.sqlserver.models
import
User
as
UserModel
from
src.domain.entities.user
import
User
as
UserEntity
from
src.infrastructure.adapters.sqlserver.mappers.mappers
import
user_model_to_entity
,
user_entity_to_model
class
SqlUserRepository
(
UserRepositoryPort
):
class
SqlUserRepository
(
UserRepositoryPort
):
def
__init__
(
self
,
session
:
AsyncSession
):
def
__init__
(
self
,
session
:
AsyncSession
):
self
.
_session
=
session
self
.
_session
=
session
async
def
get_by_email
(
self
,
email
:
EmailStr
)
->
User
|
None
:
async
def
get_by_email
(
self
,
email
:
str
)
->
UserEntity
|
None
:
result
=
await
self
.
_session
.
execute
(
result
=
await
self
.
_session
.
execute
(
select
(
User
)
.
where
(
User
.
email
==
email
))
select
(
UserModel
)
.
where
(
UserModel
.
email
==
email
)
return
result
.
scalar_one_or_none
()
)
model
=
result
.
scalar_one_or_none
()
return
user_model_to_entity
(
model
)
if
model
else
None
async
def
create_user
(
self
,
user
:
User
)
->
None
:
async
def
create_user
(
self
,
user
:
UserEntity
)
->
UserEntity
:
self
.
_session
.
add
(
user
)
model
=
user_entity_to_model
(
user
)
await
self
.
_session
.
commit
()
self
.
_session
.
add
(
model
)
\ No newline at end of file
await
self
.
_session
.
commit
()
await
self
.
_session
.
refresh
(
model
)
return
user_model_to_entity
(
model
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment