
A blazing-fast and elegant note-taking API built with FastAPI and MongoDB, featuring full CRUD operations and version control.
FastAPI Notes is a modern backend service that lets you create, read, update, and delete notes — with built-in version history tracking.
It’s designed for developers and teams who want to manage note revisions with the same flexibility as code commits.
- ⚡ Fast & Async — Built with FastAPI for ultra-fast responses.
- 🗂️ Full CRUD Support — Create, read, update, and delete notes easily.
- 🔄 Version Control — Track every change and revert to previous versions.
- 🔒 RESTful & Extensible — Clean endpoints, easily integrable with any frontend.
- 🧠 JSON-based API — Ideal for modern web and mobile applications.
| Layer | Technology |
|---|---|
| Backend Framework | FastAPI |
| Database | MongoDB or SQLite (optional) |
| ORM / ODM | Motor |
| API Docs | Swagger / ReDoc (auto-generated) |
| Language | Python 3.10+ |
| Versioning | Custom version control model |
fastapi-notes/
├─ app.py
├─ auth.py
├─ utils.py
├─ utils_b64.py
├─ utils_media.py
├─ requirements.txt
├─ README.md
├─ models/
│ ├─ auth_models.py
│ ├─ notes.py
│ └─ sql_models.py
├─ databases/
│ ├─ mongodb_connect.py
│ └─ sql_connect.py
├─ repositories/
│ ├─ notes_repository.py
get_all_notes
│ ├─ sql_notes_repository.py
get_all_notes
│ ├─ users_repository.py
│ └─ sql_users_repository.py
└─ scripts/
├─ migrate_to_base64_mongo.py
└─ migrate_to_base64_sql.py
git clone https://github.com/yourusername/fastapi-notes.git
cd fastapi-notespython -m venv venv
source venv/bin/activate # For Linux/Mac
venv\Scripts\activate # For Windowspip install -r requirements.txtCopy .env.example to .env and configure your MongoDB URI:
MONGO_URI=mongodb://localhost:27017
DB_NAME=notes_dbuvicorn app.main:app --reloadAccess the docs:
- Swagger UI → http://localhost:8000/docs
- ReDoc → http://localhost:8000/redoc
- Supported types: images (jpeg, png, gif, webp) and videos (mp4, webm, mov).
- Strict limit: 5 MB per file. Larger files are skipped with a warning; the request still succeeds.
- Files are stored under
UPLOAD_DIR(default:./uploads) and served at/uploads/....
POST /media/upload(Bearer token required)
Multipart field:files(one or many). Returns{ saved: [...], errors: [...] }.POST /notes
JSON body supports optionalmedia: [{ url, mime_type, size_bytes, original_name }].
Use after uploading files to/media/upload.POST /notes/with-media
Multipart form:note_title,note_description,files[]. Uploads and attaches in one step.
Media is not Base64 encoded. Only note
title/descriptionare stored as Base64.
Existing notes remain valid;mediadefaults to an empty list.
This API stores notes in Base64 (UTF-8 → Base64 in DB) and decodes on responses.
Why? Safer transport, no encoding surprises, and consistent cross-DB behavior.
note_titlenote_description- (Mongo only)
note_history[*].note_title,note_history[*].note_description
No action needed. The repositories encode on write and decode on read automatically.
Backup first! Always snapshot your DB before migrations.
export MONGO_URI="mongodb://localhost:27017"
export DB_NAME="notes_db"
python scripts/migrate_to_base64_mongo.py
---
## 🧬 Version Control Logic
Each note update automatically creates a new version entry:
```json
{
"note_id": "123abc",
"title": "Meeting Notes",
"content": "Discussed project timeline",
"version": 3,
"updated_at": "2025-10-31T10:00:00Z"
}You can easily revert to an older version via the /notes/{id}/versions/{version_id} endpoint.
Contributions are welcome!
Follow these steps to contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature-name) - Commit changes (
git commit -m "feat: add feature-name") - Push to your fork (
git push origin feature-name) - Submit a Pull Request
Please follow Conventional Commits format.
| Name | Role | GitHub |
|---|---|---|
| Arpan Singh | Lead Developer | @yourusername |
- 🧩 User authentication (JWT-based)
- 🌐 Multi-user collaboration
- 💾 Export/Import notes
- ☁️ Cloud deployment via Docker
This project is licensed under the MIT License — feel free to use and modify it.
Made with ❤️ using FastAPI and Python.