A simple REST API for managing notes, built with FastAPI and SQLite.
- Create notes
- List all notes
- Get a specific note
- Delete notes
- Automatic API documentation (Swagger UI)
- Full test coverage
- CI/CD with GitHub Actions
- Install dependencies:
pip install -r requirements.txt- Run the API:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
Once running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
GET /- Welcome messagePOST /notes- Create a new noteGET /notes- List all notesGET /notes/{note_id}- Get a specific noteDELETE /notes/{note_id}- Delete a note
Run the test suite:
pytest tests/ -vGitHub Actions runs tests automatically on:
- Pushes to
masterordevbranches - Pull requests to
masterordevbranches
The project structure:
notes-api/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI app and endpoints
│ ├── models.py # Pydantic models
│ └── database.py # SQLAlchemy setup
├── tests/
│ ├── __init__.py
│ └── test_api.py # Test suite
├── requirements.txt
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions config
└── README.md
This project uses C4 model annotations embedded in the source code to generate architecture diagrams.
Diagrams are automatically generated in CI and uploaded as artifacts.
To generate locally:
# Install c4-literate-python
pip install git+https://github.com/ChristosDev75/c4-literate-python.git
# Generate diagrams
c4-literate tangle . -o docs/architecture/workspace.dsl
# View with Structurizr Lite
docker run -it --rm -p 8080:8080 \
-v $(pwd):/usr/local/structurizr:Z \
docker.io/structurizr/lite
# Open http://localhost:8080Architecture is documented using C4 annotations in Python docstrings. See the c4-literate-python schema for annotation reference.
Example:
"""
@c4-container: API Application
@c4-technology: Python 3.12, FastAPI
@c4-description: REST API providing CRUD operations
"""