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 applicationroutes/userRoutes.py
- API routescontrollers/userController.py
- Business logicmiddleware/authentication.py
- JWT authenticationmiddleware/error.py
- Error handlingmodels/userModel.py
- User modelutils/
- Utility functions (JWT, email, S3)
-
Updated Dependencies
requirements.txt
- Python dependenciescrew.py
- Updated for FastAPI integration
-
Setup Scripts
setup_python_env.py
- Environment setuprun_server.py
- Server runner
# Activate virtual environment
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create 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=[email protected]
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.py
Once 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 userPOST /api/users/login
- User loginGET /api/users/me
- Get user detailsPUT /api/users/me/update
- Update user profilePUT /api/users/password/update
- Update password
GET /api/users/verify/{token}
- Verify emailPOST /api/users/email/resend
- Resend verification
POST /api/users/password/forgot
- Forgot passwordPUT /api/users/password/reset/{token}
- Reset password
POST /api/users/upload-csv
- Upload CSV for analysisPOST /api/users/upload-google-sheet
- Connect Google SheetsPOST /api/users/postgres/analyze
- Analyze PostgreSQL data
GET /api/users/reports
- Get user reportsGET /api/users/reports/analytics
- Get report analyticsGET /api/users/reports/{report_id}
- Get specific reportDELETE /api/users/reports/{report_id}
- Delete reportPUT /api/users/reports/{report_id}
- Update reportGET /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
.env
if 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