Simple FastAPI service with JWT auth, user management, and image upload via ImageKit. Uses async SQLAlchemy with SQLite.
- Python 3.10+
- ImageKit account (for
/upload)
- Create and activate a virtual environment.
- Install dependencies:
pip install .If you use uv, run uv sync instead.
- Create a
.envfile in the project root:
IMAGEKIT_PRIVATE_KEY=your_private_key
IMAGEKIT_URL_ENDPOINT=https://ik.imagekit.io/your_accountpython main.pyThe API starts at http://127.0.0.1:8000. Open docs at http://127.0.0.1:8000/docs.
SQLite file: test.db (created on startup). Tables are created automatically at app startup.
POST /auth/jwt/login- login and receive JWTPOST /auth/register- register a userPOST /auth/forgot-password- request password resetPOST /auth/request-verify-token- request verificationGET /users- list users (auth required)POST /upload- upload file + caption (ImageKit + DB record)GET /posts- list postsDELETE /posts/{post_id}- delete post
curl -X POST "http://127.0.0.1:8000/upload" \
-H "Authorization: Bearer <JWT>" \
-F "caption=Hello" \
-F "file=@/path/to/image.jpg"- JWT secret is hardcoded in
app/users.pyfor tutorial use only. - Image uploads require valid ImageKit credentials.