
- Create project structure and dependencies - Set up SQLAlchemy models for anime, genres, and their relationships - Implement CRUD operations for all models - Set up FastAPI endpoints for managing anime and genres - Add health check endpoint - Configure Alembic for database migrations - Add data seeding capability - Update README with project information
96 lines
2.5 KiB
Markdown
96 lines
2.5 KiB
Markdown
# Anime Information API
|
|
|
|
This is a FastAPI application that provides anime information via a RESTful API.
|
|
|
|
## Features
|
|
|
|
- **Anime Information**: Comprehensive anime data including titles, synopsis, episodes, scores, etc.
|
|
- **Genre Management**: Create, read, update, and delete anime genres
|
|
- **Search Capabilities**: Search anime by title, genre, or status
|
|
- **Health Endpoint**: Check the health of the application and its database connection
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework**: FastAPI
|
|
- **Database**: SQLite with SQLAlchemy ORM
|
|
- **Migration Tool**: Alembic
|
|
- **Validation**: Pydantic
|
|
- **Code Quality**: Ruff linter
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
anime-information-api/
|
|
├── alembic/ # Database migrations
|
|
├── app/ # Application code
|
|
│ ├── api/ # API endpoints
|
|
│ │ └── endpoints/ # Route definitions
|
|
│ ├── core/ # Core application components
|
|
│ ├── crud/ # CRUD operations
|
|
│ ├── db/ # Database setup
|
|
│ ├── initial_data/ # Data seeding
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ └── schemas/ # Pydantic schemas
|
|
├── storage/ # Storage for SQLite database
|
|
├── alembic.ini # Alembic config
|
|
├── main.py # Application entry point
|
|
├── requirements.txt # Dependencies
|
|
└── seed_data.py # Script to seed initial data
|
|
```
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.9+
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
```
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
### Database Setup
|
|
|
|
Run the Alembic migrations to set up the database schema:
|
|
|
|
```
|
|
alembic upgrade head
|
|
```
|
|
|
|
Seed the database with initial data:
|
|
|
|
```
|
|
python seed_data.py
|
|
```
|
|
|
|
### Running the Application
|
|
|
|
Start the application with:
|
|
|
|
```
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000, and the interactive API documentation at http://localhost:8000/docs.
|
|
|
|
## API Endpoints
|
|
|
|
### Health Check
|
|
- `GET /health`: Check application health
|
|
|
|
### Anime
|
|
- `GET /api/v1/anime/`: Get anime list with search capabilities
|
|
- `POST /api/v1/anime/`: Create new anime
|
|
- `GET /api/v1/anime/{id}`: Get anime by ID
|
|
- `PUT /api/v1/anime/{id}`: Update anime
|
|
- `DELETE /api/v1/anime/{id}`: Delete anime
|
|
|
|
### Genres
|
|
- `GET /api/v1/genres/`: Get genre list
|
|
- `POST /api/v1/genres/`: Create new genre
|
|
- `GET /api/v1/genres/{id}`: Get genre by ID
|
|
- `PUT /api/v1/genres/{id}`: Update genre
|
|
- `DELETE /api/v1/genres/{id}`: Delete genre |