
This commit includes: - Basic project structure with FastAPI - SQLite database integration using SQLAlchemy - CRUD API for items - Alembic migrations setup - Health check endpoint - Proper error handling - Updated README with setup instructions
114 lines
2.3 KiB
Markdown
114 lines
2.3 KiB
Markdown
# QuickSimpleAPI
|
|
|
|
A quick and simple FastAPI application with SQLite database. This project provides a simple CRUD API for managing items.
|
|
|
|
## Features
|
|
|
|
- FastAPI framework with automatic API documentation
|
|
- SQLite database integration
|
|
- SQLAlchemy ORM
|
|
- Alembic migrations
|
|
- CORS support
|
|
|
|
## Requirements
|
|
|
|
- Python 3.8+
|
|
- FastAPI
|
|
- SQLAlchemy
|
|
- Alembic
|
|
- Uvicorn
|
|
- Pydantic
|
|
|
|
## Getting Started
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
|
|
```bash
|
|
git clone https://github.com/yourusername/quicksimpleapi.git
|
|
cd quicksimpleapi
|
|
```
|
|
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run database migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`.
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the API documentation at:
|
|
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## API Endpoints
|
|
|
|
### Root Endpoint
|
|
|
|
- `GET /`: Returns basic information about the API.
|
|
|
|
### Health Check
|
|
|
|
- `GET /health`: Returns the health status of the API.
|
|
|
|
### Items API
|
|
|
|
- `GET /api/v1/items`: Retrieve a list of items.
|
|
- `POST /api/v1/items`: Create a new item.
|
|
- `GET /api/v1/items/{item_id}`: Retrieve an item by ID.
|
|
- `PUT /api/v1/items/{item_id}`: Update an item.
|
|
- `DELETE /api/v1/items/{item_id}`: Delete an item.
|
|
|
|
## Environment Variables
|
|
|
|
The following environment variables can be set:
|
|
|
|
- `SECRET_KEY`: Secret key for security. Default is "development_secret_key".
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
quicksimpleapi/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ └── v1/
|
|
│ │ ├── __init__.py
|
|
│ │ └── items.py
|
|
│ ├── core/
|
|
│ │ ├── __init__.py
|
|
│ │ └── config.py
|
|
│ ├── db/
|
|
│ │ ├── __init__.py
|
|
│ │ ├── base.py
|
|
│ │ └── session.py
|
|
│ ├── models/
|
|
│ │ ├── __init__.py
|
|
│ │ └── item.py
|
|
│ └── schemas/
|
|
│ ├── __init__.py
|
|
│ └── item.py
|
|
├── migrations/
|
|
│ ├── versions/
|
|
│ │ └── 001_create_items_table.py
|
|
│ ├── env.py
|
|
│ └── script.py.mako
|
|
├── main.py
|
|
├── alembic.ini
|
|
└── requirements.txt
|
|
``` |