Skip to content

A REST API for issue tracking built with FastAPI. Provides CRUD operations for managing issues with priority levels, status tracking, and JSON-based persistence. Includes request timing middleware and CORS support for web integration.

Notifications You must be signed in to change notification settings

Stradakat/FastAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FastAPI Issue Tracker

A RESTful API for issue tracking built with FastAPI. This application provides full CRUD operations for managing issues with priority levels, status tracking, and JSON-based persistence.

Features

  • βœ… Full CRUD operations (Create, Read, Update, Delete) for issues
  • 🏷️ Issue status tracking (open, in_progress, closed)
  • ⚑ Priority levels (low, medium, high)
  • πŸ“ Automatic data validation using Pydantic
  • πŸ• Request timing middleware
  • 🌐 CORS support for web integration
  • πŸ“š Interactive API documentation (Swagger UI)
  • πŸ’Ύ JSON-based file storage

Tech Stack

  • FastAPI - Modern, fast web framework for building APIs
  • Pydantic - Data validation using Python type annotations
  • Uvicorn - ASGI server for running the application
  • Python 3.9+ - Programming language

Installation

Prerequisites

  • Python 3.9 or higher
  • pip (Python package manager)

Setup

  1. Clone the repository:
git clone <repository-url>
cd FastAPI
  1. Create a virtual environment:
python3 -m venv .venv
  1. Activate the virtual environment:
# On macOS/Linux:
source .venv/bin/activate

# On Windows:
.venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Running the Application

Start the development server:

uvicorn main:app --reload

The API will be available at:

Deployment

The application is deployed and available at:

🌐 Live API: https://fastapi-vs9l.onrender.com

You can access the interactive API documentation at:

All API endpoints are available at the base URL. For example:

  • Get all issues: https://fastapi-vs9l.onrender.com/api/v1/issues/
  • Create an issue: POST https://fastapi-vs9l.onrender.com/api/v1/issues/

API Endpoints

All endpoints are prefixed with /api/v1/issues

Get All Issues

GET /api/v1/issues/

Returns a list of all issues.

Response: 200 OK

[
  {
    "id": "uuid-string",
    "title": "Issue title",
    "description": "Issue description",
    "priority": "medium",
    "status": "open"
  }
]

Get Issue by ID

GET /api/v1/issues/{issue_id}

Returns a specific issue by its ID.

Parameters:

  • issue_id (string): The unique identifier of the issue

Response: 200 OK or 404 Not Found

Create Issue

POST /api/v1/issues/

Creates a new issue.

Request Body:

{
  "title": "Fix authentication bug",
  "description": "Users cannot log in with their credentials",
  "priority": "high"
}

Validation Rules:

  • title: 3-100 characters
  • description: 5-1000 characters
  • priority: "low", "medium", or "high" (defaults to "medium")

Response: 201 Created

Update Issue

PUT /api/v1/issues/{issue_id}

Updates an existing issue. All fields are optional.

Request Body:

{
  "title": "Updated title",
  "description": "Updated description",
  "priority": "high",
  "status": "in_progress"
}

Response: 200 OK or 404 Not Found

Delete Issue

DELETE /api/v1/issues/{issue_id}

Deletes an issue by its ID.

Response: 204 No Content or 404 Not Found

Example Usage

Using cURL

Create an issue:

curl -X POST "http://localhost:8000/api/v1/issues/" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Fix bug in authentication",
    "description": "Users cannot log in with their credentials",
    "priority": "high"
  }'

Get all issues:

curl http://localhost:8000/api/v1/issues/

Get a specific issue:

curl http://localhost:8000/api/v1/issues/{issue_id}

Update an issue:

curl -X PUT "http://localhost:8000/api/v1/issues/{issue_id}" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "in_progress",
    "priority": "high"
  }'

Delete an issue:

curl -X DELETE "http://localhost:8000/api/v1/issues/{issue_id}"

Using Python

import requests

# Create an issue
response = requests.post(
    "http://localhost:8000/api/v1/issues/",
    json={
        "title": "Fix authentication bug",
        "description": "Users cannot log in",
        "priority": "high"
    }
)
issue = response.json()

# Get all issues
issues = requests.get("http://localhost:8000/api/v1/issues/").json()

# Update an issue
requests.put(
    f"http://localhost:8000/api/v1/issues/{issue['id']}",
    json={"status": "in_progress"}
)

Project Structure

FastAPI/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ schemas.py          # Pydantic models for data validation
β”‚   β”œβ”€β”€ storage.py          # JSON file storage utilities
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── timer.py        # Request timing middleware
β”‚   └── routes/
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── issues.py       # Issue CRUD endpoints
β”œβ”€β”€ data/
β”‚   └── issues.json         # JSON data storage (auto-created)
β”œβ”€β”€ main.py                 # FastAPI application entry point
β”œβ”€β”€ requirements.txt        # Python dependencies
└── README.md              # This file

Data Models

Issue Status

  • open - Issue is newly created
  • in_progress - Issue is being worked on
  • closed - Issue is resolved

Issue Priority

  • low - Low priority issue
  • medium - Medium priority issue (default)
  • high - High priority issue

Development

Running in Development Mode

The --reload flag enables auto-reload on code changes:

uvicorn main:app --reload

Data Storage

Issues are stored in data/issues.json. This file is automatically created when the first issue is saved.

License

This project is open source and available under the MIT License.

About

A REST API for issue tracking built with FastAPI. Provides CRUD operations for managing issues with priority levels, status tracking, and JSON-based persistence. Includes request timing middleware and CORS support for web integration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors