This is a FastAPI application for managing a bookstore. It includes user registration, login, and CRUD operations for books.
- User registration and login with JWT authentication
- Create, read, and delete books
- Secure endpoints with JWT tokens
-
Clone the repository:
git clone https://github.com/amaan-igs/FastAPI.git cd FastAPI-Bookstore -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database:
psql -U postgres -f SQL/setup.sql
-
Run the application:
uvicorn main:app --reload
POST /register: Register a new userPOST /login: Login and get a JWT tokenGET /books: Get a list of booksPOST /books: Create a new book (requires authentication)DELETE /books/{book_id}: Delete a book (requires authentication)
Create a .env file in the root directory and add the following:
DATABASE_URL=your_database_url
SECRET_KEY=your_secret_key