# Movie Ticket System API Documentation (Flask Version)
## Introduction
The Movie Ticket System is a Flask-based backend application that enables users to browse movies, purchase tickets, and process payments via M-Pesa. This system is designed to provide a seamless ticket purchasing experience for movie theaters, event organizers, and similar businesses.
This API handles the complete workflow from movie listing to payment processing and ticket generation. With integrated M-Pesa payment functionality, it's specifically tailored for the Kenyan market, but can be adapted for other mobile payment systems.
Key features include:
- Movie management (add, retrieve)
- Ticket purchasing
- M-Pesa payment integration with STK Push
- Payment status tracking
- Ticket availability management
## Getting Started
### Prerequisites
- Python 3.6+
- Flask and Flask-SQLAlchemy
- Requests library
- SQLite (for development) or another database of your choice
- M-Pesa developer account (for Safaricom API access)
### Installation
1. Clone the repository:
```bash
git clone
github.com
cd mpesa_movie_system_python_flask
```
2. Create a virtual environment and activate it:
```bash
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install flask flask-sqlalchemy requests
```
4. Configure the application:
- Update the M-Pesa configuration in the `app.py` file with your Safaricom credentials
- Update the `MPESA_CALLBACK_URL` to your actual callback URL
5. Run the application:
```bash
python app.py
```
The server will start at `
localhost` or `http:127.0.0.1:5000`.
## Database Schema
The system uses three main models:
### Movie
- `movieId`: Primary key (integer)
- `title`: Movie title (string, required)
- `description`: Movie description (text)
- `showTime`: Date and time of the movie (datetime, required)
- `price`: Ticket price (decimal, …