
- Set up FastAPI application structure - Implemented SQLite database integration with SQLAlchemy - Added Alembic migrations for database versioning - Created bet model and API endpoints for CRUD operations - Added comprehensive README with setup and usage instructions - Added health check endpoint and CORS support
126 lines
3.3 KiB
Markdown
126 lines
3.3 KiB
Markdown
# Sports Betting Verification API
|
|
|
|
A FastAPI-based REST API for verifying sports betting information. This application provides endpoints to manage and verify sports bets.
|
|
|
|
## Features
|
|
|
|
- RESTful API with FastAPI
|
|
- SQLite database integration with SQLAlchemy ORM
|
|
- Database migrations with Alembic
|
|
- CORS support for all origins
|
|
- Health check endpoint
|
|
- OpenAPI documentation
|
|
- Input validation with Pydantic
|
|
|
|
## Getting Started
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.8 or higher
|
|
- pip (Python package installer)
|
|
|
|
### Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone <repository-url>
|
|
cd sportsbettingverificationapi
|
|
```
|
|
|
|
2. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run database migrations:
|
|
```bash
|
|
alembic upgrade head
|
|
```
|
|
|
|
4. Start the API server:
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
The API will be available at http://localhost:8000
|
|
|
|
## API Documentation
|
|
|
|
Once the application is running, you can access the automatically generated API documentation:
|
|
|
|
- Swagger UI: http://localhost:8000/docs
|
|
- ReDoc: http://localhost:8000/redoc
|
|
|
|
## API Endpoints
|
|
|
|
- `GET /`: Root endpoint with API information
|
|
- `GET /health`: Health check endpoint
|
|
- `GET /api/v1/bets`: List all bets
|
|
- `POST /api/v1/bets`: Create a new bet
|
|
- `GET /api/v1/bets/{id}`: Get details of a specific bet
|
|
- `PUT /api/v1/bets/{id}`: Update a bet
|
|
- `DELETE /api/v1/bets/{id}`: Delete a bet
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
.
|
|
├── alembic.ini # Alembic configuration
|
|
├── app/ # Application code
|
|
│ ├── api/ # API endpoints
|
|
│ │ └── api_v1/ # API version 1
|
|
│ │ ├── api.py # API router
|
|
│ │ └── endpoints/ # API endpoint modules
|
|
│ ├── core/ # Core functionality
|
|
│ │ └── config.py # Application configuration
|
|
│ ├── crud/ # CRUD operations
|
|
│ ├── db/ # Database setup
|
|
│ │ ├── base.py # SQLAlchemy models registry
|
|
│ │ ├── base_class.py # SQLAlchemy base class
|
|
│ │ ├── deps.py # Dependencies for database
|
|
│ │ └── session.py # Database session
|
|
│ ├── models/ # SQLAlchemy models
|
|
│ ├── schemas/ # Pydantic schemas
|
|
│ └── utils/ # Utility functions
|
|
├── migrations/ # Alembic migration scripts
|
|
│ └── versions/ # Migration versions
|
|
├── main.py # Application entry point
|
|
└── requirements.txt # Python dependencies
|
|
```
|
|
|
|
## Database
|
|
|
|
The application uses SQLite for data storage. The database file is located at `/app/storage/db/db.sqlite`.
|
|
|
|
## Environment Variables
|
|
|
|
The application supports the following environment variables:
|
|
|
|
- `API_V1_STR`: API version 1 prefix (default: "/api/v1")
|
|
- `PROJECT_NAME`: Project name (default: "Sports Betting Verification API")
|
|
- `PROJECT_DESCRIPTION`: Project description
|
|
- `CORS_ORIGINS`: Comma-separated list of allowed CORS origins (default: all origins are allowed)
|
|
|
|
## Development
|
|
|
|
### Running Tests
|
|
|
|
```bash
|
|
pytest
|
|
```
|
|
|
|
### Linting
|
|
|
|
```bash
|
|
ruff check .
|
|
```
|
|
|
|
### Auto-fix Linting Issues
|
|
|
|
```bash
|
|
ruff check --fix .
|
|
```
|
|
|
|
## License
|
|
|
|
[Specify license information] |