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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

.env
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.1.0
16 changes: 16 additions & 0 deletions AI/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from flask import Flask, request, jsonify

app = Flask(__name)

# Add chatbot routes

@app.route('/match', methods=['POST'])
def match_users():
user_data = request.json
# Implement your AI matching logic here
matched_mentor = {} # Replace this with actual matching results
return jsonify(matched_mentor)


if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gem "puma", "~> 5.0"
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
Expand All @@ -34,7 +34,7 @@ gem "bootsnap", require: false
# gem "image_processing", "~> 1.2"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem "rack-cors"
gem "rack-cors"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
Expand All @@ -48,3 +48,7 @@ end


gem "active_model_serializers", "~> 0.10.14"

gem 'dotenv-rails'

gem 'faker'
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
bcrypt (3.1.19)
bootsnap (1.16.0)
msgpack (~> 1.2)
builder (3.2.4)
Expand All @@ -82,7 +83,13 @@ GEM
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
erubi (1.12.0)
faker (3.2.1)
i18n (>= 1.8.11, < 2)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
Expand Down Expand Up @@ -115,6 +122,8 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
pg (1.5.4)
Expand All @@ -124,6 +133,8 @@ GEM
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.8)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
Expand Down Expand Up @@ -170,14 +181,19 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-23
x86_64-linux

DEPENDENCIES
active_model_serializers (~> 0.10.14)
bcrypt (~> 3.1.7)
bootsnap
debug
dotenv-rails
faker
pg (~> 1.1)
puma (~> 5.0)
rack-cors
rails (~> 7.0.8)
tzinfo-data

Expand Down
60 changes: 60 additions & 0 deletions app/controllers/ai_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class AiController < ApplicationController
skip_before_action :authorized_user

def chat_prompt_data

render json: current_user, serializer: UserSerializer, status: :ok
end

def match_prompt_data

# current user (id, match criteria only)
# all mentor records (id, match criteria only)

# mentors = Mentor.select(:id).includes(:skills, :interests, :genders, :races)

@mentors = Mentor.all

mentors = []

@mentors.each do |mentor|
user = mentor.user
mentor_obj = {
skills: user.skills,
interests: user.interests,
genders: user.genders,
races: user.races
}

mentors << mentor_obj
end

match_data = {
mentee_id: current_user.id,
skills: current_user.skills,
interests: current_user.interests,
mentors: mentors
}

render json: match_data, status: :ok
end

def get_cards
# render array of cards (max 5)
end

private

def gender_prompt(user)
gender = user.genders[0]
prompt = "I would prefer to be matched with a mentor that has experience as a #{gender} person."
prompt
end

def race_prompt(user)
race = user.races[0]
prompt = "I would prefer to be matched with a mentor that has experience as a #{race} person."
prompt
end

end
75 changes: 53 additions & 22 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@


class ApplicationController < ActionController::API
# rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
# rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
# rescue_from ActiveRecord::ConnectionNotEstablished, with: :render_connection_not_established_response
# include ActionController::Cookies
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found_response
rescue_from ActiveRecord::RecordInvalid, with: :render_unprocessable_entity_response
rescue_from ActiveRecord::ConnectionNotEstablished, with: :render_connection_not_established_response
include ActionController::Cookies

before_action :authorized_user

# PassageClient = Passage::Client.new(
# app_id: Rails.application.config.passage_app_id
# api_key: Rails.application.config.passage_api_key
# )

def current_user
user = User.find_by(id: session[:user_id])

if !user && session[:psg_user_id]
passage_user = PassageClient.user.get(user_id: @user_id)
@email = passage_user[:email]
user = User.find_by(email: @email)

User.create!(email: @email) unless user
user
end

user
end

def authorized_user
render json: { error: "Not Authorized" }, status: :unauthorized unless current_user
end

# before_action :authorized_user
def authorize!
begin
request.to_hash()
@user_id = Passage.auth.authenticate_request(request)
session[:psg_user_id] = @user_id

# def current_user
# user = User.find_by(id: session[:user_id])
# user
# end
render json: current_user, status: :ok
rescue Exception => e
# unauthorized
redirect_to "/unauthorized"
end
end

# def authorized_user
# render json: { error: "Not Authorized" }, status: :unauthorized unless current_user
# end

# private
private

# def render_not_found_response(error)
# render json: { error: "#{error.model} not found."}, status: :not_found
# end
def render_not_found_response(error)
render json: { error: "#{error.model} not found."}, status: :not_found
end

# def render_unprocessable_entity_response(error)
# render json: { error: invalid.record.errors.full_messages }, status: :unprocessable_entity
# end
def render_unprocessable_entity_response(error)
render json: { error: invalid.record.errors.full_messages }, status: :unprocessable_entity
end



# def render_connection_not_established_response(error)
# render json: { error: error}, status: :service_unavailable
# end
def render_connection_not_established_response(error)
render json: { error: error}, status: :service_unavailable
end
end
7 changes: 7 additions & 0 deletions app/controllers/career_fields_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CareerFieldsController < ApplicationController
skip_before_action :authorized_user

def index
render json: CareerField.all, status: :ok
end
end
8 changes: 8 additions & 0 deletions app/controllers/career_titles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CareerTitlesController < ApplicationController
skip_before_action :authorized_user

def index
render json: CareerTitle.all, status: :ok
end

end
7 changes: 7 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CategoriesController < ApplicationController
skip_before_action :authorized_user

def index
render json: Category.all, status: :ok
end
end
7 changes: 7 additions & 0 deletions app/controllers/category_interests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CategoryInterestsController < ApplicationController
skip_before_action :authorized_user

def index
render json: CategoryInterest.all, status: :ok
end
end
7 changes: 7 additions & 0 deletions app/controllers/category_skills_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CategorySkillsController < ApplicationController
skip_before_action :authorized_user

def index
render json: CategorySkill.all, status: :ok
end
end
7 changes: 7 additions & 0 deletions app/controllers/genders_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class GendersController < ApplicationController
skip_before_action :authorized_user

def index
render json: Gender.all, status: :ok
end
end
8 changes: 8 additions & 0 deletions app/controllers/interests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class InterestsController < ApplicationController
skip_before_action :authorized_user

def index
render json: Interest.all, status: :ok
end

end
7 changes: 7 additions & 0 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MatchesController < ApplicationController
skip_before_action :authorized_user

def index
render json: Match.all, status: :ok
end
end
7 changes: 7 additions & 0 deletions app/controllers/mentees_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MenteesController < ApplicationController
skip_before_action :authorized_user

def index
render json: Mentee.all, status: :ok
end
end
8 changes: 8 additions & 0 deletions app/controllers/mentors_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class MentorsController < ApplicationController
skip_before_action :authorized_user

def index
render json: Mentor.all, status: :ok
end

end
7 changes: 7 additions & 0 deletions app/controllers/races_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class RacesController < ApplicationController
skip_before_action :authorized_user

def index
render json: Race.all, status: :ok
end
end
Loading