FastAPI backend for the FFPU (Financial Futures Portfolio Utility) application.
- Authentication System: JWT-based authentication with Google OAuth support
- Strategy Management: Save, retrieve, and execute trading strategies
- Database Integration: SQLAlchemy ORM with PostgreSQL support
- Email Services: SMTP integration for user verification and password reset
- RESTful API: Clean, documented API endpoints
- Framework: FastAPI
- Database: PostgreSQL (with SQLite fallback for development)
- ORM: SQLAlchemy
- Authentication: JWT, Google OAuth
- Email: SMTP with Jinja2 templates
- Python Version: 3.9+
backend-repo/
├── app/
│ ├── auth/ # Authentication routes and services
│ ├── database/ # Database models and connection
│ ├── strategy/ # Strategy execution and management
│ ├── templates/ # Email templates
│ ├── __init__.py
│ └── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
└── README.md
-
Clone the repository
git clone <your-backend-repo-url> cd backend-repo
-
Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.env
file with:DATABASE_URL=postgresql://user:password@localhost:5432/ffpu_db SECRET_KEY=your-secret-key-here GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret GOOGLE_REDIRECT_URI=http://localhost:3000/auth/google/callback SMTP_SERVER=smtp.gmail.com SMTP_PORT=587 SMTP_USERNAME=your-email@gmail.com SMTP_PASSWORD=your-app-password ALGORITHM=HS256
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
uvicorn app.main:app --host 0.0.0.0 --port 8000
Once running, visit:
- Interactive API Docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /api/auth/login
- User loginPOST /api/auth/signup
- User registrationGET /api/auth/google/login
- Google OAuth loginPOST /api/auth/forgot-password
- Password reset requestPOST /api/auth/reset-password
- Password reset completion
POST /api/strategy/execute
- Execute trading strategyPOST /api/strategy/save
- Save new strategyGET /api/strategy/get_all_public_strategies
- Get public strategiesGET /api/strategy/get_all_strategy_user
- Get user strategiesGET /api/strategy/strategies
- Get specific strategy
- Install PostgreSQL
- Create database:
CREATE DATABASE ffpu_db;
- Set
DATABASE_URL
in environment variables
For development, you can use SQLite by setting:
DATABASE_URL=sqlite:///./ffpu.db
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
[Add your license here]