2026-08-29 13:49:03 +03:00
2025-10-18 17:34:59 +03:00
2025-09-25 17:54:34 +03:00
2025-10-03 14:47:12 +03:00
2025-10-05 02:09:28 +03:00
2026-08-29 13:49:03 +03:00
2025-10-12 15:00:23 +03:00
2025-10-01 12:24:49 +03:00

sqlalchemy-fastapi-pydentic-pytest

Pet project built with FastAPI + SQLAlchemy (async) + Pydantic + Pytest. Implements CRUD for users, JWT authentication, and tests.


📂 Project Structure

/
├── server/backend        # Source code: endpoints, pydantic, JWT, password email sending, permissions, rate-limiting
├── server/frontend       # Pages: login, registration, reset-password, main
├── server/database       # Database, alembic, db_balancer (not configured, template only)
├── server/testing        # pytests
├── run.py			      # Entry point, application startup
├── makefile 		      # Entry point, application and utility commands
├── requirements.txt      # Dependencies
├── .env                  # Environment variables
└── README.md             # This file


⚙️ Requirements

  • Python 3.13.3
  • SQLite (default)

🚀 Installation and Running

  1. Clone the repository:
    git clone <repository URL>
    cd sqlalchemy-fastapi-pydentic-pytest
    
  2. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate    # Linux / macOS
venv\Scripts\activate       # Windows
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure the .env file (example):
ALLOW_ORIGINS=http://localhost:3000
ALLOW_CREDENTIALS=true
ALLOW_METHODS=GET,POST,PUT,DELETE
ALLOW_HEADERS=*
JWT_SECRET_KEY=your_secret_key
ACCESS_TOKEN_EXPIRE_MINUTES=30
  1. Run DB migrations:
make migrate_head
  1. Start the application:
python run.py, or without the environment, simply run make run
Open the page via Microsoft Live Server
  1. OpenAPI documentation will be available at:
	•	Swagger UI → http://localhost:8000/docs
	•	JSON schema → http://localhost:8000/openapi.json

🔐 Authentication • The /login endpoint accepts application/x-www-form-urlencoded:

username=<email>&password=<password>

Returns a JWT token:

{
  "access_token": "...",
  "token_type": "bearer"
}

👤 Users (CRUD)
	•	POST /user_create — create a user
	•	GET /get_user_by_email/{email} — get a user by email
	•	GET / — get all users
	•	PUT /user_update/{email} — update user data
	•	DELETE /user_delete/{email} — delete a user

🧪 Testing

Run all tests:

make test

Test coverage (planned):

	•	CRUD operations
	•	Pydantic schemas
	•	API endpoints
	•	JWT authorization
	•	Testing

📜 License

Educational project.

S
Description
Изучение sqlalchemy-fastapi-pydentic-pytest на пет-проекте
Readme
320 KiB
Languages
Python 62.4%
JavaScript 18%
CSS 11.4%
HTML 6.1%
Mako 1.2%
Other 0.9%