Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions PadBot_api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env

venv/

mod5-2.pdf
189 changes: 189 additions & 0 deletions PadBot_api/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
from flask import Flask, request, jsonify
from flask_cors import CORS
import fitz # PyMuPDF
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import Chroma
from langchain_together import TogetherEmbeddings, Together
from langchain.chains import create_retrieval_chain
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import PromptTemplate
import google.generativeai as genai
import requests
import os
from dotenv import load_dotenv

load_dotenv()

app = Flask(__name__)
CORS(app, origins=["*"])



# Load API Keys
TOGETHER_API_KEY = os.getenv("TOGETHER_API_KEY")
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")

# Gemini setup
genai.configure(api_key=GEMINI_API_KEY)
gemini_model = genai.GenerativeModel("gemini-2.5-flash")

if not TOGETHER_API_KEY:
raise Exception("TOGETHER_AI_API_KEY not found in environment variables.")
if not GEMINI_API_KEY:
raise Exception("GEMINI_API_KEY not found in environment variables.")

VECTOR_STORE = None
RETRIEVAL_CHAIN = None

# -----------------------------------------
# PDF Parsing and LangChain QA Chain Setup
# -----------------------------------------
def extract_pdf_text(file_bytes):
with fitz.open(stream=file_bytes, filetype="pdf") as doc:
return "".join(page.get_text() for page in doc)

def process_and_store(pdf_text):
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
chunks = splitter.split_text(pdf_text)

embeddings = TogetherEmbeddings(
model="togethercomputer/m2-bert-80M-32k-retrieval",
together_api_key=TOGETHER_API_KEY
)
vector_store = Chroma.from_texts(chunks, embeddings)

llm = Together(
model="meta-llama/Llama-3-8b-chat-hf",
temperature=0,
max_tokens=1024,
together_api_key=TOGETHER_API_KEY
)

retriever = vector_store.as_retriever(search_kwargs={"k": 5})
prompt_template = """
Answer the question based only on the following context in brief.
If you don't know the answer, just say that you don't know.

CONTEXT:
{context}

QUESTION:
{input}

ANSWER:
"""
prompt = PromptTemplate.from_template(prompt_template)
qa_chain = create_stuff_documents_chain(llm, prompt)
retrieval_chain = create_retrieval_chain(retriever, qa_chain)

return vector_store, retrieval_chain

# -------------------------------
# Gemini Skill Analysis Functions
# -------------------------------
def fetch_github_summary(github_url):
try:
username = github_url.rstrip("/").split("/")[-1]
api_url = f"https://api.github.com/users/{username}/repos"
repos = requests.get(api_url).json()

summary = f"GitHub user: {username}\n"
for repo in repos[:5]:
summary += f"- {repo['name']}: {repo.get('description', 'No description')}\n"
return summary
except Exception as e:
return f"Error fetching GitHub info: {str(e)}"

def analyze_with_gemini(resume_text, github_summary, desired_role):
prompt = f"""
You are a career coach. A user wants to become a {desired_role}.
Based on the resume and GitHub data, analyze:

1. Skills they already have
2. Skills they lack
3. A short learning roadmap

Resume:
{resume_text}

GitHub:
{github_summary}
"""
response = gemini_model.generate_content(prompt)
return response.text

# -------------------------------
# Routes
# -------------------------------
@app.route("/upload", methods=["POST"])
def upload_pdf():
global VECTOR_STORE, RETRIEVAL_CHAIN

if 'file' not in request.files:
return jsonify({"error": "No file provided"}), 400

file = request.files['file']
if not file or file.filename == '':
return jsonify({"error": "Invalid file"}), 400

try:
pdf_text = extract_pdf_text(file.read())
VECTOR_STORE, RETRIEVAL_CHAIN = process_and_store(pdf_text)
return jsonify({"message": "File processed and stored"}), 200
except Exception as e:
return jsonify({"error": str(e)}), 500

@app.route("/ask", methods=["POST"])
def ask_question():
global RETRIEVAL_CHAIN
if RETRIEVAL_CHAIN is None:
return jsonify({"error": "Please upload a PDF first"}), 400

data = request.get_json()
question = data.get("question", "").strip()
if not question:
return jsonify({"error": "No question provided"}), 400

try:
response = RETRIEVAL_CHAIN.invoke({"input": question})
return jsonify({"answer": response["answer"]}), 200
except Exception as e:
return jsonify({"error": str(e)}), 500

@app.route('/submit_preferences', methods=['POST'])
def submit_preferences():
try:
role = request.form.get("role", "").strip()
company = request.form.get("company", "").strip()
github_link = request.form.get("githubLink", "").strip()
resume_file = request.files.get("resumeFile")

# ✅ Field validation
if not (role and company and github_link and resume_file):
print("❌ Missing fields:", role, company, github_link, resume_file)
return jsonify({"error": "Missing required fields"}), 400

# ✅ Debug info
print(f"\n📥 Received Submission:")
print(f" - 📄 Resume: {resume_file.filename} ({resume_file.content_type})")
print(f" - 🎯 Role: {role}")
print(f" - 🏢 Company: {company}")
print(f" - 🐙 GitHub: {github_link}\n")

# ✅ Process data
pdf_text = extract_pdf_text(resume_file.read())
github_summary = fetch_github_summary(github_link)
gemini_analysis = analyze_with_gemini(pdf_text, github_summary, role)

print(f"✅ Gemini Analysis:\n{gemini_analysis}\n")

return jsonify({
"message": "Analysis complete!",
"analysis": gemini_analysis
}), 200

except Exception as e:
return jsonify({"error": f"Internal server error: {str(e)}"}), 500

if __name__ == "__main__":
app.run(debug=True)
7 changes: 7 additions & 0 deletions PadBot_api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Flask
PyMuPDF
langchain
langchain-community
langchain-together
chromadb
python-dotenv
136 changes: 102 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,137 @@
# CODERECET

## Project Repository
*Commit and save your changes here*
https://github.com/devananda6200/CODERECET-ByteWizards

### Team Name :
ByteWizards

### Team Members :
- Deva Nanda Nair
- Swathi H Nair
- Shreya R S

### Project Description
.
.
.
**Project Padhik (പഥികൻ)** is a dual-purpose AI-powered student ecosystem designed specifically for the educational and employment challenges faced by students in Kerala. It consists of two integrated pillars:

1. **Academic Accelerator (EXAM AI Wing)** – helps students boost CGPA and ace university exams using AI-driven PYQ solving, smart note analysis, and curated YouTube learning playlists.
2. **Career Navigator (Original Padhik)** – analyzes resumes and GitHub profiles to identify skill gaps and suggests personalized learning paths and hyper-local job opportunities.

It empowers students from their **first semester to their first job**—making Padhik the ultimate Kerala student companion.

---

## Technical Details

### Technologies/Components Used

## For Software:

[Languages used]
[Frameworks used]
[Libraries used]
[Tools used]

## For Hardware:

[List main components]
[List specifications]
[List tools required]
**Languages used:**
- Python
- JavaScript
- HTML/CSS

**Frameworks used:**
- Flask (Backend)
- Svelte + Astro + Tailwind CSS (Frontend)

**Libraries used:**
- LangChain
- Together.ai
- Google Generative AI (Gemini)
- PyMuPDF (fitz)
- Chroma (Vector Store)
- SymPy (Math solver)
- dotenv
- Flask-CORS
- Requests

**Tools used:**
- GitHub
- VS Code
- Postman
- Gamma for Deck
- Figma (UI mockups)
- YouTube Data API
- LinkedIn API (planned)

---

[List specifications]
- Runs on any machine with Python 3.10+
- Tested on Google Colab, local Ubuntu 22.04, and Windows 10

[List tools required]
- Python + pip
- .env file for API keys

---

## Implementation

## For Software:

### Installation
[commands]
```bash
git clone https://github.com/devananda6200/CODERECET-ByteWizards
cd CODERECET-ByteWizards
python -m venv env
source env/bin/activate # for Linux/macOS
# or
env\Scripts\activate # for Windows

pip install -r requirements.txt
# Add your .env file with GEMINI_API_KEY and TOGETHER_API_KEY
python app.py
# Then open the frontend (Svelte project)
cd frontend
npm install
npm run dev
```

### Run
[commands]
### Screenshots (Add at least 3)

### Project Documentation
![Dashboard](dashboard.png)
*Main dashboard allowing users to choose between "Boost My Grades" (XMAI) or "Build My Career" (Navigator).*

### Screenshots (Add at least 3)
![PYQ Solver](pyq_solver.png)
![PYQ Solver1](pyq2.png)
![PYQ Solver](padbot.png)
*User uploads a PDF of previous year questions and receives step-by-step AI-generated solutions.*

![Career Analysis Result](career.png)
*Caption: Gemini AI analyzing resume + GitHub and generating skill gap and career roadmap.*

---

### Diagrams
Workflow(Add your workflow/architecture diagram here) Add caption explaining your workflow

## For Hardware:
#### Workflow (Architecture Diagram)

![Workflow Architecture](https://via.placeholder.com/800x450.png?text=Workflow+Diagram+Coming+Soon)

### Schematic & Circuit
Circuit(Add your circuit diagram here) Add caption explaining connections
Schematic(Add your schematic diagram here) Add caption explaining the schematic

### Build Photos
Components(Add photo of your components here) List out all components shown
Build(Add photos of build process here) Explain the build steps
Final(Add photo of final product here) Explain the final build

### Project Demo

### Video
[Add your demo video link here] Explain what the video demonstrates

## Additional Demos
[Add any extra demo materials/links]
[https://youtu.be/sample-demo-link](https://youtube.com/shorts/78PsVvvoW5Y?feature=share)


## Team Contributions
[Name 1]: [Specific contributions]
[Name 2]: [Specific contributions]
[Name 3]: [Specific contributions]

**Deva Nanda Nair:**
- Core backend logic and integration with Together AI
- Flask endpoints and Gemini integration

**Shreya R S:**
- Career Navigator logic
- EXAM AI Wing Setup

**Swathi H Nair:**
- Frontend design and implementation (Svelte, Astro, Tailwind)



Binary file added career.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading