# Generic REST API Service A RESTful API built with FastAPI and SQLite, providing endpoints for user and item management. ## Features - User management (create, read, update, delete) - Item management (create, read, update, delete) - SQLite database with SQLAlchemy ORM - Alembic migrations - OpenAPI documentation (Swagger UI) - Password hashing with bcrypt - Health check endpoint ## Requirements - Python 3.8+ - FastAPI - SQLAlchemy - Alembic - Uvicorn - Pydantic - Other dependencies as listed in requirements.txt ## Project Structure ``` . ├── app/ │ ├── api/ │ │ ├── endpoints/ │ │ │ ├── items.py │ │ │ └── users.py │ │ ├── api.py │ │ └── deps.py │ ├── core/ │ │ ├── config.py │ │ └── security.py │ ├── crud/ │ │ ├── base.py │ │ ├── crud_item.py │ │ └── crud_user.py │ ├── database/ │ │ ├── base.py │ │ ├── base_class.py │ │ └── session.py │ ├── models/ │ │ ├── item.py │ │ └── user.py │ └── schemas/ │ ├── item.py │ └── user.py ├── migrations/ │ └── versions/ │ └── 20240520_initial.py ├── storage/ │ └── db/ │ └── db.sqlite ├── alembic.ini ├── main.py └── requirements.txt ``` ## Installation 1. Clone the repository: ```bash git clone cd genericrestapiservice ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Run database migrations: ```bash alembic upgrade head ``` ## Running the Application Start the application using Uvicorn: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` The API will be available at http://localhost:8000. ## API Documentation - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ## API Endpoints ### Health Check - `GET /health` - Check the API health status ### Users - `GET /api/v1/users/` - List all users - `POST /api/v1/users/` - Create a new user - `GET /api/v1/users/{user_id}` - Get user details - `PUT /api/v1/users/{user_id}` - Update user information - `DELETE /api/v1/users/{user_id}` - Delete a user ### Items - `GET /api/v1/items/` - List all items - `POST /api/v1/items/` - Create a new item - `GET /api/v1/items/{id}` - Get item details - `PUT /api/v1/items/{id}` - Update item information - `DELETE /api/v1/items/{id}` - Delete an item - `GET /api/v1/items/user/{owner_id}` - List all items owned by a specific user ## Development ### Database Migrations Generate a new migration: ```bash alembic revision -m "description" ``` Apply migrations: ```bash alembic upgrade head ``` Revert migrations: ```bash alembic downgrade -1 ```