# 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: ```bash git clone 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 ``` 3. Install dependencies: ``` pip install -r requirements.txt ``` 4. 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 ``` 5. Run DB migrations: ``` make migrate_head ``` 6. Start the application: ``` python run.py, or without the environment, simply run make run Open the page via Microsoft Live Server ``` 7. 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=&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.