From 9f12de89a205b46051b3ff3f1aa5d9da1db7b88b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20C=C3=A1rdenas?= Date: Tue, 10 Sep 2024 07:01:35 -0500 Subject: [PATCH] feat: #52 created missing repositories - update also endpoints - change api welcome message --- app/api/endpoints/activity.py | 65 ++++++++++++++++++ app/api/endpoints/answer.py | 65 ++++++++++++++++++ app/api/endpoints/question.py | 65 ++++++++++++++++++ app/api/endpoints/study_session.py | 71 ++++++++++++++++++++ app/database/models.py | 61 ++++++++--------- app/database/session.py | 3 +- app/repositories/activity_repository.py | 35 ++++++++++ app/repositories/answer_repository.py | 33 +++++++++ app/repositories/question_repository.py | 37 ++++++++++ app/repositories/study_session_repository.py | 45 +++++++++++++ app/repositories/user_repository.py | 8 +-- app/schemas/activity.py | 7 +- app/schemas/answer.py | 16 ++--- app/schemas/question.py | 10 ++- app/schemas/study_session.py | 12 ++-- app/schemas/user.py | 18 ++--- main.py | 10 ++- 17 files changed, 484 insertions(+), 77 deletions(-) create mode 100644 app/api/endpoints/activity.py create mode 100644 app/api/endpoints/answer.py create mode 100644 app/api/endpoints/question.py create mode 100644 app/api/endpoints/study_session.py create mode 100644 app/repositories/activity_repository.py create mode 100644 app/repositories/answer_repository.py create mode 100644 app/repositories/question_repository.py create mode 100644 app/repositories/study_session_repository.py diff --git a/app/api/endpoints/activity.py b/app/api/endpoints/activity.py new file mode 100644 index 0000000..5acdda1 --- /dev/null +++ b/app/api/endpoints/activity.py @@ -0,0 +1,65 @@ +# app/api/endpoints/activity.py + +from fastapi import ( + APIRouter, + Depends, + HTTPException, +) +from sqlalchemy.orm import Session +from app.database.session import get_db +from app.schemas.activity import ( + ActivityCreate, + ActivityUpdate, + ActivityInDBBase, +) +from app.repositories.activity_repository import ( + create_activity, + get_activity, + get_activities, + update_activity, + delete_activity, +) + +router = APIRouter() + + +@router.post("/activities/", response_model=ActivityInDBBase) +def create_activity_endpoint( + activity: ActivityCreate, db: Session = Depends(get_db) +) -> ActivityInDBBase: + return create_activity(db, activity) + + +@router.get("/activities/{activity_id}", response_model=ActivityInDBBase) +def read_activity(activity_id: int, db: Session = Depends(get_db)) -> ActivityInDBBase: + activity = get_activity(db, activity_id) + if activity is None: + raise HTTPException(status_code=404, detail="Activity not found") + return activity + + +@router.get("/activities/", response_model=list[ActivityInDBBase]) +def read_activities( + skip: int = 0, limit: int = 10, db: Session = Depends(get_db) +) -> list[ActivityInDBBase]: + return get_activities(db, skip, limit) + + +@router.put("/activities/{activity_id}", response_model=ActivityInDBBase) +def update_activity_endpoint( + activity_id: int, activity: ActivityUpdate, db: Session = Depends(get_db) +) -> ActivityInDBBase: + db_activity = get_activity(db, activity_id) + if db_activity is None: + raise HTTPException(status_code=404, detail="Activity not found") + return update_activity(db, activity_id, activity.model_dump()) + + +@router.delete("/activities/{activity_id}", response_model=ActivityInDBBase) +def delete_activity_endpoint( + activity_id: int, db: Session = Depends(get_db) +) -> ActivityInDBBase: + activity = delete_activity(db, activity_id) + if activity is None: + raise HTTPException(status_code=404, detail="Activity not found") + return activity diff --git a/app/api/endpoints/answer.py b/app/api/endpoints/answer.py new file mode 100644 index 0000000..06c132b --- /dev/null +++ b/app/api/endpoints/answer.py @@ -0,0 +1,65 @@ +# app/api/endpoints/answer.py + +from fastapi import ( + APIRouter, + Depends, + HTTPException, +) +from sqlalchemy.orm import Session +from app.database.session import get_db +from app.schemas.answer import ( + AnswerCreate, + AnswerUpdate, + AnswerInDBBase, +) +from app.repositories.answer_repository import ( + create_answer, + get_answer, + get_answers, + update_answer, + delete_answer, +) + +router = APIRouter() + + +@router.post("/answers/", response_model=AnswerInDBBase) +def create_answer_endpoint( + answer: AnswerCreate, db: Session = Depends(get_db) +) -> AnswerInDBBase: + return create_answer(db, answer) + + +@router.get("/answers/{answer_id}", response_model=AnswerInDBBase) +def read_answer(answer_id: int, db: Session = Depends(get_db)) -> AnswerInDBBase: + answer = get_answer(db, answer_id) + if answer is None: + raise HTTPException(status_code=404, detail="Answer not found") + return answer + + +@router.get("/answers/", response_model=list[AnswerInDBBase]) +def read_answers( + skip: int = 0, limit: int = 10, db: Session = Depends(get_db) +) -> list[AnswerInDBBase]: + return get_answers(db, skip, limit) + + +@router.put("/answers/{answer_id}", response_model=AnswerInDBBase) +def update_answer_endpoint( + answer_id: int, answer: AnswerUpdate, db: Session = Depends(get_db) +) -> AnswerInDBBase: + db_answer = get_answer(db, answer_id) + if db_answer is None: + raise HTTPException(status_code=404, detail="Answer not found") + return update_answer(db, answer_id, answer.model_dump()) + + +@router.delete("/answers/{answer_id}", response_model=AnswerInDBBase) +def delete_answer_endpoint( + answer_id: int, db: Session = Depends(get_db) +) -> AnswerInDBBase: + answer = delete_answer(db, answer_id) + if answer is None: + raise HTTPException(status_code=404, detail="Answer not found") + return answer diff --git a/app/api/endpoints/question.py b/app/api/endpoints/question.py new file mode 100644 index 0000000..16a1da3 --- /dev/null +++ b/app/api/endpoints/question.py @@ -0,0 +1,65 @@ +# app/api/endpoints/question.py + +from fastapi import ( + APIRouter, + Depends, + HTTPException, +) +from sqlalchemy.orm import Session +from app.database.session import get_db +from app.schemas.question import ( + QuestionCreate, + QuestionUpdate, + QuestionInDBBase, +) +from app.repositories.question_repository import ( + create_question, + get_question, + get_questions, + update_question, + delete_question, +) + +router = APIRouter() + + +@router.post("/questions/", response_model=QuestionInDBBase) +def create_question_endpoint( + question: QuestionCreate, db: Session = Depends(get_db) +) -> QuestionInDBBase: + return create_question(db, question) + + +@router.get("/questions/{question_id}", response_model=QuestionInDBBase) +def read_question(question_id: int, db: Session = Depends(get_db)) -> QuestionInDBBase: + question = get_question(db, question_id) + if question is None: + raise HTTPException(status_code=404, detail="Question not found") + return question + + +@router.get("/questions/", response_model=list[QuestionInDBBase]) +def read_questions( + skip: int = 0, limit: int = 10, db: Session = Depends(get_db) +) -> list[QuestionInDBBase]: + return get_questions(db, skip, limit) + + +@router.put("/questions/{question_id}", response_model=QuestionInDBBase) +def update_question_endpoint( + question_id: int, question: QuestionUpdate, db: Session = Depends(get_db) +) -> QuestionInDBBase: + db_question = get_question(db, question_id) + if db_question is None: + raise HTTPException(status_code=404, detail="Question not found") + return update_question(db, question_id, question.model_dump()) + + +@router.delete("/questions/{question_id}", response_model=QuestionInDBBase) +def delete_question_endpoint( + question_id: int, db: Session = Depends(get_db) +) -> QuestionInDBBase: + question = delete_question(db, question_id) + if question is None: + raise HTTPException(status_code=404, detail="Question not found") + return question diff --git a/app/api/endpoints/study_session.py b/app/api/endpoints/study_session.py new file mode 100644 index 0000000..d237611 --- /dev/null +++ b/app/api/endpoints/study_session.py @@ -0,0 +1,71 @@ +# app/api/endpoints/study_session.py + +from fastapi import ( + APIRouter, + Depends, + HTTPException, +) +from sqlalchemy.orm import Session +from app.database.session import get_db +from app.schemas.study_session import ( + StudySessionCreate, + StudySessionUpdate, + StudySessionInDBBase, +) +from app.repositories.study_session_repository import ( + create_study_session, + get_study_session, + get_study_sessions, + update_study_session, + delete_study_session, +) + +router = APIRouter() + + +@router.post("/study_sessions/", response_model=StudySessionInDBBase) +def create_study_session_endpoint( + study_session: StudySessionCreate, db: Session = Depends(get_db) +) -> StudySessionInDBBase: + return create_study_session(db, study_session) + + +@router.get("/study_sessions/{study_session_id}", response_model=StudySessionInDBBase) +def read_study_session( + study_session_id: int, db: Session = Depends(get_db) +) -> StudySessionInDBBase: + study_session = get_study_session(db, study_session_id) + if study_session is None: + raise HTTPException(status_code=404, detail="StudySession not found") + return study_session + + +@router.get("/study_sessions/", response_model=list[StudySessionInDBBase]) +def read_study_sessions( + skip: int = 0, limit: int = 10, db: Session = Depends(get_db) +) -> list[StudySessionInDBBase]: + return get_study_sessions(db, skip, limit) + + +@router.put("/study_sessions/{study_session_id}", response_model=StudySessionInDBBase) +def update_study_session_endpoint( + study_session_id: int, + study_session: StudySessionUpdate, + db: Session = Depends(get_db), +) -> StudySessionInDBBase: + db_study_session = get_study_session(db, study_session_id) + if db_study_session is None: + raise HTTPException(status_code=404, detail="StudySession not found") + return update_study_session(db, study_session_id, study_session.model_dump()) + + +@router.delete( + "/study_sessions/{study_session_id}", response_model=StudySessionInDBBase +) +def delete_study_session_endpoint( + study_session_id: int, db: Session = Depends(get_db) +) -> StudySessionInDBBase: + study_session = delete_study_session(db, study_session_id) + if study_session is None: + raise HTTPException(status_code=404, detail="StudySession not found") + return study_session diff --git a/app/database/models.py b/app/database/models.py index 9325142..845ade7 100644 --- a/app/database/models.py +++ b/app/database/models.py @@ -1,11 +1,12 @@ -# app/database/models.py - from enum import Enum from sqlalchemy import ( Column, Integer, String, ForeignKey, + Enum as SQLEnum, + Text, + DateTime, ) from sqlalchemy.orm import relationship from app.database.session import Base @@ -18,12 +19,12 @@ class ActivityType(Enum): class User(Base): __tablename__ = "users" - id: Column = Column(Integer, primary_key=True, index=True) - username: Column = Column(String, unique=True, index=True) - email: Column = Column(String, unique=True, index=True) - role: Column = Column(String) - created_at = Column(String) - updated_at = Column(String) + id = Column(Integer, primary_key=True, index=True) + username = Column(String, unique=True, index=True) + email = Column(String, unique=True, index=True) + role = Column(String) + created_at = Column(DateTime) + updated_at = Column(DateTime) study_sessions = relationship("StudySession", back_populates="user") activities = relationship("Activity", back_populates="user") @@ -34,10 +35,10 @@ class User(Base): class StudySession(Base): __tablename__ = "study_sessions" - id: Column = Column(Integer, primary_key=True, index=True) - user_id: Column = Column(Integer, ForeignKey("users.id")) - start_time: Column = Column(String) - end_time: Column = Column(String) + id = Column(Integer, primary_key=True, index=True) + user_id = Column(Integer, ForeignKey("users.id")) + start_time = Column(DateTime) + end_time = Column(DateTime) user = relationship("User", back_populates="study_sessions") activities = relationship("Activity", back_populates="study_session") @@ -46,12 +47,12 @@ class StudySession(Base): class Activity(Base): __tablename__ = "activities" - id: Column = Column(Integer, primary_key=True, index=True) - user_id: Column = Column(Integer, ForeignKey("users.id")) - study_session_id: Column = Column(Integer, ForeignKey("study_sessions.id")) - type: Column = Column(Enum(ActivityType), nullable=False) - activity: Column = Column(String) - created_at = Column(String) + id = Column(Integer, primary_key=True, index=True) + user_id = Column(Integer, ForeignKey("users.id")) + study_session_id = Column(Integer, ForeignKey("study_sessions.id")) + type = Column(SQLEnum(ActivityType), nullable=False) + activity = Column(String) + created_at = Column(DateTime) user = relationship("User", back_populates="activities") study_session = relationship("StudySession", back_populates="activities") @@ -62,10 +63,10 @@ class Activity(Base): class Question(Base): __tablename__ = "questions" - id: Column = Column(Integer, primary_key=True, index=True) - user_id: Column = Column(Integer, ForeignKey("users.id")) - activity_id: Column = Column(Integer, ForeignKey("activities.id")) - question: Column = Column(String) + id = Column(Integer, primary_key=True, index=True) + user_id = Column(Integer, ForeignKey("users.id")) + activity_id = Column(Integer, ForeignKey("activities.id")) + question = Column(String) user = relationship("User", back_populates="questions") answers = relationship("Answer", back_populates="question") @@ -75,16 +76,12 @@ class Question(Base): class Answer(Base): __tablename__ = "answers" - id: Column = Column(Integer, primary_key=True, index=True) - user_id: Column = Column(Integer, ForeignKey("users.id")) - question_id: Column = Column(Integer, ForeignKey("questions.id")) - answer: Column = Column(String) + id = Column(Integer, primary_key=True, index=True) + user_id = Column(Integer, ForeignKey("users.id")) + question_id = Column(Integer, ForeignKey("questions.id")) + answer = Column(Text, nullable=False) + parent_answer_id = Column(Integer, ForeignKey("answers.id")) user = relationship("User", back_populates="answers") question = relationship("Question", back_populates="answers") - parent_answer = relationship( - "Answer", remote_side=[id], back_populates="child_answers" - ) - child_answers = relationship( - "Answer", back_populates="parent_answer", cascade="all, delete-orphan" - ) + parent_answer = relationship("Answer", remote_side=[id], backref="child_answers") diff --git a/app/database/session.py b/app/database/session.py index 87199ef..f55cfde 100644 --- a/app/database/session.py +++ b/app/database/session.py @@ -4,7 +4,6 @@ from typing import Generator from sqlalchemy import ( create_engine, - Engine, ) from sqlalchemy.orm import ( declarative_base, @@ -14,7 +13,7 @@ BASE_DIR: str = os.path.dirname(os.path.abspath(__file__)) DB_PATH: str = os.path.join(BASE_DIR, "../../data/db/aura.db") -engine: Engine = create_engine( +engine = create_engine( f"sqlite:///{DB_PATH}", connect_args={"check_same_thread": False}, ) diff --git a/app/repositories/activity_repository.py b/app/repositories/activity_repository.py new file mode 100644 index 0000000..be2a525 --- /dev/null +++ b/app/repositories/activity_repository.py @@ -0,0 +1,35 @@ +from sqlalchemy.orm import Session +from app.database.models import Activity +from app.schemas.activity import ActivityCreate, ActivityUpdate + + +def create_activity(db: Session, activity: ActivityCreate) -> Activity: + db_activity = Activity(**activity.dict()) + db.add(db_activity) + db.commit() + db.refresh(db_activity) + return db_activity + + +def get_activity(db: Session, activity_id: int) -> Activity: + return db.query(Activity).filter(Activity.id == activity_id).first() + + +def get_activities(db: Session, skip: int = 0, limit: int = 10) -> list[Activity]: + return db.query(Activity).offset(skip).limit(limit).all() + + +def update_activity( + db: Session, activity_id: int, activity: ActivityUpdate +) -> Activity: + db.query(Activity).filter(Activity.id == activity_id).update(activity.dict()) + db.commit() + return db.query(Activity).filter(Activity.id == activity_id).first() + + +def delete_activity(db: Session, activity_id: int) -> Activity: + activity = db.query(Activity).filter(Activity.id == activity_id).first() + if activity: + db.delete(activity) + db.commit() + return activity diff --git a/app/repositories/answer_repository.py b/app/repositories/answer_repository.py new file mode 100644 index 0000000..9199607 --- /dev/null +++ b/app/repositories/answer_repository.py @@ -0,0 +1,33 @@ +from sqlalchemy.orm import Session +from app.database.models import Answer +from app.schemas.answer import AnswerCreate, AnswerUpdate + + +def create_answer(db: Session, answer: AnswerCreate) -> Answer: + db_answer = Answer(**answer.dict()) + db.add(db_answer) + db.commit() + db.refresh(db_answer) + return db_answer + + +def get_answer(db: Session, answer_id: int) -> Answer: + return db.query(Answer).filter(Answer.id == answer_id).first() + + +def get_answers(db: Session, skip: int = 0, limit: int = 10) -> list[Answer]: + return db.query(Answer).offset(skip).limit(limit).all() + + +def update_answer(db: Session, answer_id: int, answer: AnswerUpdate) -> Answer: + db.query(Answer).filter(Answer.id == answer_id).update(answer.dict()) + db.commit() + return db.query(Answer).filter(Answer.id == answer_id).first() + + +def delete_answer(db: Session, answer_id: int) -> Answer: + answer = db.query(Answer).filter(Answer.id == answer_id).first() + if answer: + db.delete(answer) + db.commit() + return answer diff --git a/app/repositories/question_repository.py b/app/repositories/question_repository.py new file mode 100644 index 0000000..c0e23e1 --- /dev/null +++ b/app/repositories/question_repository.py @@ -0,0 +1,37 @@ +# app/repositories/question_repository.py + +from sqlalchemy.orm import Session +from app.database.models import Question +from app.schemas.question import QuestionCreate, QuestionUpdate + + +def create_question(db: Session, question: QuestionCreate) -> Question: + db_question = Question(**question.model_dump()) + db.add(db_question) + db.commit() + db.refresh(db_question) + return db_question + + +def get_question(db: Session, question_id: int) -> Question: + return db.query(Question).filter(Question.id == question_id).first() + + +def get_questions(db: Session, skip: int = 0, limit: int = 10) -> list[Question]: + return db.query(Question).offset(skip).limit(limit).all() + + +def update_question( + db: Session, question_id: int, question: QuestionUpdate +) -> Question: + db.query(Question).filter(Question.id == question_id).update(question.model_dump()) + db.commit() + return db.query(Question).filter(Question.id == question_id).first() + + +def delete_question(db: Session, question_id: int) -> Question: + question = db.query(Question).filter(Question.id == question_id).first() + if question: + db.delete(question) + db.commit() + return question diff --git a/app/repositories/study_session_repository.py b/app/repositories/study_session_repository.py new file mode 100644 index 0000000..25f95c8 --- /dev/null +++ b/app/repositories/study_session_repository.py @@ -0,0 +1,45 @@ +# app/repositories/study_repository.py + +from sqlalchemy.orm import Session +from app.database.models import StudySession +from app.schemas.study_session import StudySessionCreate, StudySessionUpdate + + +def create_study_session( + db: Session, study_session: StudySessionCreate +) -> StudySession: + db_study_session = StudySession(**study_session.model_dump()) + db.add(db_study_session) + db.commit() + db.refresh(db_study_session) + return db_study_session + + +def get_study_session(db: Session, study_session_id: int) -> StudySession: + return db.query(StudySession).filter(StudySession.id == study_session_id).first() + + +def get_study_sessions( + db: Session, skip: int = 0, limit: int = 10 +) -> list[StudySession]: + return db.query(StudySession).offset(skip).limit(limit).all() + + +def update_study_session( + db: Session, study_session_id: int, study_session: StudySessionUpdate +) -> StudySession: + db.query(StudySession).filter(StudySession.id == study_session_id).update( + study_session.model_dump() + ) + db.commit() + return db.query(StudySession).filter(StudySession.id == study_session_id).first() + + +def delete_study_session(db: Session, study_session_id: int) -> StudySession: + study_session = ( + db.query(StudySession).filter(StudySession.id == study_session_id).first() + ) + if study_session: + db.delete(study_session) + db.commit() + return study_session diff --git a/app/repositories/user_repository.py b/app/repositories/user_repository.py index 69686f8..9851933 100644 --- a/app/repositories/user_repository.py +++ b/app/repositories/user_repository.py @@ -2,11 +2,11 @@ from sqlalchemy.orm import Session from app.database.models import User -from app.schemas.user import UserCreate +from app.schemas.user import UserCreate, UserUpdate def create_user(db: Session, user: UserCreate) -> User: - db_user = User(**user.model_dump()) + db_user = User(**user.dict()) db.add(db_user) db.commit() db.refresh(db_user) @@ -21,8 +21,8 @@ def get_users(db: Session, skip: int = 0, limit: int = 10) -> list[User]: return db.query(User).offset(skip).limit(limit).all() -def update_user(db: Session, user_id: int, user: User) -> User: - db.query(User).filter(User.id == user_id).update(user) +def update_user(db: Session, user_id: int, user: UserUpdate) -> User: + db.query(User).filter(User.id == user_id).update(user.dict()) db.commit() return db.query(User).filter(User.id == user_id).first() diff --git a/app/schemas/activity.py b/app/schemas/activity.py index 298d592..4513c58 100644 --- a/app/schemas/activity.py +++ b/app/schemas/activity.py @@ -1,5 +1,3 @@ -# app/schemas/activity.py - from typing import Optional from enum import Enum from datetime import datetime @@ -31,11 +29,12 @@ class ActivityInDBBase(ActivityBase): study_session_id: int class Config: - orm_mode = True + from_attributes = True + arbitrary_types_allowed = True class Activity(ActivityInDBBase): - question: Optional["Question"] = None + question: Optional[Question] = None class ActivityInDB(ActivityInDBBase): diff --git a/app/schemas/answer.py b/app/schemas/answer.py index 0797ad2..310d98b 100644 --- a/app/schemas/answer.py +++ b/app/schemas/answer.py @@ -1,10 +1,6 @@ -# app/schemas/answer.py - -from typing import ( - Optional, - List, -) +from typing import Optional, List from pydantic import BaseModel +from app.database.models import Answer class AnswerBase(BaseModel): @@ -25,12 +21,14 @@ class AnswerInDBBase(AnswerBase): question_id: int class Config: - orm_mode = True + from_attributes = True + arbitrary_types_allowed = True +# pylint: disable=function-redefined class Answer(AnswerInDBBase): - parent_answer: Optional["Answer"] = None - child_answers: Optional[List["Answer"]] = [] + parent_answer: Optional[Answer] = None + child_answers: Optional[List[Answer]] = None class AnswerInDB(AnswerInDBBase): diff --git a/app/schemas/question.py b/app/schemas/question.py index a8e02e7..6d6a977 100644 --- a/app/schemas/question.py +++ b/app/schemas/question.py @@ -1,7 +1,4 @@ -from typing import ( - Optional, - List, -) +from typing import Optional, List from pydantic import BaseModel from app.database.models import Answer @@ -24,11 +21,12 @@ class QuestionInDBBase(QuestionBase): activity_id: int class Config: - orm_mode = True + from_attributes = True + arbitrary_types_allowed = True class Question(QuestionInDBBase): - answers: Optional[List["Answer"]] = [] + answers: Optional[List[Answer]] = None class QuestionInDB(QuestionInDBBase): diff --git a/app/schemas/study_session.py b/app/schemas/study_session.py index b0cc017..7214d55 100644 --- a/app/schemas/study_session.py +++ b/app/schemas/study_session.py @@ -1,9 +1,4 @@ -# app/schemas/study_session.py - -from typing import ( - List, - Optional, -) +from typing import List, Optional from datetime import datetime from pydantic import BaseModel from app.database.models import Activity @@ -27,11 +22,12 @@ class StudySessionInDBBase(StudySessionBase): user_id: int class Config: - orm_mode = True + from_attributes = True + arbitrary_types_allowed = True class StudySession(StudySessionInDBBase): - activities: Optional[List["Activity"]] = [] + activities: Optional[List[Activity]] = None class StudySessionInDB(StudySessionInDBBase): diff --git a/app/schemas/user.py b/app/schemas/user.py index 505c969..ef8a7b9 100644 --- a/app/schemas/user.py +++ b/app/schemas/user.py @@ -1,9 +1,4 @@ -# app/schemas/user.py - -from typing import ( - List, - Optional, -) +from typing import List, Optional from datetime import datetime from pydantic import BaseModel from app.database.models import Activity, Answer, Question, StudySession @@ -29,11 +24,12 @@ class UserInDBBase(UserBase): updated_at: datetime class Config: - orm_mode = True + from_attributes = True + arbitrary_types_allowed = True class User(UserInDBBase): - study_sessions: Optional[List["StudySession"]] = [] - activities: Optional[List["Activity"]] = [] - questions: Optional[List["Question"]] = [] - answers: Optional[List["Answer"]] = [] + study_sessions: Optional[List[StudySession]] = None + activities: Optional[List[Activity]] = None + questions: Optional[List[Question]] = None + answers: Optional[List[Answer]] = None diff --git a/main.py b/main.py index 7df589f..1dda034 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,10 @@ from sqlalchemy.orm import Session import uvicorn from app.api.endpoints import ( + activity, + answer, + question, + study_session, user, ) from app.database.session import ( @@ -16,6 +20,10 @@ app = FastAPI() Base.metadata.create_all(bind=engine) +app.include_router(activity.router) +app.include_router(answer.router) +app.include_router(question.router) +app.include_router(study_session.router) app.include_router(user.router) @@ -29,7 +37,7 @@ def get_session(): @app.get("/") def read_root(): - return {"Hello": "World"} + return {"message": "Welcome to AURA"} def main() -> None: