A FastAPI backend service that uses Google's Vertex AI (Gemini-1.0-pro model) to analyze skills and expertise, generating personalized career paths, roadmaps, and course recommendations.
- POST /analyze endpoint that accepts skills and expertise
- Generates top 3 career paths based on input
- Creates a detailed roadmap for the best matching career path
- Recommends 3-5 relevant courses
- CORS middleware configured for React frontend (localhost:3000)
- Comprehensive error handling and fallback responses
- JSON-only responses (no plain text)
- Python 3.10+
- Google Cloud Project with Vertex AI enabled
- Required environment variables
- Clone the repository:
git clone <repository-url>
cd gemini2- Install dependencies:
pip install -r requirements.txt- Set up Google Cloud credentials:
# Set your Google Cloud project ID
export GOOGLE_CLOUD_PROJECT="your-project-id"
# Authenticate with Google Cloud
gcloud auth application-default loginCreate a .env file or set the following environment variable:
GOOGLE_CLOUD_PROJECT=your-google-cloud-project-id
- Start the development server:
python main.pyOr using uvicorn directly:
uvicorn main:app --reload --host 0.0.0.0 --port 8000-
The API will be available at
http://localhost:8000 -
View the interactive API documentation at
http://localhost:8000/docs
Analyzes skills and expertise to generate career recommendations.
Request Body:
{
"skills": "Python, JavaScript, React, Node.js",
"expertise": "Full-stack web development with 2 years experience"
}Response:
{
"career_paths": [
{
"title": "Senior Full-Stack Developer",
"description": "Lead development of complex web applications",
"required_skills": ["Python", "JavaScript", "React", "Node.js"],
"salary_range": "$80,000 - $150,000",
"growth_prospect": "High - Strong demand for full-stack developers"
}
],
"selected_path": {
"title": "Senior Full-Stack Developer",
"description": "Lead development of complex web applications using modern technologies",
"required_skills": ["Python", "JavaScript", "React", "Node.js", "System Design"],
"salary_range": "$80,000 - $150,000",
"growth_prospect": "High - Strong demand for full-stack developers"
},
"roadmap": [
{
"step": 1,
"title": "Master Advanced Concepts",
"description": "Deepen understanding of advanced programming concepts",
"duration": "3-6 months",
"resources": ["Advanced tutorials", "Code reviews", "Open source contributions"]
}
],
"courses": [
{
"title": "Advanced React Patterns",
"provider": "Frontend Masters",
"duration": "8 weeks",
"difficulty": "Advanced",
"url": "https://frontendmasters.com/courses/advanced-react-patterns/"
}
]
}Health check endpoint.
Response:
{
"message": "Career Path Analyzer API is running"
}Detailed health check endpoint.
Response:
{
"status": "healthy",
"service": "career-analyzer"
}gemini2/
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── models/ # Pydantic models
│ ├── __init__.py
│ └── schemas.py # Request/Response schemas
├── services/ # Business logic services
│ ├── __init__.py
│ └── ai_service.py # Vertex AI integration
├── routes/ # API route handlers
│ ├── __init__.py
│ ├── analyze.py # Career analysis endpoints
│ └── health.py # Health check endpoints
├── config/ # Configuration settings
│ ├── __init__.py
│ └── settings.py # Application settings
├── frontend/ # React frontend application
│ ├── package.json # Frontend dependencies
│ ├── tailwind.config.js # Tailwind CSS configuration
│ ├── postcss.config.js # PostCSS configuration
│ ├── public/ # Static assets
│ │ └── index.html # HTML template
│ └── src/ # React source code
│ ├── App.js # Main App component
│ ├── App.css # Custom styles
│ ├── index.js # React entry point
│ ├── index.css # Global styles
│ ├── components/ # Reusable components
│ │ └── Navbar.js # Navigation component
│ ├── pages/ # Page components
│ │ ├── Landing.js # Landing page
│ │ ├── Dashboard.js # Dashboard page
│ │ ├── CareerPath.js # Career paths page
│ │ ├── Roadmap.js # Roadmap page
│ │ ├── Courses.js # Courses page
│ │ └── Settings.js # Settings page
│ ├── context/ # React Context
│ │ └── AppContext.js # Global state management
│ └── services/ # API services
│ └── api.js # Backend API integration
└── README.md # This file
- fastapi: Web framework for building APIs
- uvicorn: ASGI server for running FastAPI
- google-cloud-aiplatform: Google Cloud AI Platform client
- pydantic: Data validation using Python type annotations
- python-multipart: Support for multipart form data
- react: JavaScript library for building user interfaces
- react-router-dom: Declarative routing for React
- axios: Promise-based HTTP client
- tailwindcss: Utility-first CSS framework
- autoprefixer: PostCSS plugin to parse CSS and add vendor prefixes
- postcss: Tool for transforming CSS with JavaScript
The API includes comprehensive error handling:
- 500 Internal Server Error: When Vertex AI generation fails, a fallback response is provided
- 422 Validation Error: When request data doesn't match the expected schema
- Fallback Response: If AI generation fails, the API returns a generic but useful response
The API is configured to accept requests from:
http://localhost:3000(React development server)
To modify CORS settings, update the allow_origins list in main.py.
To run the backend in development mode with auto-reload:
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export GOOGLE_CLOUD_PROJECT="your-project-id"
# Run the server
uvicorn main:app --reload --host 0.0.0.0 --port 8000To run the frontend in development mode:
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm startThe frontend will be available at http://localhost:3000 and will automatically connect to the backend API.
The React frontend includes:
- Landing: Input form for skills and expertise analysis
- Dashboard: Overview of career analysis results
- Career Path: Detailed view of all recommended career paths
- Roadmap: Step-by-step career development guide
- Courses: Curated learning resources and courses
- Settings: User profile and application preferences
- Responsive Design: Mobile-first approach with Tailwind CSS
- Global State Management: React Context for data sharing across components
- API Integration: Axios-based service for backend communication
- Error Handling: Comprehensive error states and user feedback
- Loading States: Visual feedback during API calls
- Navigation: React Router for seamless page transitions
The project follows a clean, modular architecture:
models/: Contains all Pydantic models for request/response validationservices/: Contains business logic and external service integrationsroutes/: Contains API route handlers organized by functionalityconfig/: Contains application settings and configurationmain.py: Application entry point that ties everything together
components/: Reusable UI componentspages/: Page-level components for different routescontext/: React Context for global state managementservices/: API service layer for backend communication
This structure makes the codebase:
- Maintainable: Easy to find and modify specific functionality
- Testable: Each module can be tested independently
- Scalable: Easy to add new features without affecting existing code
- Readable: Clear separation of concerns
For production deployment, consider:
- Using a production ASGI server like Gunicorn with Uvicorn workers
- Setting up proper logging
- Configuring environment variables securely
- Setting up monitoring and health checks
- Using a reverse proxy like Nginx
- Google Cloud Authentication: Ensure you're authenticated with
gcloud auth application-default login - Project ID: Make sure
GOOGLE_CLOUD_PROJECTis set correctly - Vertex AI Access: Ensure Vertex AI is enabled in your Google Cloud project
- CORS Issues: Check that your frontend URL matches the allowed origins
The application logs errors to the console. Check the terminal output for detailed error messages.
This project is open source and available under the MIT License.