Skip to content

chriscarias/notes-api-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure Polyglot Notes API (Python Layer)

A production-ready, secure, and authenticated RESTful Notes API built using FastAPI and SQLAlchemy (ORM), backed by a PostgreSQL database running inside a Docker container.

This project implements strict user isolation via JWT Authentication, ensuring that users can only manage their own notes.

This is part of a bigger project, same API in three different languages, hence the 'polyglot' name.

Features

  • Full CRUD Operations: Create, read, update (PATCH), and delete notes.
  • JWT Authentication: User registration and token-based login security hooks.
  • Data Isolation: Foreign key constraints map notes to specific owners.
  • Data Validation: Strict structural parsing using Pydantic schemas.

Tech Stack

  • Language: Python 3.12
  • Framework: FastAPI (ASGI)
  • ORM: SQLAlchemy
  • Database: PostgreSQL 16 (Dockerized)
  • Security: Passlib (Bcrypt 4.0.1) & PyJWT

Local Setup & Installation

1. Clone the Repository

git clone https://github.com/chriscarias/notes-api-python.git
cd notes-api-python

2. Run the PostgreSQL Container

Ensure Docker is running, then fire up the database process:

docker run --name polyglot-db \
  -e POSTGRES_USER=user \
  -e POSTGRES_PASSWORD=password \
  -e POSTGRES_DB=notes_db \
  -p 5433:5432 \
  -d postgres:16

Port mapping if needed.

3. Setup Environment Variables

Create a .env file in the root directory:

Code snippet

DATABASE_URL=postgresql://user:password@127.0.0.1:5433/notes_db
JWT_SECRET=YOUR_NEW_SECURE_RANDOM_STRING

use openssl rand -hex 32 to create JWT_SECRET

4. Install Dependencies

Create a virtual environment and install the required packages:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

5. Launch the Server

uvicorn main:app --reload

The API will be at http://127.0.0.1:8000. Interactive API docs at http://127.0.0.1:8000/docs.

About

Polyglot Notes API project using python FastAPI

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages