This project has been migrated from Node.js to FastAPI (Python). Here's what you need to do to complete the setup.
- 
FastAPI Application Structure - main.py- Main FastAPI application
- routes/userRoutes.py- API routes
- controllers/userController.py- Business logic
- middleware/authentication.py- JWT authentication
- middleware/error.py- Error handling
- models/userModel.py- User model
- utils/- Utility functions (JWT, email, S3)
 
- 
Updated Dependencies - requirements.txt- Python dependencies
- crew.py- Updated for FastAPI integration
 
- 
Setup Scripts - setup_python_env.py- Environment setup
- run_server.py- Server runner
 
# Activate virtual environment
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtCreate a .env file in the root directory:
# Example environment variables for DataIntel-Hub-Backend
# OpenAI API Key
OPENAI_API_KEY=your-openai-api-key-here
# MongoDB connection URI
MONGO_URI=your-mongodb-uri-here
# Backend server port
PORT=8090
# SMTP (Email) configuration
SMPT_SERVICE=gmail
SMPT_MAIL=your-email@gmail.com
SMPT_PASSWORD=your-app-password-here
SMPT_HOST=smtp.gmail.com
SMPT_PORT=465
# JWT (Authentication) configuration
JWT_SECRET=your-jwt-secret-here
JWT_EXPIRE=5d
COOKIE_EXPIRE=2
# Frontend URL
FRONTEND_URL=http://localhost:5173 # Option 1: Using the run script
python run_server.py
# Option 2: Using uvicorn directly
uvicorn main:app --reload --host 0.0.0.0 --port 8000
# Option 3: Using the main file
python main.pyOnce the server is running, you can access:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- Health Check: http://localhost:8000/health
DataIntel-Hub-Backend/
βββ main.py                    # FastAPI application
βββ crew.py                    # CrewAI integration
βββ requirements.txt           # Python dependencies
βββ run_server.py             # Server runner
βββ setup_python_env.py       # Setup script
βββ .env                      # Environment variables
βββ routes/
β   βββ userRoutes.py         # API routes
βββ controllers/
β   βββ userController.py     # Business logic
βββ middleware/
β   βββ authentication.py     # JWT auth
β   βββ error.py             # Error handling
βββ models/
β   βββ userModel.py         # User model
βββ utils/
β   βββ jwtToken.py          # JWT utilities
β   βββ sendEmail.py         # Email utilities
β   βββ s3upload.py          # File upload utilities
βββ config/
    βββ agents.yaml           # CrewAI agents config
    βββ tasks.yaml            # CrewAI tasks config
- JWT-based authentication
- Email verification
- Password reset functionality
- Role-based access control
- CSV file upload and processing
- Integration with CrewAI for data analysis
- Local file storage with S3 backup option
- Google Sheets integration
- PostgreSQL database connection
- Multi-source data analysis
- Report generation and management
- POST /api/users/register- Register new user
- POST /api/users/login- User login
- GET /api/users/me- Get user details
- PUT /api/users/me/update- Update user profile
- PUT /api/users/password/update- Update password
- GET /api/users/verify/{token}- Verify email
- POST /api/users/email/resend- Resend verification
- POST /api/users/password/forgot- Forgot password
- PUT /api/users/password/reset/{token}- Reset password
- POST /api/users/upload-csv- Upload CSV for analysis
- POST /api/users/upload-google-sheet- Connect Google Sheets
- POST /api/users/postgres/analyze- Analyze PostgreSQL data
- GET /api/users/reports- Get user reports
- GET /api/users/reports/analytics- Get report analytics
- GET /api/users/reports/{report_id}- Get specific report
- DELETE /api/users/reports/{report_id}- Delete report
- PUT /api/users/reports/{report_id}- Update report
- GET /api/users/reports/{report_id}/download- Download report
- GET /api/users/admin/users- Get all users (admin only)
- Import Errors: Make sure you've activated the virtual environment and installed dependencies
- Environment Variables: Ensure all required environment variables are set in .env
- Port Conflicts: Change the port in .envif 8000 is already in use
- Database Connection: Set up MongoDB or update the database configuration
Run with debug logging:
uvicorn main:app --reload --log-level debug- Database Integration: Implement proper database models using SQLAlchemy or MongoDB
- Testing: Add unit tests and integration tests
- Production: Configure for production deployment
- Monitoring: Add logging and monitoring
- Security: Implement additional security measures
If you encounter any issues during setup, check:
- Python version (3.8+ required)
- Virtual environment activation
- Dependencies installation
- Environment variables configuration
- Project: DataIntel Hub
- Event: RemoteBase HackFest
- Team: Random
- Repository: https://github.com/usama7365/DataIntel-Hub-Backend
- Live Demo: https://dataintel-hub-frontend.onrender.com
- Documentation Version: 1.1
- Last Updated: July 2025