About
## Challenges we ran into
### ๐งฉ The Challenge: AI Non-Determinism & Frontend Crashes
One of the most complex hurdles we faced was reliably rendering the AI-generated architecture diagrams without crashing the frontend.
We integrated **Gemini 2.5 Flash** to analyze repositories and output `Mermaid.js` flowchart syntax. However, Large Language Models are inherently non-deterministic. Even with strict prompt engineering, the AI would occasionally return slightly invalid syntax, such as: * Injecting unexpected Markdown code fences (e.g., ` ```mermaid `). * Using parentheses inside node definitions.
When our Flutter frontend attempted to parse these edge cases inside the iframe, the Mermaid renderer would throw a fatal syntax error, causing the UI component to crash completely.
### ๐ ๏ธ The Solution: A Robust Middleware Sanitizer
We quickly realized that prompt engineering alone wasn't enough to guarantee stability. To solve this, we built a **regex-based middleware sanitizer** directly into our Node.js backend.
Before saving any AI output to MongoDB, this custom data pipeline intercepts the response and performs aggressive cleaning: 1. **Strips rogue markdown fences** to ensure raw text execution. 2. **Enforces correct graph directives** (e.g., defaulting to `graph TD`). 3. **Automatically converts invalid characters** (like nested parentheses) into safe, quoted string labels using Regex.
**The Impact:** By implementing this middle-layer sanitizer, we transformed an unpredictable AI output into a **100% deterministic, crash-proof data source**, allowing our UI to render complex architecture diagrams flawlessly every single time.
## The problem it solves
# CodeSpotlight โจ
**The Developer Proof-of-Work Platform** *Transform any public GitHub repository into a beautifully rendered, AI-powered case study.*
**Live Application / Deployment Link:** https://codespotlight-hm.web.app
**Watch Demo:** https://youtu.be/BZO2LhEN5AU
---
## ๐ Overview
Many developers build great projects but lose them in scattered GitHub repositories. **CodeSpotlight** is a centralized showcase directory where developers can host their deployed projects, generate AI-powered technical deep-dives, and present their work to recruiters through a polished, read-only portfolio interface.
Paste a GitHub URL, and CodeSpotlight's integration with Gemini AI and the GitHub API instantly generates architecture diagrams, commit heatmaps, language visualizations, and a fully formatted Markdown README.
---
## โจ Features
- **๐ค AI Technical Deep Dive:** Gemini 2.5 Flash generates a comprehensive case study explaining the project's purpose, the hardest problems solved, and the architectural decisions made.
- **๐ Auto-Generated READMEs:** Export your AI-generated project analysis to beautiful, fully-formatted Markdown, ready to be pushed directly to your GitHub repository.
- **๐๏ธ Architecture Diagrams:** Auto-generated Mermaid.js flowcharts visualize components, data flow, and system interactions in a secure sandboxed iframe.
- **๐ฅ Commit Heatmap:** A real 52-week ร 7-day contribution grid pulled live from GitHub to showcase consistent effort.
- **๐ Public Discoverability:** A global "Discover" feed where developers can browse top projects filtered by tech stack (MERN, Web3, AI, etc.).
- **๐ Secure Portfolio Sharing:** Share a read-only link to your portfolio with recruiters without exposing edit/delete controls. Includes customizable social links (LinkedIn, Twitter, Portfolio).
---
## ๐ ๏ธ Tech Stack
### Frontend
- **Framework:** Flutter Web (Canvas Kit) - **Routing:** `go_router` for shareable deep links - **Markdown:** `flutter_markdown` - **Hosting:** Firebase Hosting
### Backend
- **Framework:** Node.js + Express - **Authentication:** JWT (JSON Web Tokens) - **Database:** MongoDB Atlas (Mongoose) - **AI Integration:** `@google/generative-ai` (Gemini 2.5 Flash) - **Hosting:** Render.com
---
## ๐ Deployment Information
This project is fully deployed and accessible live for the hackathon judging process: - **Frontend (Flutter Web):** Deployed on **Firebase Hosting** - **Backend (Node.js/Express):** Deployed on **Render.com** - **Database (MongoDB):** Hosted on **MongoDB Atlas** - **Live URL:** https://codespotlight-hm.web.app
---
## ๐ Getting Started
Follow these instructions to set up the project locally. ### Prerequisites
- [Node.js](https://nodejs.org/en/) (v18 or higher)
- [Flutter SDK](https://docs.flutter.dev/get-started/install) (3.x with Web target enabled)
- A [MongoDB Atlas](https://www.mongodb.com/cloud/atlas/register) cluster URI
- A Google [Gemini API Key](https://aistudio.google.com/)
- A [GitHub Personal Access Token (PAT)](https://github.com/settings/tokens)
### 1. Backend Setup
```bash
# Navigate to the backend directory cd backend
# Copy the environment template
cp .env.example .env ```
**Configure Environment Variables (`backend/.env`):** | Variable | Description | |---|---| | `PORT` | API port (default: `3000`) | | `MONGODB_URI` | MongoDB Atlas connection string | | `JWT_SECRET` | Secret key for signing authentication tokens | | `GITHUB_PAT` | GitHub Personal Access Token (public repo scope) | | `GEMINI_API_KEY` | Google AI Studio key | | `CLIENT_URL` | Frontend URL for CORS (e.g., `http://localhost:52870`) |
```bash
# Install dependencies npm install
# Start the development server
npm run dev ```
### 2. Frontend Setup
```bash
# Open a new terminal and navigate to the frontend directory cd frontend
# Get dependencies
flutter pub get
# Run the Flutter web app (Chrome)
flutter run -d chrome ``` *Note: The frontend is configured to communicate with `http://localhost:3000/api` by default.*
---
## ๐ Project Structure
```text CodeSpotlight/ โโโ backend/ โ โโโ src/ โ โ โโโ controllers/ # Route logic โ โ โโโ models/ # Mongoose schemas (User, Project) โ โ โโโ routes/ # Express routes (auth.js, projects.js) โ โ โโโ services/ # Integrations (geminiService.js, githubService.js) โ โโโ index.js # Server entry point โ โโโ frontend/ โ โโโ lib/ โ โ โโโ models/ # Dart data models โ โ โโโ pages/ # UI Screens (Dashboard, Discover, Detail) โ โ โโโ services/ # API & Auth clients โ โ โโโ theme/ # Global AppTheme and styling โ โ โโโ widgets/ # Reusable UI (Cards, Heatmap, Mermaid) โ โโโ web/ # Web-specific assets (index.html) โ โโโ deploy.sh # Deployment automation script ```
Prizes
- 2nd Runner Up
Team
From the public Devfolio project page. Votes, swipes and the judge score are hackfeed's own.






