2.2 KiB
2.2 KiB
QuickSimpleApp
A quick and simple FastAPI application with a SQLite database. This application provides a RESTful API for managing items.
Features
- FastAPI framework with automatic OpenAPI documentation
- SQLite database with SQLAlchemy ORM
- Database migrations using Alembic
- CRUD operations for items
- Health endpoint for monitoring
Project Structure
.
├── alembic.ini
├── app
│ ├── api
│ │ └── routes
│ │ ├── health.py
│ │ └── items.py
│ ├── core
│ │ └── config.py
│ ├── db
│ │ └── session.py
│ ├── models
│ │ ├── base.py
│ │ └── item.py
│ └── schemas
│ └── item.py
├── main.py
├── migrations
│ ├── env.py
│ ├── README
│ ├── script.py.mako
│ └── versions
│ └── a1b2c3d4e5f6_create_items_table.py
└── requirements.txt
Setup and Installation
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\\Scripts\\activate
- Install required packages:
pip install -r requirements.txt
- Run the database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
- The application will be available at http://localhost:8000
API Documentation
Once the application is running, you can view the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check if the API is running
Items
GET /api/v1/items/
- List all itemsPOST /api/v1/items/
- Create a new itemGET /api/v1/items/{item_id}
- Get a specific itemDELETE /api/v1/items/{item_id}
- Delete an item
Example Request
Creating a new item:
curl -X POST "http://localhost:8000/api/v1/items/" \
-H "Content-Type: application/json" \
-d '{
"name": "Example Item",
"description": "This is an example item",
"price": 1999,
"is_available": true
}'