A simple notepad api project focuse on minimal CRUD principles. The moment i was crafting this project, my focus was to learn SOLID principles in a simple implemenation of minimal project I accept feedback and suggestions you guys can provide me
Feel free to use it, play around with it, and update whatever doesn't suit your needs.
| Principle | Implementation in Code |
|---|---|
| Single Responsibility | Each module has one job: notes.py handles HTTP only, note_service.py handles business logic, MySQLRepository.py handles persistence. |
| Open/Closed | Query strategies (query_strategies.py) allow adding new fetch types (e.g., SortedNoteStrategy) without modifying get_notes—new strategies are added by extending, not changing existing code. |
| Liskov Substitution | MySQLRepository implements NoteRepository and can be swapped with another implementation (e.g., PostgreSQLRepository) without breaking consumers. |
| Interface Segregation | NoteReader and NoteWriter are split; DeleteId is separate from Id—clients depend only on the methods they use. |
| Dependency Inversion | Services depend on the abstract NoteRepository, not concrete MySQL—dependency injection via FastAPI Depends(). |
- Create note
- Read note by ID
- Get notes (all, sorted by desc)
- Update note
- Delete note (single or batch)
- Python 3.10+
- MySQL database
- FastAPI (with standard dependencies)
- curl
- postman
git clone https://github.com/debil746429/notepadAPI.git
cd notepadAPIOn Linux/macOS:
python3 -m venv .venv
source .venv/bin/activateOn Windows:
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txt-
Create a MySQL database (make sure you don't have a database named
notepadif you're using the default configuration) -
Update the
.envfile with your configuration:
# Database Configuration
db_host = localhost
db_name = notepad
db_user = your_database_user
db_password = your_database_password- Import the database schema:
mysql -u your_db_user -p your_database_name < schema.sqlOr manually execute the SQL commands from schema.sql in your MySQL client.
Start the development server:
fastapi dev app/main.pyThe API will be available at http://127.0.0.1:8000
Once the server is running, you can view the interactive API documentation at:
- ReDoc: http://127.0.0.1:8000/redoc
- Swagger UI: http://127.0.0.1:8000/docs
You can test the endpoints using:
- cURL - Command-line tool for making HTTP requests
- Postman - API testing and development platform
- Swagger UI - Interactive documentation at
/docsendpoint
notepadAPI/
├── app/
│ ├── api/
│ │ ├── main.py # API router setup
│ │ └── v1/
│ │ ├── main.py # v1 router
│ │ └── routes/
│ │ └── notes.py # Note endpoints
│ ├── core/
│ │ └── config.py # Settings (env)
│ ├── models/
│ │ └── note.py # Pydantic models
│ ├── repositories/
│ │ ├── note_repository.py # Abstract repository interface
│ │ ├── MySQLRepository.py # MySQL implementation
│ │ └── query_strategies.py # Query strategy pattern
│ ├── services/
│ │ └── note_service.py # Business logic
│ └── main.py # FastAPI entry point
├── .env
├── requirements.txt
├── schema.sql
├── LICENSE.md
└── README.md
See LICENSE.md for details.
Feel free to fork this project, make changes, and submit pull requests. This is a learning project, so contributions and improvements are welcome!