Skip to content

somashekhar/InstaAPI

Repository files navigation

InstaAPI

A RESTful API built with FastAPI for creating, managing, and interacting with social media posts

Project Overview

InstaAPI is a robust backend service for a social media application, providing secure and efficient endpoints for user management, post operations, and social interactions. The API implements full authentication, comprehensive CRUD operations, data validation, and detailed API documentation.

Features

  • User Management

    • Registration with secure password hashing
    • Authentication using JWT tokens
    • User profile retrieval
  • Post Operations

    • Create, read, update, and delete posts
    • Pagination and search functionality
    • Ownership validation for secured operations
  • Social Interactions

    • Vote/like system for posts
    • Post metrics (vote count)

Technical Stack

Getting Started

Prerequisites

  • Python 3.9+
  • Docker and Docker Compose
  • PostgreSQL

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/InstaAPI.git
    cd InstaAPI
    
  2. Set up environment variables: Create a .env file in the project root with the following variables:

    DATABASE_HOSTNAME=postgres
    DATABASE_PORT=5432
    DATABASE_NAME=InstaAPI
    DATABASE_USERNAME=yourusername
    DATABASE_PASSWORD=yourpassword
    SECRET_KEY=yoursecretkey
    ALGORITHM=HS256
    ACCESS_TOKEN_EXPIRE_MINUTES=60
    
  3. Run with Docker Compose (recommended):

    # For development
    docker compose -f docker-compose-dev.yaml up -d
    
    # For production
    docker compose -f docker-compose-prod.yaml up -d
    
  4. Or set up a local development environment:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    uvicorn app.main:app --reload
    
  5. Run database migrations:

    alembic upgrade head
    

API Documentation

Once the server is running, access the interactive API documentation:

Development

Database Migrations

# Create a new migration
alembic revision --autogenerate -m "description"

# Apply migrations
alembic upgrade head

# Rollback migration
alembic downgrade -1

Running Tests

pytest

Ruff fomat and lint

    ruff check --fix
    ruff format

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

A RESTful API built with FAST API for creating, managing, and interacting with social media posts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages