
- 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
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 categoriesGET /api/v1/categories/{category_id}
: Get a specific categoryPOST /api/v1/categories
: Create a new categoryPUT /api/v1/categories/{category_id}
: Update a categoryDELETE /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 questionPOST /api/v1/questions
: Create a new questionPUT /api/v1/questions/{question_id}
: Update a questionDELETE /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 questionsPOST /api/v1/quizzes
: Create a new quizPUT /api/v1/quizzes/{quiz_id}
: Update a quizDELETE /api/v1/quizzes/{quiz_id}
: Delete a quiz
Results
GET /api/v1/results
: Get all quiz resultsGET /api/v1/results/{result_id}
: Get a specific resultGET /api/v1/results/user/{user_id}
: Get all results for a specific userPOST /api/v1/results
: Create a new quiz result
Prerequisites
- Python 3.8+
- pip (Python package installer)
Installation
-
Clone the repository:
git clone https://github.com/yourusername/biblequizappapi.git cd biblequizappapi
-
Install the required packages:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
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
- Create/update SQLAlchemy models in
app/models/
- Create/update Pydantic schemas in
app/schemas/
- Create/update service functions in
app/services/
- Create/update API endpoints in
app/api/v1/endpoints/
- Add routes to the router in
app/api/v1/router.py
- Generate new migration with Alembic if needed:
alembic revision --autogenerate -m "your_migration_description"
- Apply migrations:
alembic upgrade head
License
This project is licensed under the MIT License - see the LICENSE file for details.
Description
Languages
Python
98.5%
Mako
1.5%