
- Set up FastAPI application with CORS and authentication - Implement user registration and login with JWT tokens - Create SQLAlchemy models for users and items - Add CRUD endpoints for item management - Configure Alembic for database migrations - Add health check endpoint - Include comprehensive API documentation - Set up proper project structure with routers and schemas
68 lines
1.6 KiB
Markdown
68 lines
1.6 KiB
Markdown
# REST API Service
|
|
|
|
A comprehensive REST API built with FastAPI and SQLite, featuring user authentication, CRUD operations, and health monitoring.
|
|
|
|
## Features
|
|
|
|
- User registration and authentication with JWT tokens
|
|
- Item management (CRUD operations)
|
|
- SQLite database with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- Health check endpoint
|
|
- CORS enabled for all origins
|
|
- Interactive API documentation at `/docs` and `/redoc`
|
|
- OpenAPI specification at `/openapi.json`
|
|
|
|
## Installation
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Run the application:
|
|
```bash
|
|
uvicorn main:app --host 0.0.0.0 --port 8000
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
Set the following environment variables:
|
|
|
|
- `SECRET_KEY`: JWT secret key for token signing (required for production)
|
|
|
|
## API Endpoints
|
|
|
|
### Authentication
|
|
- `POST /auth/register` - Register a new user
|
|
- `POST /auth/login` - Login and get access token
|
|
- `GET /auth/me` - Get current user profile
|
|
|
|
### Items
|
|
- `GET /items/` - List user's items
|
|
- `POST /items/` - Create a new item
|
|
- `GET /items/{item_id}` - Get a specific item
|
|
- `PUT /items/{item_id}` - Update an item
|
|
- `DELETE /items/{item_id}` - Delete an item
|
|
|
|
### Health
|
|
- `GET /health` - Health check endpoint
|
|
|
|
### Documentation
|
|
- `GET /` - Service information
|
|
- `GET /docs` - Interactive API documentation
|
|
- `GET /redoc` - ReDoc documentation
|
|
- `GET /openapi.json` - OpenAPI specification
|
|
|
|
## Database
|
|
|
|
The application uses SQLite with database file stored at `/app/storage/db/db.sqlite`.
|
|
|
|
## Development
|
|
|
|
The application includes Ruff for code linting and formatting. Run linting with:
|
|
```bash
|
|
ruff check .
|
|
ruff format .
|
|
```
|