A REST API built with FastAPI and SQL Server, serving as the backend for a recipe-listing app. It handles user authentication, recipe creation and browsing, ingredients, categories, and step-by-step instructions.
Built as the final project for a Mobile Application Development (DAM) course.
- JWT authentication — registration, login, and protected endpoints via OAuth2 password flow, with bcrypt password hashing
- Recipes — create, fetch, and browse by author, category, or ingredient
- Full-text style search — case-insensitive search across recipe titles, descriptions, ingredients, and categories
- Ingredients & categories — CRUD-lite endpoints plus "top used" rankings (most popular ingredients/categories by recipe count)
- Step-by-step instructions attached to each recipe
- User management — profile lookup, password change, account deletion
| Layer | Technology |
|---|---|
| Framework | FastAPI |
| ORM | SQLAlchemy 2.0 |
| Database | Microsoft SQL Server (via pymssql) |
| Auth | JWT (python-jose) + passlib/bcrypt |
| Validation | Pydantic 2 |
| Server | Uvicorn |
| Hosting | Replit |
app/
├── models/ # SQLAlchemy ORM models (User, Recipe, Ingredient, Category, Instruction, ...)
├── schemas/ # Pydantic request/response schemas
├── routers/ # API endpoints (auth, users, recipes, ingredients, categories, instructions)
├── security/ # JWT handling, password hashing, auth dependencies
├── config.py # Environment-based settings
└── database.py # SQLAlchemy engine/session setup
SQL/
├── TableCreation.sql # Database schema (SQL Server)
└── MockData.sql # Seed data for local testing
main.py # Uvicorn entrypoint
Seven related tables: users, recipes, categories, ingredients, instructions, recipe_categories (many-to-many) and recipe_ingredients (many-to-many with amount/unit). See SQL/TableCreation.sql for the full DDL.
- Python 3.12
- A SQL Server instance (local or remote) — connects via
pymssql, no ODBC driver needed
git clone https://github.com/viribusegovis/DAM-Final-API.git
cd DAM-Final-API
python -m venv .venv
.venv\Scripts\activate # Windows
source .venv/bin/activate # macOS/Linux
pip install -r requirements.txtCreate a .env file in the project root:
DB_SERVER=your-sql-server-host
DB_NAME=your-database-name
DB_USERNAME=your-db-username
DB_PASSWORD=your-db-password
JWT_SECRET=a-long-random-secret
JWT_ALGORITHM=HS256Run the schema script against your database first:
sqlcmd -S <server> -d <database> -i SQL/TableCreation.sql(Optionally load SQL/MockData.sql for sample recipes.)
python main.pyThe API starts on http://0.0.0.0:8080. Interactive docs are available at http://localhost:8080/docs (Swagger UI) and /redoc.
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /token |
Login, returns a JWT | |
| POST | /users/register |
Register a new user | |
| GET | /users/me |
✅ | Current user profile |
| GET | /users/{user_id} |
✅ | Get user by ID |
| POST | /users/password |
✅ | Change password |
| DELETE | /users/deletion |
✅ | Delete own account |
| GET | /recipes/ |
List all recipes | |
| GET | /recipes/{recipe_id} |
Recipe detail | |
| GET | /recipes/search?query= |
Search recipes | |
| GET | /recipes/category/{category_id} |
Recipes by category | |
| GET | /recipes/ingredient/{ingredient_id} |
Recipes by ingredient | |
| GET | /recipes/author/?author_id= |
✅ | Recipes by author |
| GET | /recipes/{recipe_id}/ingredients |
Ingredients for a recipe | |
| GET | /recipes/{recipe_id}/instructions |
Instructions for a recipe | |
| POST | /recipes/ |
✅ | Create a recipe |
| GET | /ingredients/ |
List ingredients | |
| GET | /ingredients/top/{limit} |
Most-used ingredients | |
| GET | /ingredients/search?query= |
Search ingredients | |
| POST | /ingredients/ |
✅ | Create an ingredient |
| GET | /categories/ |
List categories | |
| GET | /categories/top |
Most-used categories | |
| POST | /categories/ |
✅ | Create a category |
| GET | /instructions/ |
List instructions |
Full interactive reference: /docs once the server is running.