"""
A comprehensive FastAPI backend for a Forex & Crypto trading community platform featuring authentication, community forums, educational content, marketplace, reviews, signals, and economic calendar.
- JWT-based authentication with refresh tokens
- Social login support (Google, GitHub)
- Email verification and password reset
- Two-factor authentication (2FA)
- Role-based access control (User, Admin)
- Discussion boards with categories (Forex, Crypto, Stocks, AI Trading, General)
- Threaded comments and replies
- Post likes and reactions
- User badges and gamification
- Real-time messaging via WebSocket
- Structured courses (Beginner, Intermediate, Advanced)
- Blog articles and video tutorials
- Progress tracking and completion certificates
- Searchable knowledge base
- Product listings for EAs, bots, indicators, scripts
- Secure digital delivery system
- Ratings and reviews
- Payment processing integration ready
- File upload and management
- Broker and platform reviews
- Verified user reviews
- Detailed rating categories
- Helpful vote system
- Signal provider system
- Subscription management
- Performance tracking and leaderboards
- Real-time signal updates
- Economic events with impact levels
- Country and currency filtering
- Real-time updates
- Clean Architecture pattern
- Repository and Service patterns
- Comprehensive error handling
- Rate limiting and security middleware
- File upload and processing
- Caching with Redis
- Background tasks with Celery
- WebSocket real-time communication
- Full-text search functionality
- Analytics and metrics
- Email notifications
- Database migrations with Alembic
- FastAPI - Modern Python web framework
- PostgreSQL - Primary database
- Redis - Caching and task queue
- SQLAlchemy - ORM
- Alembic - Database migrations
- Celery - Background task processing
- JWT - Authentication tokens
- Pydantic - Data validation
- Docker - Containerization
- Python 3.11+
- PostgreSQL 15+
- Redis 7+
- Clone the repository:
git clone <repository-url>
cd fxutopia_backend- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Environment setup:
cp .env.example .env
# Edit .env with your configuration- Database setup:
# Create database
createdb fxutopia
# Run migrations
alembic upgrade head- Start the application:
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
API documentation at http://localhost:8000/docs
- Build and run with Docker Compose:
docker-compose up -dThis will start:
- API server on port 8000
- PostgreSQL on port 5432
- Redis on port 6379
- Celery worker and beat scheduler
POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/verify-email- Verify email addressPOST /api/v1/auth/forgot-password- Request password resetPOST /api/v1/auth/reset-password- Reset password
GET /api/v1/users/me- Get current user profilePUT /api/v1/users/me- Update user profilePOST /api/v1/users/me/avatar- Upload avatar
GET /api/v1/community/posts- Get postsPOST /api/v1/community/posts- Create postGET /api/v1/community/posts/{id}- Get post by IDPOST /api/v1/community/posts/{id}/like- Like/unlike postPOST /api/v1/community/posts/{id}/comments- Add comment
GET /api/v1/education/content- Get educational contentPOST /api/v1/education/content- Create contentGET /api/v1/education/courses- Get coursesPOST /api/v1/education/courses/{id}/enroll- Enroll in course
GET /api/v1/marketplace/products- Get productsPOST /api/v1/marketplace/products- Create productPOST /api/v1/marketplace/products/{id}/purchase- Purchase product
GET /api/v1/reviews- Get reviewsPOST /api/v1/reviews- Create reviewPOST /api/v1/reviews/{id}/helpful- Mark review helpful
GET /api/v1/signals- Get trading signalsPOST /api/v1/signals- Create signalGET /api/v1/signals/providers- Get signal providers
GET /api/v1/calendar/events- Get economic eventsPOST /api/v1/calendar/events- Create event (admin)
GET /api/v1/search- Global searchGET /api/v1/search/posts- Search postsGET /api/v1/search/articles- Search articles
# Run all tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
# Run specific test file
pytest tests/test_auth.py# Create new migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1# Start Celery worker
celery -A app.core.celery_app worker --loglevel=info
# Start Celery beat scheduler
celery -A app.core.celery_app beat --loglevel=info
# Monitor with Flower
celery -A app.core.celery_app flower --port=5555Key environment variables:
# Database
DATABASE_URL=postgresql://user:password@localhost/fxutopia
# Redis
REDIS_URL=redis://localhost:6379
# Security
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Email
SMTP_HOST=smtp.gmail.com
SMTP_USER=your-email@gmail.com
SMTP_PASSWORD=your-app-password
# File Storage
UPLOAD_FOLDER=uploads
MAX_FILE_SIZE=52428800# Build production image
docker build -t fxutopia-api .
# Run with environment variables
docker run -p 8000:8000 --env-file .env fxutopia-api- Change default SECRET_KEY
- Use environment variables for sensitive data
- Configure CORS for production domains
- Set up SSL/TLS certificates
- Configure rate limiting
- Enable database connection pooling
- Set up monitoring and logging
- Fork the repository
- Create feature branch (
git checkout -b feature/new-feature) - Commit changes (
git commit -am 'Add new feature') - Push to branch (
git push origin feature/new-feature) - Create Pull Request
This project is licensed under the MIT License.
For support and questions:
- Create an issue on GitHub
- Check the API documentation at
/docs - Review the test files for usage examples """