Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
85aa2e3
feat: Create modern Next.js frontend for OpenAI Chat API
Aug 29, 2025
60fa6f3
ui + api ready
Aug 29, 2025
31def06
removed misleading ai generated note on openai key never being shared…
aztecadmin Aug 29, 2025
ed4e3e5
first push
aztecadmin Sep 17, 2025
409c882
feat: implement PDF-based RAG system
aztecadmin Sep 17, 2025
1771f9b
docs: add merge instructions for PDF RAG feature
aztecadmin Sep 17, 2025
f8687e2
feat: Add study interface with local storage and history
aztecadmin Sep 23, 2025
838c4ae
ip
aztecadmin Sep 23, 2025
52b2f58
ip
aztecadmin Sep 23, 2025
3764f1e
ip
aztecadmin Sep 23, 2025
20bc48a
feat(api): extract topics per PDF chunk, store in-memory, and return …
Sep 26, 2025
7d5eec5
docs: add merge instructions for feature/pdf-topics-extraction to Mer…
Sep 26, 2025
448f712
feat(api): extract hierarchical topics from PDF chunks and return the…
Sep 26, 2025
7c2424a
chore(deps): add numpy to root pyproject and install in .venv
Sep 26, 2025
61a86e2
chore(deps): add python-dotenv to root pyproject and install in .venv
Sep 26, 2025
2b4aa3f
feat(api): extract topics per PDF chunk and return in upload response…
Sep 26, 2025
7d76b5f
chore(api): add structured logging, request middleware with request I…
Sep 26, 2025
d5b9769
feat(frontend): add TopicSelector UI with search and single-select pi…
Sep 26, 2025
56a2044
feat(frontend): surface PDF upload and TopicSelector in always-visibl…
Sep 26, 2025
a3e22fb
feat(frontend): modern combobox TopicSelector + sticky quick actions …
Sep 26, 2025
d28ca0b
feat(frontend): two-column layout; right sidebar with TopicSelector +…
Sep 26, 2025
da6f602
feat(chat): conversation history support in API and UI; sidebar histo…
Sep 26, 2025
5bfc05a
feat(api): add LangChain/LangGraph agent to generate topic-based MCQs…
Sep 26, 2025
e6aad3a
chore(api): add faiss-cpu to requirements for LangChain vector store
Sep 26, 2025
6ab868e
feat(api): switch LangChain vector store from FAISS to Qdrant; add la…
Sep 26, 2025
a75c659
feat(frontend): add Generate MCQ flow calling /api/topic-question and…
Sep 26, 2025
3ef4990
fix(api): rename LangGraph node to generate_question to avoid state k…
Sep 26, 2025
205b982
feat(frontend): cache PDF-upload state and filename; persist API key;…
Sep 26, 2025
aeecd78
feat(mcq): interactive MCQ UI with delayed reveal; add evidence from …
Sep 26, 2025
d318972
chore(api): load .env via python-dotenv at startup
Sep 26, 2025
105e0a3
fix(api): allow chat retrieval from Qdrant when in-memory vectors are…
Sep 26, 2025
22468b1
fix(api): lazily attach to existing Qdrant collection in chat when qa…
Sep 26, 2025
5308eb8
fix(api): lazily attach to existing Qdrant collection in /api/topic-q…
Sep 26, 2025
b44580e
feat(api): remove PDF upload requirement; assume Qdrant collection or…
Sep 26, 2025
7e44c36
feat(api): reduce duplicate MCQs via MMR retrieval and slight tempera…
Sep 26, 2025
594095e
chore(api): add retrieval logging and prompt guidance to improve MCQ …
Sep 26, 2025
54ea1bb
refactor(api): remove in-memory vector store; Qdrant is first-class f…
Sep 26, 2025
965fcc0
feat(mcq): add query expansion + multi-query MMR retrieval for varied…
Sep 26, 2025
2c0e29b
obs(rag): log expanded/selected queries, sampled doc metadata/preview…
Sep 26, 2025
9dd0a96
fix(chatopenai): pass penalties and top_p explicitly instead of model…
Sep 26, 2025
ca7e9c0
fix(qdrant): pass search_type="mmr" as parameter; move fetch_k/lambda…
Sep 26, 2025
9f7fba1
feat(frontend): enable vertical scroll overflow on ChatInterface cont…
Sep 26, 2025
7b1eb85
fix(api): remove stray parenthesis causing IndentationError in /api/t…
Sep 26, 2025
1520646
fix(frontend): prevent message overwrite by using robust unique IDs f…
Sep 26, 2025
e3224af
various changes
Sep 27, 2025
7efb4d8
ip
Sep 27, 2025
e9042a8
api: fix Qdrant 403 by using authenticated client and sanitize loggin…
Sep 27, 2025
447127e
api: make Qdrant collection configurable; pin embeddings to text-embe…
Sep 27, 2025
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
Binary file added .DS_Store
Binary file not shown.
12 changes: 8 additions & 4 deletions .cursor/rules/general-rule.mdc
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
description:
globs:
description:
globs:
alwaysApply: true
---

## Rules to Follow

- You must always commit your changes whenever you update code.
- You always prefer to use branch development.
- Before writing any code, you create a feature branch to hold those changes.
- After you are done, provide instructions in a "Merge.md" file that explains how to merge the changes back to main with both a Github PR route and a Github CLI route.
- You must always commit your changes whenever you update code.
- You must always try and write code that is well documented. (self or commented is fine)
- You must only work on a single feature at a time.
- You must explain your decisions thouroughly to the user.
- You must explain your decisions thouroughly to the user.
166 changes: 166 additions & 0 deletions Merge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Merge Instructions

This repo follows a branch-based workflow. Current work for the Qdrant auth fix is on `fix/qdrant-auth-upload`. Previous UI work was done on `fix/chat-question-overwrite`.
Previous rollback context remains available on `rollback/ca7e9c0` (reset to commit `ca7e9c03403e3053ede6a2d14b00531facf95d98`).

## Create PR on GitHub (UI Route)

1. Push your branch (if not already pushed):

```bash
git push -u origin fix/qdrant-auth-upload
```

2. Open a Pull Request from `fix/qdrant-auth-upload` into `main` on GitHub.
3. Add reviewers and wait for approvals and CI to pass.
4. Use “Squash and merge” or your preferred merge strategy.

## GitHub CLI Route

From the repo root:

```bash
git push -u origin fix/qdrant-auth-upload
gh pr create --fill --base main --head fix/qdrant-auth-upload
gh pr view --web # optional, open in browser
gh pr merge --merge # or --squash / --rebase per your preference
```

## Post-merge cleanup

```bash
git checkout main
git pull origin main
git branch -d fix/qdrant-auth-upload
```

## Notes for Reviewers

- Rollback branch `rollback/ca7e9c0` points to commit `ca7e9c0`.
- Effectively reverts subsequent changes after `ca7e9c0` by merging this branch.
- Validate that critical functionality at that commit still builds/tests cleanly.
- Any newer work has been preserved on its original feature branches.

# Deployment Instructions

This project consists of two separate deployments:

1. Frontend (Next.js)
2. API (FastAPI)

## API Deployment

### Prerequisites

1. Install Vercel CLI:

```bash
npm install -g vercel
```

2. Login to Vercel:

```bash
vercel login
```

### Deploy API

1. Navigate to the API directory:

```bash
cd api
```

2. Deploy to Vercel:

```bash
vercel
```

3. After deployment, copy the API URL (you'll need it for the frontend)

### Environment Variables for API

Set these in your Vercel project dashboard:

- `OPENAI_API_KEY`: Your OpenAI API key

## Frontend Deployment

### Prerequisites

Same as API deployment (Vercel CLI and login)

### Deploy Frontend

1. Navigate to the frontend directory:

```bash
cd frontend
```

2. Deploy to Vercel:

```bash
vercel
```

### Environment Variables for Frontend

Set these in your Vercel project dashboard:

- `NEXT_PUBLIC_API_URL`: The URL of your deployed API (e.g., https://your-api.vercel.app)

## Monitoring and Management

### API Project

1. Monitor API logs and performance in Vercel dashboard
2. Check Function execution logs
3. Monitor API rate limits and usage

### Frontend Project

1. Monitor build logs and deployment status
2. Check static asset delivery
3. Monitor page performance

## Troubleshooting

### API Issues

1. Check API logs in Vercel dashboard
2. Verify environment variables are set
3. Test API endpoints directly

### Frontend Issues

1. Check build logs
2. Verify API URL is correctly set
3. Check browser console for errors
4. Verify API is accessible from frontend domain

## Alternative: GitHub PR Route

1. For API changes:

```bash
cd api
gh pr create --title "Deploy API changes" --body "Deploy latest API changes to Vercel"
```

2. For Frontend changes:

```bash
cd frontend
gh pr create --title "Deploy Frontend changes" --body "Deploy latest Frontend changes to Vercel"
```

3. After PRs are merged:

```bash
gh pr merge
```

Vercel will automatically deploy changes when merged to main branch for each project.
103 changes: 58 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
height="auto"/>
</p>


## <h1 align="center" id="heading"> 👋 Welcome to the AI Engineer Challenge</h1>

## 🤖 Your First Vibe Coding LLM Application
Expand All @@ -27,7 +26,6 @@ That's it! Head to the next step and start building your application!

</details>


<details>
<summary>🏗️ Forking & Cloning This Repository</summary>

Expand All @@ -43,81 +41,96 @@ Got everything in place? Let's move on!

1. Fork [this](https://github.com/AI-Maker-Space/The-AI-Engineer-Challenge) repo!

![image](https://i.imgur.com/bhjySNh.png)
![image](https://i.imgur.com/bhjySNh.png)

1. Clone your newly created repo.

``` bash
# First, navigate to where you want the project folder to be created
cd PATH_TO_DESIRED_PARENT_DIRECTORY
```bash
# First, navigate to where you want the project folder to be created
cd PATH_TO_DESIRED_PARENT_DIRECTORY

# Then clone (this will create a new folder called The-AI-Engineer-Challenge)
git clone [email protected]:<YOUR GITHUB USERNAME>/The-AI-Engineer-Challenge.git
```

> Note: This command uses SSH. If you haven't set up SSH with GitHub, the command will fail. In that case, use HTTPS by replacing `[email protected]:` with `https://github.com/` - you'll then be prompted for your GitHub username and personal access token.

# Then clone (this will create a new folder called The-AI-Engineer-Challenge)
git clone [email protected]:<YOUR GITHUB USERNAME>/The-AI-Engineer-Challenge.git
```
1. Verify your git setup:

> Note: This command uses SSH. If you haven't set up SSH with GitHub, the command will fail. In that case, use HTTPS by replacing `[email protected]:` with `https://github.com/` - you'll then be prompted for your GitHub username and personal access token.
```bash
# Check that your remote is set up correctly
git remote -v

2. Verify your git setup:
# Check the status of your repository
git status

```bash
# Check that your remote is set up correctly
git remote -v
# See which branch you're on
git branch
```

# Check the status of your repository
git status
<!-- > Need more help with git? Check out our [Detailed Git Setup Guide](docs/GIT_SETUP.md) for a comprehensive walkthrough of git configuration and best practices. -->

# See which branch you're on
git branch
```
1. Open the freshly cloned repository inside Cursor!

<!-- > Need more help with git? Check out our [Detailed Git Setup Guide](docs/GIT_SETUP.md) for a comprehensive walkthrough of git configuration and best practices. -->
```bash
cd The-AI-Engineering-Challenge
cursor .
```

3. Open the freshly cloned repository inside Cursor!
1. Check out the existing backend code found in `/api/app.py`

```bash
cd The-AI-Engineering-Challenge
cursor .
```
### Root Python Environment with `uv`

4. Check out the existing backend code found in `/api/app.py`
To keep things tidy, we use a single root-level virtual environment and install all Python deps at the repo root using `uv`.

```bash
# At repo root
uv venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv sync # installs deps from pyproject.toml

# Run the FastAPI server from root
uv run python api/app.py
```

</details>

<details>
<summary>🔥Setting Up for Vibe Coding Success </summary>

While it is a bit counter-intuitive to set things up before jumping into vibe-coding - it's important to remember that there exists a gradient betweeen AI-Assisted Development and Vibe-Coding. We're only reaching *slightly* into AI-Assisted Development for this challenge, but it's worth it!
While it is a bit counter-intuitive to set things up before jumping into vibe-coding - it's important to remember that there exists a gradient betweeen AI-Assisted Development and Vibe-Coding. We're only reaching _slightly_ into AI-Assisted Development for this challenge, but it's worth it!

1. Check out the rules in `.cursor/rules/` and add theme-ing information like colour schemes in `frontend-rule.mdc`! You can be as expressive as you'd like in these rules!
2. We're going to index some docs to make our application more likely to succeed. To do this - we're going to start with `CTRL+SHIFT+P` (or `CMD+SHIFT+P` on Mac) and we're going to type "custom doc" into the search bar.
2. We're going to index some docs to make our application more likely to succeed. To do this - we're going to start with `CTRL+SHIFT+P` (or `CMD+SHIFT+P` on Mac) and we're going to type "custom doc" into the search bar.

![image](https://i.imgur.com/ILx3hZu.png)

![image](https://i.imgur.com/ILx3hZu.png)
3. We're then going to copy and paste `https://nextjs.org/docs` into the prompt.

![image](https://i.imgur.com/psBjpQd.png)
![image](https://i.imgur.com/psBjpQd.png)

4. We're then going to use the default configs to add these docs to our available and indexed documents.

![image](https://i.imgur.com/LULLeaF.png)
![image](https://i.imgur.com/LULLeaF.png)

5. After that - you will do the same with Vercel's documentation. After which you should see:

![image](https://i.imgur.com/hjyXhhC.png)
![image](https://i.imgur.com/hjyXhhC.png)

</details>

<details>
<summary>😎 Vibe Coding a Front End for the FastAPI Backend</summary>

1. Use `Command-L` or `CTRL-L` to open the Cursor chat console.
1. Use `Command-L` or `CTRL-L` to open the Cursor chat console.

2. Set the chat settings to the following:

![image](https://i.imgur.com/LSgRSgF.png)
![image](https://i.imgur.com/LSgRSgF.png)

3. Ask Cursor to create a frontend for your application. Iterate as much as you like!

4. Run the frontend using the instructions Cursor provided.
4. Run the frontend using the instructions Cursor provided.

> NOTE: If you run into any errors, copy and paste them back into the Cursor chat window - and ask Cursor to fix them!

Expand All @@ -134,19 +147,19 @@ While it is a bit counter-intuitive to set things up before jumping into vibe-co

3. Run the command:

```bash
npm install -g vercel
```
```bash
npm install -g vercel
```

4. Run the command:

```bash
vercel
```
```bash
vercel
```

5. Follow the in-terminal instructions. (Below is an example of what you will see!)

![image](https://i.imgur.com/D1iKGCq.png)
![image](https://i.imgur.com/D1iKGCq.png)

6. Once the build is completed - head to the provided link and try out your app!

Expand All @@ -156,13 +169,13 @@ While it is a bit counter-intuitive to set things up before jumping into vibe-co

### Vercel Link to Share

You'll want to make sure you share you *domains* hyperlink to ensure people can access your app!
You'll want to make sure you share you _domains_ hyperlink to ensure people can access your app!

![image](https://i.imgur.com/mpXIgIz.png)

> NOTE: Test this is the public link by trying to open your newly deployed site in an Incognito browser tab!

### 🎉 Congratulations!
### 🎉 Congratulations!

You just deployed your first LLM-powered application! 🚀🚀🚀 Get on linkedin and post your results and experience! Make sure to tag us at @AIMakerspace!

Expand All @@ -182,5 +195,5 @@ Looking forward to building with the community! 🙌✨ Here's to many more cre

Who else is diving into the world of AI? Let's connect! 🌐💡

#FirstLLMApp
#FirstLLMApp
```
Empty file added aimakerspace/__init__.py
Empty file.
1 change: 1 addition & 0 deletions aimakerspace/aimakerspace
Empty file.
Loading