main
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
- Clone the repository:
git clone <repository URL> cd sqlalchemy-fastapi-pydentic-pytest - Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- 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
- Run DB migrations:
make migrate_head
- Start the application:
python run.py, or without the environment, simply run make run
Open the page via Microsoft Live Server
- 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.
Languages
Python
62.4%
JavaScript
18%
CSS
11.4%
HTML
6.1%
Mako
1.2%
Other
0.9%