An open API service indexing awesome lists of open source software.

https://github.com/tushar-3549/api-development

FastAPI application showcasing backend development with Python, including RESTful APIs, database integration with PostgreSQL, and modern development practices.
https://github.com/tushar-3549/api-development

api-development backend fastapi jwt oauth2 postgresql-database sqlalchemy

Last synced: 3 months ago
JSON representation

FastAPI application showcasing backend development with Python, including RESTful APIs, database integration with PostgreSQL, and modern development practices.

Awesome Lists containing this project

README

          

## ShareThoughts API

A high-performance ShareThoughts API built using **FastAPI**, **PostgreSQL**, and **Alembic**. This project implements secure user authentication, robust database operations, and thorough testing to ensure a reliable and efficient system.

---

## ๐Ÿš€ Features

- ๐Ÿ” **User Authentication** (JWT-based login/logout using OAuth2)
- ๐Ÿ“ **CRUD Operations** for posts and users
- ๐Ÿ”‘ **Password Hashing** for secure login credentials
- ๐Ÿ—„๏ธ **PostgreSQL Integration** using SQLAlchemy ORM
- ๐Ÿ”„ **Alembic Migrations** for schema versioning
- ๐Ÿ›ก๏ธ **SQL Injection Prevention** with ORM best practices
- โœ… **Unit Testing** with Pytest (users, auth, DB, API endpoints)
- ๐Ÿงช **Postman API Testing** support
- โš™๏ธ **GitHub Actions** for CI/CD
- ๐Ÿณ **Docker Support** for easy containerized deployment

---

## ๐Ÿ› ๏ธ Technologies Used

- **FastAPI** โ€“ Modern, high-performance web framework
- **PostgreSQL** โ€“ Relational database
- **SQLAlchemy** โ€“ ORM for interacting with the DB
- **Alembic** โ€“ Database migrations
- **OAuth2 & JWT** โ€“ Secure authentication
- **Pytest** โ€“ Python testing framework
- **GitHub Actions** โ€“ CI/CD automation

---

## ๐Ÿ“ฆ Installation

### โœ… Prerequisites

Ensure the following are installed:

- Python (3.10 or higher)
- PostgreSQL
- Virtual environment module (venv)

### ๐Ÿ”ง Steps

1. **Clone the repository**
```bash
git clone https://github.com/tushar-3549/API-Development.git
cd API-Development
```
2. **Create and activate a virtual environment**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install dependencies**
`pip install -r requirements.txt`
4. **Set up your `.env` file**
```
DATABASE_URL=postgresql://:@localhost/
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
```
5. **Apply Alembic migrations**
`alembic upgrade head`
6. **Run the FastAPI server**
`uvicorn app.main:app --reload`
- Visit the API at: `http://127.0.0.1:8000`
- Docs: `http://127.0.0.1:8000/docs`
- ๐Ÿงช **Running Tests**

```pytest```

**ER Diagram**

![fastapi - public](https://github.com/user-attachments/assets/fd5483ed-7abf-4943-a931-e8c9e365b17b)