readme fix
This commit is contained in:
@@ -1,53 +1,53 @@
|
|||||||
# sqlalchemy-fastapi-pydentic-pytest
|
# sqlalchemy-fastapi-pydentic-pytest
|
||||||
|
|
||||||
Pet-проект на стеке **FastAPI + SQLAlchemy (async) + Pydantic + Pytest**.
|
Pet project built with **FastAPI + SQLAlchemy (async) + Pydantic + Pytest**.
|
||||||
Реализован CRUD для пользователей, JWT-аутентификация и тесты.
|
Implements CRUD for users, JWT authentication, and tests.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📂 Структура проекта
|
## 📂 Project Structure
|
||||||
```
|
```
|
||||||
/
|
/
|
||||||
├── server/backend # Исходный код: endpoints, pydantic, JWT, отправка паролей на почту, permissions, rate-limiting
|
├── server/backend # Source code: endpoints, pydantic, JWT, password email sending, permissions, rate-limiting
|
||||||
├── server/frontend # Странички login, registration, reset-password, main
|
├── server/frontend # Pages: login, registration, reset-password, main
|
||||||
├── server/database # База данных, alembic, db_balancer(не настроен, как шаблон)
|
├── server/database # Database, alembic, db_balancer (not configured, template only)
|
||||||
├── server/testing # pytests
|
├── server/testing # pytests
|
||||||
├── run.py # Точка входа, запуск приложения
|
├── run.py # Entry point, application startup
|
||||||
├── makefile # Точка входа, запуск приложения и утилит
|
├── makefile # Entry point, application and utility commands
|
||||||
├── requirements.txt # Зависимости
|
├── requirements.txt # Dependencies
|
||||||
├── .env # Переменные окружения
|
├── .env # Environment variables
|
||||||
└── README.md # Этот файл
|
└── README.md # This file
|
||||||
|
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
## ⚙️ Требования
|
## ⚙️ Requirements
|
||||||
|
|
||||||
- Python 3.13.3
|
- Python 3.13.3
|
||||||
- SQLite (по умолчанию)
|
- SQLite (default)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Установка и запуск
|
## 🚀 Installation and Running
|
||||||
|
|
||||||
1. Клонировать репозиторий:
|
1. Clone the repository:
|
||||||
```bash
|
```bash
|
||||||
git clone <URL репозитория>
|
git clone <repository URL>
|
||||||
cd sqlalchemy-fastapi-pydentic-pytest
|
cd sqlalchemy-fastapi-pydentic-pytest
|
||||||
```
|
```
|
||||||
2. Создать и активировать виртуальное окружение:
|
2. Create and activate a virtual environment:
|
||||||
```
|
```
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
source .venv/bin/activate # Linux / macOS
|
source .venv/bin/activate # Linux / macOS
|
||||||
venv\Scripts\activate # Windows
|
venv\Scripts\activate # Windows
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Установить зависимости:
|
3. Install dependencies:
|
||||||
```
|
```
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Настроить .env файл (пример):
|
4. Configure the .env file (example):
|
||||||
```
|
```
|
||||||
ALLOW_ORIGINS=http://localhost:3000
|
ALLOW_ORIGINS=http://localhost:3000
|
||||||
ALLOW_CREDENTIALS=true
|
ALLOW_CREDENTIALS=true
|
||||||
@@ -56,30 +56,30 @@ ALLOW_HEADERS=*
|
|||||||
JWT_SECRET_KEY=your_secret_key
|
JWT_SECRET_KEY=your_secret_key
|
||||||
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
||||||
```
|
```
|
||||||
5. Мигрировать БД:
|
5. Run DB migrations:
|
||||||
```
|
```
|
||||||
make migrate_head
|
make migrate_head
|
||||||
```
|
```
|
||||||
6. Запустить приложение:
|
6. Start the application:
|
||||||
```
|
```
|
||||||
python run.py или вне окружения сразу прописать make run
|
python run.py, or without the environment, simply run make run
|
||||||
Открыть страничку через microsoft live server
|
Open the page via Microsoft Live Server
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Документация OpenAPI будет доступна по адресу:
|
7. OpenAPI documentation will be available at:
|
||||||
```
|
```
|
||||||
• Swagger UI → http://localhost:8000/docs
|
• Swagger UI → http://localhost:8000/docs
|
||||||
• JSON схема → http://localhost:8000/openapi.json
|
• JSON schema → http://localhost:8000/openapi.json
|
||||||
```
|
```
|
||||||
⸻
|
⸻
|
||||||
|
|
||||||
🔐 Аутентификация
|
🔐 Authentication
|
||||||
• Эндпоинт /login принимает application/x-www-form-urlencoded:
|
• The /login endpoint accepts application/x-www-form-urlencoded:
|
||||||
```
|
```
|
||||||
username=<email>&password=<пароль>
|
username=<email>&password=<password>
|
||||||
```
|
```
|
||||||
|
|
||||||
Возвращает JWT токен:
|
Returns a JWT token:
|
||||||
```
|
```
|
||||||
{
|
{
|
||||||
"access_token": "...",
|
"access_token": "...",
|
||||||
@@ -88,31 +88,31 @@ username=<email>&password=<пароль>
|
|||||||
```
|
```
|
||||||
⸻
|
⸻
|
||||||
```
|
```
|
||||||
👤 Пользователи (CRUD)
|
👤 Users (CRUD)
|
||||||
• POST /user_create — создать пользователя
|
• POST /user_create — create a user
|
||||||
• GET /get_user_by_email/{email} — получить пользователя по email
|
• GET /get_user_by_email/{email} — get a user by email
|
||||||
• GET / — получить всех пользователей
|
• GET / — get all users
|
||||||
• PUT /user_update/{email} — обновить данные пользователя
|
• PUT /user_update/{email} — update user data
|
||||||
• DELETE /user_delete/{email} — удалить пользователя
|
• DELETE /user_delete/{email} — delete a user
|
||||||
```
|
```
|
||||||
⸻
|
⸻
|
||||||
|
|
||||||
🧪 Тестирование
|
🧪 Testing
|
||||||
|
|
||||||
Запуск всех тестов:
|
Run all tests:
|
||||||
```
|
```
|
||||||
make test
|
make test
|
||||||
```
|
```
|
||||||
Тестируются (В планах):
|
Test coverage (planned):
|
||||||
```
|
```
|
||||||
• CRUD операции
|
• CRUD operations
|
||||||
• Pydantic-схемы
|
• Pydantic schemas
|
||||||
• Эндпоинты API
|
• API endpoints
|
||||||
• JWT авторизация
|
• JWT authorization
|
||||||
• Тестирование
|
• Testing
|
||||||
```
|
```
|
||||||
⸻
|
⸻
|
||||||
|
|
||||||
📜 Лицензия
|
📜 License
|
||||||
|
|
||||||
Учебный проект.
|
Educational project.
|
||||||
Reference in New Issue
Block a user