
- Setup project structure with FastAPI - Create database models for users, gifts, preferences, and recommendations - Configure SQLite database with SQLAlchemy ORM - Setup Alembic for database migrations - Implement user authentication with JWT - Create API endpoints for users, gifts, preferences, and recommendations - Integrate OpenAI API for gift recommendations - Add comprehensive documentation
AI Powered Gifting Platform
An intelligent API service that helps users find the perfect gift for any recipient using AI recommendations based on preferences and interests.
Features
- 🎁 Gift Management: Track gift ideas, purchases, and occasions
- 🧠 AI-Powered Recommendations: Get personalized gift suggestions based on recipient preferences
- 👤 User Profiles: Secure authentication and user management
- 🔍 Preference Tracking: Store recipient interests, hobbies, sizes, and dislikes
- 🔒 Secure API: JWT authentication with role-based access control
Tech Stack
- Framework: FastAPI
- Database: SQLite with SQLAlchemy ORM
- Authentication: JWT with OAuth2
- Migrations: Alembic
- AI Integration: OpenAI API
- Code Quality: Ruff linter
Getting Started
Prerequisites
- Python 3.8+
- OpenAI API key (for AI-powered recommendations)
Environment Variables
Create a .env
file in the project root with the following variables:
SECRET_KEY=your-secret-key-for-jwt
OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-3.5-turbo # or another OpenAI model
Installation
- Clone the repository:
git clone <repository-url>
cd ai-powered-gifting-platform
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API Documentation
Once the application is running, you can access:
- Interactive API documentation: http://localhost:8000/docs
- Alternative documentation: http://localhost:8000/redoc
- OpenAPI schema: http://localhost:8000/openapi.json
API Endpoints
Health Check
GET /api/v1/health
: Check the API service health
Authentication
POST /api/v1/auth/login
: Get access token
Users
POST /api/v1/users
: Create new userGET /api/v1/users/me
: Get current user infoPUT /api/v1/users/me
: Update current user
Gifts
GET /api/v1/gifts
: List all giftsPOST /api/v1/gifts
: Create a new giftGET /api/v1/gifts/{id}
: Get gift detailsPUT /api/v1/gifts/{id}
: Update a giftDELETE /api/v1/gifts/{id}
: Delete a gift
Preferences
GET /api/v1/preferences
: List all preferencesPOST /api/v1/preferences
: Create a new preferenceGET /api/v1/preferences/{id}
: Get preference detailsPUT /api/v1/preferences/{id}
: Update a preferenceDELETE /api/v1/preferences/{id}
: Delete a preference
Recommendations
GET /api/v1/recommendations
: List all recommendationsPOST /api/v1/recommendations
: Get AI-powered gift recommendationGET /api/v1/recommendations/{id}
: Get recommendation detailsPUT /api/v1/recommendations/{id}
: Update a recommendationDELETE /api/v1/recommendations/{id}
: Delete a recommendation
Project Structure
.
├── alembic.ini # Alembic configuration
├── app # Application package
│ ├── api # API endpoints
│ │ └── v1 # API version 1
│ │ ├── endpoints # API endpoint modules
│ │ └── api.py # API router
│ ├── core # Core modules
│ │ ├── config.py # Settings and configuration
│ │ └── security.py # Security utilities
│ ├── db # Database modules
│ │ ├── base.py # SQLAlchemy Base
│ │ ├── deps.py # Dependency functions
│ │ └── session.py # Database session
│ ├── models # SQLAlchemy models
│ ├── schemas # Pydantic schemas
│ └── services # Business logic services
├── main.py # Application entry point
├── migrations # Alembic migrations
│ ├── versions # Migration scripts
│ └── env.py # Alembic environment
└── requirements.txt # Project dependencies
Development
Database Migrations
To create a new migration after modifying models:
alembic revision --autogenerate -m "Description of changes"
To apply migrations:
alembic upgrade head
Linting
Run the linter to ensure code quality:
ruff check .
Fix auto-fixable issues:
ruff check --fix .
License
Description
Languages
Python
98.9%
Mako
1.1%