Automated Action 6f0470e475 Implement Bible Quiz App API with FastAPI and SQLite
- Setup project structure with FastAPI app
- Create SQLAlchemy models for categories, questions, quizzes, and results
- Implement API endpoints for all CRUD operations
- Set up Alembic migrations for database schema management
- Add comprehensive documentation in README.md
2025-06-05 10:31:02 +00:00

137 lines
4.4 KiB
Markdown

# Bible Quiz App API
A RESTful API for a Bible quiz application built with FastAPI and SQLite.
## Features
- Comprehensive Bible quiz management system
- Categories management (e.g., Old Testament, New Testament, etc.)
- Questions and answers with difficulty levels and Bible references
- Quiz creation and management
- User quiz results tracking
- RESTful API with full CRUD operations
- SQLite database with SQLAlchemy ORM
- Alembic migrations for database versioning
## API Endpoints
### Health Check
- `GET /health`: Check if the API is running properly
### Categories
- `GET /api/v1/categories`: Get all categories
- `GET /api/v1/categories/{category_id}`: Get a specific category
- `POST /api/v1/categories`: Create a new category
- `PUT /api/v1/categories/{category_id}`: Update a category
- `DELETE /api/v1/categories/{category_id}`: Delete a category
### Questions
- `GET /api/v1/questions`: Get all questions (with optional filtering)
- `GET /api/v1/questions/{question_id}`: Get a specific question
- `POST /api/v1/questions`: Create a new question
- `PUT /api/v1/questions/{question_id}`: Update a question
- `DELETE /api/v1/questions/{question_id}`: Delete a question
### Quizzes
- `GET /api/v1/quizzes`: Get all quizzes (with optional filtering)
- `GET /api/v1/quizzes/{quiz_id}`: Get a specific quiz with its questions
- `POST /api/v1/quizzes`: Create a new quiz
- `PUT /api/v1/quizzes/{quiz_id}`: Update a quiz
- `DELETE /api/v1/quizzes/{quiz_id}`: Delete a quiz
### Results
- `GET /api/v1/results`: Get all quiz results
- `GET /api/v1/results/{result_id}`: Get a specific result
- `GET /api/v1/results/user/{user_id}`: Get all results for a specific user
- `POST /api/v1/results`: Create a new quiz result
## Prerequisites
- Python 3.8+
- pip (Python package installer)
## Installation
1. Clone the repository:
```
git clone https://github.com/yourusername/biblequizappapi.git
cd biblequizappapi
```
2. Install the required packages:
```
pip install -r requirements.txt
```
3. Run database migrations:
```
alembic upgrade head
```
4. Start the application:
```
uvicorn main:app --reload
```
## Environment Variables
The application uses the following environment variables:
- `SECRET_KEY`: Secret key for tokens (defaults to "insecuresecretkey" if not provided)
- `ACCESS_TOKEN_EXPIRE_MINUTES`: Token expiration time in minutes (defaults to 10080 - 7 days)
## API Documentation
Once the application is running, you can access the Swagger UI documentation at:
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
- OpenAPI JSON: `http://localhost:8000/openapi.json`
## Development
### Project Structure
```
.
├── alembic.ini # Alembic configuration
├── app # Application package
│ ├── api # API endpoints
│ │ └── v1 # API version 1
│ │ ├── endpoints # API endpoint modules
│ │ └── router.py # API router
│ ├── core # Core modules
│ │ └── config.py # Configuration settings
│ ├── db # Database modules
│ │ └── session.py # Database session
│ ├── models # SQLAlchemy models
│ ├── schemas # Pydantic schemas
│ └── services # Business logic services
├── main.py # Application entry point
├── migrations # Alembic migrations
│ ├── env.py # Alembic environment
│ ├── README # Migrations readme
│ ├── script.py.mako # Migration script template
│ └── versions # Migration versions
└── requirements.txt # Project dependencies
```
### Adding New Features
1. Create/update SQLAlchemy models in `app/models/`
2. Create/update Pydantic schemas in `app/schemas/`
3. Create/update service functions in `app/services/`
4. Create/update API endpoints in `app/api/v1/endpoints/`
5. Add routes to the router in `app/api/v1/router.py`
6. Generate new migration with Alembic if needed:
```
alembic revision --autogenerate -m "your_migration_description"
```
7. Apply migrations:
```
alembic upgrade head
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.