Skip to content

sergiomarquezdev/fastapi-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI PostgreSQL Quiz API

A simple REST API built with FastAPI and PostgreSQL for managing quiz questions and choices.

Features

  • Create questions with multiple choices
  • Retrieve questions by ID
  • Get choices for specific questions
  • PostgreSQL database integration
  • OpenAPI documentation (Swagger UI)

Prerequisites

  • Python 3.12 or higher
  • Docker and Docker Compose
  • Poetry (optional)

Installation

  1. Clone the repository:
git clone https://github.com/sergiomarquezdev/fastapi-postgresql
cd fastapi-postgresql
  1. Install dependencies:
# Using uv (recommended)
uv pip install -e .

# Or using poetry
poetry install

Running the Application

  1. Start PostgreSQL database:
docker-compose up -d
  1. Run the FastAPI application:
uvicorn src.fastapi_postgresql.main:app --reload

The API will be available at http://localhost:8000

API Documentation

Access the interactive API documentation at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

API Endpoints

  • GET /questions/{question_id} - Get a specific question
  • GET /choices/{question_id} - Get choices for a specific question
  • POST /questions - Create a new question with choices

Example Request

POST /questions
{
  "question_text": "What is the capital of France?",
  "choices": [
    {
      "choice_text": "Paris",
      "is_correct": true
    },
    {
      "choice_text": "London",
      "is_correct": false
    }
  ]
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages