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
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ Uses **Nodemailer** with SMTP transport. Two styled HTML email templates:

| Variable | Required | Description |
|---|---|---|
| `PORT` | ✅ | Server port (e.g., `5000`) |
| `PORT` | ✅ | Server port (e.g., `8000`) |
| `MONGO_URI` | ✅ | MongoDB connection string |
| `JWT_SECRET` | ✅ | Secret key for JWT signing |
| `JWT_EXPIRES_IN` | ✅ | JWT expiry duration (e.g., `7d`) |
Expand All @@ -734,7 +734,7 @@ MONGO_URI=

| Variable | Description |
|---|---|
| `VITE_API_BASE_URL` | Backend API base URL (e.g., `http://localhost:5000/api`) |
| `VITE_API_BASE_URL` | Backend API base URL (e.g., `http://localhost:8000/api`) |

---

Expand Down Expand Up @@ -767,11 +767,11 @@ cp .env.example .env
node server.js
```

The API will be available at `http://localhost:5000`.
The API will be available at `http://localhost:8000`.

**Health check:**
```bash
curl http://localhost:5000/api/health
curl http://localhost:8000/api/health
# → { "status": "ok", "message": "CodeLens API is running" }
```

Expand All @@ -787,7 +787,7 @@ cd CodeLens/frontend
npm install

# 3. Create environment file
echo "VITE_API_BASE_URL=http://localhost:5000/api" > .env
echo "VITE_API_BASE_URL=http://localhost:8000/api" > .env

# 4. Start the development server
npm run dev
Expand Down Expand Up @@ -863,3 +863,53 @@ This project uses the [MIT License](./LICENSE).
<strong>CodeLens — Stop the Guesswork. Dictate the Path.</strong><br>
Built with ❤️ for the developer community as part of GSSoC 2026.
</div>

---

### MongoDB Atlas Setup

1. Go to [cloud.mongodb.com](https://cloud.mongodb.com) and create a free account
2. Create a new **Cluster** (free M0 tier works fine)
3. Under **Database Access**, create a user with read/write permissions
4. Under **Network Access**, add your IP (or `0.0.0.0/0` for development)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid recommending 0.0.0.0/0 as a default Atlas network rule.

This guidance weakens security posture and is easy to copy into non-dev environments. Prefer recommending least-privilege IP allowlists, with 0.0.0.0/0 only as a short-lived fallback plus explicit warning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 874, Replace the README guidance that suggests adding
"0.0.0.0/0" under Network Access with a least-privilege recommendation: instruct
users to add only necessary IP ranges or specific CIDRs for their environment
and to avoid using 0.0.0.0/0 except as a temporary, short-lived fallback; if you
keep mention of 0.0.0.0/0 include an explicit, prominent warning about the
security risk and require steps to remove it before production.

5. Click **Connect** → **Connect your application** and copy the connection string
6. Replace `<username>`, `<password>` in the connection string
7. Set `MONGO_URI` in `server/.env` to the connection string

**Example:**
```env
MONGO_URI=mongodb+srv://youruser:yourpassword@cluster0.xxxxx.mongodb.net/codelens?retryWrites=true&w=majority
```

---

### SMTP Setup

**Using Gmail:**
1. Enable 2-Factor Authentication on your Google account
2. Go to Google Account → Security → **App Passwords**
3. Generate an app password for "Mail"
4. Use in `server/.env`:

```env
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your.email@gmail.com
SMTP_PASS=your-16-char-app-password
```

**Using Mailtrap (for testing):**
1. Sign up at [mailtrap.io](https://mailtrap.io)
2. Go to Email Testing → your inbox → SMTP Settings
3. Copy the credentials into `server/.env`

---

### Troubleshooting

| Issue | Cause | Fix |
|---|---|---|
| `ECONNREFUSED` on API calls | Port mismatch | Ensure `VITE_API_BASE_URL` in `frontend/.env` matches `PORT` in `server/.env` (default: `8000`) |
| MongoDB connection fails | Wrong URI or IP not whitelisted | Check `MONGO_URI` format and whitelist your IP in Atlas Network Access |
| Emails not sending | Wrong SMTP credentials | Use Gmail App Password, not your account password |
| JWT errors | Missing secret | Set a long random string as `JWT_SECRET` in `server/.env` |
5 changes: 5 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Frontend Environment Variables
# Copy this file to .env and fill in your values

# Backend API URL — must match the PORT set in server/.env
VITE_API_BASE_URL=http://localhost:8000/api
2 changes: 1 addition & 1 deletion frontend/src/components/shared/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export default function Navbar() {

{/* ── Mobile Menu ── */}
{isMenuOpen && (
<div className="lg:hidden w-full bg-white border-t-4 border-black">
<div className="lg:hidden w-full bg-white border-t-4 border-black max-h-[calc(100vh-4rem)] overflow-y-auto">
<div className="flex flex-col">
{/* Nav links */}
{isAuthenticated && (
Expand Down
Loading