105 lines
3.3 KiB
Markdown
105 lines
3.3 KiB
Markdown
# Anime Merchandise Catalog API
|
|
|
|
A FastAPI-based API for managing an anime merchandise catalog.
|
|
|
|
## Features
|
|
|
|
- **Product Management:** Create, read, update, and delete anime merchandise products
|
|
- **Category System:** Organize products with categories
|
|
- **Filtering and Searching:** Filter products by anime title or character name
|
|
- **API Documentation:** Auto-generated OpenAPI documentation
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework:** FastAPI
|
|
- **Database:** SQLite with SQLAlchemy and Alembic
|
|
- **Authentication:** (Not implemented in this version)
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── app # Main application package
|
|
│ ├── api # API routes and endpoint definitions
|
|
│ │ └── routes # API route handlers
|
|
│ ├── core # Core application components
|
|
│ ├── dependencies # Dependency injection components
|
|
│ ├── models # SQLAlchemy database models
|
|
│ ├── schemas # Pydantic schemas for request/response validation
|
|
│ └── services # Business logic services
|
|
├── migrations # Alembic database migrations
|
|
│ └── versions # Migration version scripts
|
|
├── storage # Storage directory for SQLite database
|
|
│ └── db # Database files
|
|
├── alembic.ini # Alembic configuration
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Python dependencies
|
|
```
|
|
|
|
## API Routes
|
|
|
|
### Health Check
|
|
- `GET /health` - Check API health status
|
|
|
|
### Products
|
|
- `GET /api/v1/products` - List all products (with optional filtering)
|
|
- `GET /api/v1/products/{product_id}` - Get a specific product by ID
|
|
- `POST /api/v1/products` - Create a new product
|
|
- `PUT /api/v1/products/{product_id}` - Update an existing product
|
|
- `DELETE /api/v1/products/{product_id}` - Delete a product
|
|
|
|
### Categories
|
|
- `GET /api/v1/categories` - List all categories
|
|
- `GET /api/v1/categories/{category_id}` - Get a specific category by ID
|
|
- `GET /api/v1/categories/{category_id}/products` - Get a category with its products
|
|
- `POST /api/v1/categories` - Create a new category
|
|
- `PUT /api/v1/categories/{category_id}` - Update an existing category
|
|
- `DELETE /api/v1/categories/{category_id}` - Delete a category
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
3. Apply migrations to create the database schema:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Running the Application
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at `http://localhost:8000`
|
|
|
|
## API Documentation
|
|
|
|
- Swagger UI: `http://localhost:8000/docs`
|
|
- ReDoc: `http://localhost:8000/redoc`
|
|
|
|
## Database Schema
|
|
|
|
### Product
|
|
- id: Integer (Primary Key)
|
|
- name: String
|
|
- description: Text (Optional)
|
|
- price: Float
|
|
- stock: Integer
|
|
- image_url: String (Optional)
|
|
- anime_title: String (Optional)
|
|
- character_name: String (Optional)
|
|
- created_at: DateTime
|
|
- updated_at: DateTime
|
|
- categories: Many-to-Many relationship with Category
|
|
|
|
### Category
|
|
- id: Integer (Primary Key)
|
|
- name: String (Unique)
|
|
- description: Text (Optional)
|
|
- created_at: DateTime
|
|
- updated_at: DateTime
|
|
- products: Many-to-Many relationship with Product |