94 lines
2.2 KiB
Markdown
94 lines
2.2 KiB
Markdown
# 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
|
|
|
|
1. Clone the repository
|
|
2. Create a virtual environment:
|
|
```
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\\Scripts\\activate
|
|
```
|
|
3. Install required packages:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
4. Run the database migrations:
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
5. Start the application:
|
|
```
|
|
uvicorn main:app --reload
|
|
```
|
|
6. 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 items
|
|
- `POST /api/v1/items/` - Create a new item
|
|
- `GET /api/v1/items/{item_id}` - Get a specific item
|
|
- `DELETE /api/v1/items/{item_id}` - Delete an item
|
|
|
|
## Example Request
|
|
|
|
Creating a new item:
|
|
|
|
```bash
|
|
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
|
|
}'
|
|
``` |