# Late Show API
The **Late Show API** is a Flask-based RESTful API designed to manage episodes, guests, and their appearances on a late-night talk show. It provides endpoints to create, read, update, and delete data for episodes, guests, and their appearances, along with database seeding and migrations.
## Features
- **Episodes Management**: Create, retrieve, update, and delete episodes.
- **Guests Management**: Manage guest information, including their name and occupation.
- **Appearances Management**: Track guest appearances on specific episodes with ratings.
- **Database Seeding**: Populate the database with sample data using the `Faker` library.
- **Database Migrations**: Manage schema changes using Alembic and Flask-Migrate.
- **RESTful API**: Fully RESTful endpoints for CRUD operations.
## Project Structure
late-show/ ├── app/ │ ├── init.py # App factory and initialization │ ├── models/ # Models for database tables │ │ ├── init.py # Import all models here │ │ ├── episode.py # Episode model │ │ ├── guest.py # Guest model │ │ ├── appearance.py # Appearance model │ ├── routes/ # API routes │ │ ├── init.py # Import all routes here │ │ ├── episode.py # Episode routes │ │ ├── guest.py # Guest routes │ │ ├── appearance.py # Appearance routes │ ├── extensions.py # Extensions like db, migrate │ ├── config.py # Configuration for the app │ ├── seed.py # Database seeding script ├── migrations/ # Alembic migrations ├── instances/ │ ├── lateShowDb.sqlite3 # SQLite database ├── run.py # Entry point for the app ├── Pipfile # Dependencies
## Installation
1. Clone the repository:
```bash
git clone <repository-url>
cd late-show
-
Install dependencies using
pipenv:pipenv install
-
Activate the virtual environment:
pipenv shell
-
Set up the database:
flask db upgrade
-
Seed the database with sample data:
python app/seed.py
-
Run the application:
python run.py
GET /episodes: Retrieve all episodes.GET /episodes/<id>: Retrieve a specific episode by ID.POST /episodes: Create a new episode.PUT /episodes/<id>: Update an existing episode.PATCH /episodes/<id>: Partially update an episode.DELETE /episodes/<id>: Delete an episode.
GET /guests: Retrieve all guests.GET /guests/<id>: Retrieve a specific guest by ID.POST /guests: Create a new guest.PUT /guests/<id>: Update an existing guest.PATCH /guests/<id>: Partially update a guest.DELETE /guests/<id>: Delete a guest.
GET /appearances: Retrieve all appearances.GET /appearances/<id>: Retrieve a specific appearance by ID.POST /appearances: Create a new appearance.PUT /appearances/<id>: Update an existing appearance.PATCH /appearances/<id>: Partially update an appearance.DELETE /appearances/<id>: Delete an appearance.
The application uses a SQLite database by default. You can configure the database URI in app/config.py:
SQLALCHEMY_DATABASE_URI = 'sqlite:///instances/lateShowDb.sqlite3'To manage database schema changes, use Flask-Migrate:
- Create a new migration:
flask db migrate -m "Migration message" - Apply migrations:
flask db upgrade
To populate the database with sample data, run:
python seed.py- Flask: Web framework.
- Flask-SQLAlchemy: ORM for database interactions.
- Flask-Migrate: Database migrations.
- Flask-RESTful: RESTful API support.
- SQLAlchemy-Serializer: Serialization for models.
- Faker: Generate fake data for seeding.
To contribute to this project:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Flask
- SQLAlchemy
- [Faker](https://faker.readthedo
Email me: jeyceejeyka635@gmail.com