
- Set up project structure and dependencies - Create database models with SQLAlchemy - Implement API endpoints for CRUD operations - Set up Alembic for database migrations - Add health check endpoint - Configure Ruff for linting - Update documentation in README
100 lines
2.2 KiB
Markdown
100 lines
2.2 KiB
Markdown
# QuickRestAPI
|
|
|
|
A simple REST API built with FastAPI and SQLite.
|
|
|
|
## Features
|
|
|
|
- FastAPI framework for high performance
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Alembic database migrations
|
|
- Pydantic for data validation
|
|
- RESTful CRUD operations on items
|
|
- Health check endpoint
|
|
- OpenAPI documentation
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
/
|
|
├── app/
|
|
│ ├── api/
|
|
│ │ └── v1/
|
|
│ │ ├── endpoints/
|
|
│ │ │ └── items.py
|
|
│ │ └── api.py
|
|
│ ├── core/
|
|
│ │ └── config.py
|
|
│ ├── db/
|
|
│ │ ├── base.py
|
|
│ │ ├── base_class.py
|
|
│ │ └── session.py
|
|
│ ├── models/
|
|
│ │ └── item.py
|
|
│ ├── schemas/
|
|
│ │ └── item.py
|
|
│ └── storage/
|
|
│ └── db/
|
|
├── migrations/
|
|
│ └── versions/
|
|
│ └── initial_migration.py
|
|
├── alembic.ini
|
|
├── main.py
|
|
└── requirements.txt
|
|
```
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
## Running 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:
|
|
- Swagger UI documentation: http://localhost:8000/docs
|
|
- ReDoc documentation: http://localhost:8000/redoc
|
|
- OpenAPI JSON: http://localhost:8000/openapi.json
|
|
|
|
## API Endpoints
|
|
|
|
| Method | URL | Description |
|
|
|--------|---------------------|---------------------------|
|
|
| GET | /health | Health check |
|
|
| GET | /api/v1/items | List all items |
|
|
| POST | /api/v1/items | Create a new item |
|
|
| GET | /api/v1/items/{id} | Get a specific item |
|
|
| PUT | /api/v1/items/{id} | Update a specific item |
|
|
| DELETE | /api/v1/items/{id} | Delete a specific item |
|
|
|
|
## Database Migrations
|
|
|
|
Initialize the database:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Development
|
|
|
|
Create a new migration after modifying models:
|
|
|
|
```bash
|
|
alembic revision --autogenerate -m "Description of changes"
|
|
```
|
|
|
|
Apply migrations:
|
|
|
|
```bash
|
|
alembic upgrade head
|
|
``` |