Skip to content

Latest commit

 

History

History
194 lines (137 loc) · 4.31 KB

README.md

File metadata and controls

194 lines (137 loc) · 4.31 KB

Project for university

Rest API project for university, that emluate university system):

Running on:

  • Windows 11

  • Python 3.11.4 or higher

  • PostgreSQL

How to run

Install from git:

Using GitFlic:

$ git clone https://gitflic.ru/project/abstract-333/university-api.git

$ cd university-api

Using GitHub:

$ git clone https://github.com/abstract-333/university-api.git

$ cd university-api

Create and activate virutal environment:

$ python -m venv .venv

$ .\.venv\Scripts\activate

Install dependencies:

$ pip install -r requirements.txt

Make migration for database:

First Create database under "name".
Add this name and other properties to .env.prod file.


$ alembic upgrade heads

Run App:

  • Using Make:

$ make run
  • Without Make:

$ uvicorn --factory src.app:app --reload

Description:

This project has been developed as an alternative to the Moodle LMS system, as it creates a complete interactive environment for the university. This system include wide range of features such as:

  • Courses: Create courses, add lectures there, questions and posts about the course, so it provides tools for easily creating and managing educational content.
  • Interaction Between Students and Instructors: Enabling effective communication through forums, chats, and messaging.
  • Assessments and Exams: Offering tools for designing tests and evaluating student performance.
  • Data Analysis: Utilizing data to analyze student performance and improve the educational process.
  • Personalization of the Learning Experience: The ability to customize content and resources based on students' needs.

Use Case Diagram:

use_case

Sign-in BPMN:

sign_in_bpmn

Delete Session BPMN:

delete_session_bpmn

Add Lecture BPMN:

add_lecture_bpmn

Add Question BPMN:

add_question_bpmn

ERD:

erd.png

Repository Pattern:

The repository pattern (Repository) is an abstraction of persistent storage (DB). In Python, to abstract classes, ABC or Duck typing.

class AbstractSQLRepository(ABC):
    @abstractmethod
    async def add_one(self, data: dict) -> None:
        ...

    @abstractmethod
    async def edit_one(
            self,
            data: dict,
            arguments: ColumnExpressionOrAnyArgument,
    ) -> None:
        ...

    @abstractmethod
    async def find_by(
            self,
            *options: Any,
            offset: int,
            limit: int,
            join_conditions: tuple[Any] = tuple(),
            schema: Type[Schema],
            arguments: ColumnExpressionOrAnyArgument,
    ) -> list[Schema] | None:
        ...

    @abstractmethod
    async def find_one(
            self,
            *options: Any,
            join_conditions: tuple[Any] = tuple(),
            schema: Type[Schema],
            arguments: ColumnExpressionOrAnyArgument,
    ) -> Schema | None:
        ...

    @abstractmethod
    async def delete_one(
            self,
            arguments: ColumnExpressionOrAnyArgument,
    ) -> None:
        ...

Specification Pattern:

The Specification Pattern is a design pattern used in software development to encapsulate business rules or criteria in a reusable and composable way. We use this pattern in order to move business logic from repository pattern, for example:

class Specification(Protocol):
    def is_satisfied_by(self) -> Any:
        ...

    def __and__(self, spec: "Specification") -> Any:
        ...

    def __or__(self, spec: "Specification") -> Any:
        ...

    def __invert__(self) -> Any:
        ...

Here we are putting the rules of implementation, not inheritance. In this case, Python's Protocol is more useful.

Health Check:

The API endpoint handler performs various checks, such as the status of the connections to the infrastructure services used by the service instance, the status of the host and application specific logic, for more details.