Skip to content

Commit 1ac7236

Browse files
committed
Update readme file for better explanation
1 parent bbf0cd4 commit 1ac7236

1 file changed

Lines changed: 87 additions & 37 deletions

File tree

README.md

Lines changed: 87 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,130 @@
11
# 🤖 AI Code Explainer
22

3-
[![Next.js](https://img.shields.io/badge/Next.js-14-black?style=for-the-badge&logo=nextdotjs)](https://nextjs.org/) [![TypeScript](https://img.shields.io/badge/TypeScript-blue?style=for-the-badge&logo=typescript)](https://www.typescriptlang.org/) [![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-38B2AC?style=for-the-badge&logo=tailwind-css)](https://tailwindcss.com/) [![DeepSeek API](https://img.shields.io/badge/DeepSeek_API-gray?style=for-the-badge&logo=openai)](https://www.deepseek.com/)
3+
[![Next.js](https://img.shields.io/badge/Next.js-16-black?style=for-the-badge&logo=nextdotjs)](https://nextjs.org/) [![TypeScript](https://img.shields.io/badge/TypeScript-5-blue?style=for-the-badge&logo=typescript)](https://www.typescriptlang.org/) [![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-4-38B2AC?style=for-the-badge&logo=tailwind-css)](https://tailwindcss.com/) [![Groq API](https://img.shields.io/badge/Groq_API-llama--3.1--8b--instant-gray?style=for-the-badge&logo=openai)](https://www.groq.com/)
44

5-
A simple web application that translates complex code into plain, easy-to-understand English. Paste any code snippet and get an instant explanation, powered by the DeepSeek Coder API.
5+
AI Code Explainer is a bilingual coding buddy that turns confusing code into friendly explanations. Paste any snippet, pick the tone you prefer, and get practical insights in English or Bengali—all powered by Groq’s `llama-3.1-8b-instant` model.
66

77
---
88

9-
## Features
9+
## Highlights
1010

11-
- **Simple Interface:** A clean, minimal UI with a single text area for pasting code.
12-
- **Instant Explanations:** Get real-time, human-like explanations for any code snippet.
13-
- **Multi-Language Support:** Understands JavaScript, Python, React, SQL, Regex, and more.
14-
- **Modern Tech:** Built with the latest Next.js 14 (App Router) and Server Actions.
11+
- **Bilingual output** – Switch between English and Bengali explanations without leaving the page.
12+
- **Custom teaching styles** – Choose explanation depth, style (detailed, concise, beginner), target audience, and whether to include examples.
13+
- **Quick start snippets** – One-click sample snippets help you test the flow instantly.
14+
- **Dark/light aware** – Theme toggle with persisted preference plus responsive layout built on shadcn/ui components.
15+
- **Helpful feedback** – Friendly loading states, validation, and actionable error messages keep the UX smooth.
1516

1617
---
1718

18-
## 🚀 Tech Stack
19+
## 🧰 Tech Stack
1920

20-
- **Framework:** [Next.js](https://nextjs.org/) 14 (App Router)
21+
- **Framework:** [Next.js](https://nextjs.org/) 16 (App Router, Route Handlers)
22+
- **UI:** [React](https://react.dev/) 19 + [shadcn/ui](https://ui.shadcn.com/) + [Radix UI](https://www.radix-ui.com/)
2123
- **Language:** [TypeScript](https://www.typescriptlang.org/)
22-
- **Styling:** [Tailwind CSS](https://tailwindcss.com/)
23-
- **Platform:** [Vercel](https://vercel.com/)
24-
- **AI:** [DeepSeek API](https://www.deepseek.com/) (deepseek-coder model)
24+
- **Styling:** [Tailwind CSS](https://tailwindcss.com/) 4 + `tailwind-merge`
25+
- **Icons:** [lucide-react](https://lucide.dev/)
26+
- **AI runtime:** [Groq API](https://console.groq.com/) (`llama-3.1-8b-instant`)
2527

2628
---
2729

28-
## 🛠️ Getting Started
30+
## 🚀 Getting Started
2931

30-
Follow these instructions to get a copy of the project running on your local machine for development and testing.
32+
Follow the steps below to set up the project locally.
3133

3234
### Prerequisites
3335

34-
- [Node.js](https://nodejs.org/en/) (Version 18.x or newer)
35-
- A DeepSeek API Key (Get yours from the [DeepSeek Platform](https://platform.deepseek.com/))
36+
- [Node.js](https://nodejs.org/en/) 18 or newer
37+
- [pnpm](https://pnpm.io/) 9+ (or npm/yarn if you prefer)
38+
- A Groq API key with access to `llama-3.1-8b-instant`
3639

37-
### 1. Clone the Repository
40+
### Installation
3841

3942
```bash
40-
git clone [https://github.com/your-username/ai-code-explainer.git](https://github.com/your-username/ai-code-explainer.git)
43+
git clone https://github.com/maker-shihab/ai-code-explainer.git
4144
cd ai-code-explainer
45+
pnpm install # or npm install / yarn install
4246
```
4347

44-
### 2. Install Dependencies
48+
### Environment Variables
49+
50+
Create a `.env.local` file in the project root:
4551

4652
```bash
47-
npm install
48-
# or
49-
yarn install
53+
GROQ_API_KEY=your_groq_api_key
5054
```
5155

52-
### 3. Setup Environment Variables
56+
Optional integrations already scaffolded in `lib/` can use:
5357

54-
Create a new file named `.env.local` in the root of your project and add your DeepSeek API key.
58+
```bash
59+
DEEPSEEK_API_KEY=optional_if_you_enable_deepseek
60+
GOOGLE_GEMINI_API_KEY=optional_if_you_enable_gemini
61+
HUGGING_FACE_API_KEY=optional_if_you_enable_huggingface
62+
```
63+
64+
### Start the Dev Server
5565

5666
```bash
57-
DEEPSEEK_API_KEY="YOUR_SECRET_DEEPSEEK_API_KEY_HERE"
67+
pnpm dev
68+
# or: npm run dev / yarn dev
5869
```
5970

60-
### 4. Run the Development Server
71+
Then visit [http://localhost:3000](http://localhost:3000).
72+
73+
### Useful Scripts
74+
75+
- `pnpm build` – create a production build
76+
- `pnpm start` – run the production server
77+
- `pnpm lint` – check code quality with ESLint
78+
79+
---
80+
81+
## 🧑‍💻 How to Use It
82+
83+
1. Paste or type your code into the **Your Code** editor.
84+
2. Adjust filters to match your learning needs (language, depth, style, target audience, examples).
85+
3. Hit **Explain Code** and wait a moment while Groq generates the response.
86+
4. Review the explanation in the **AI Explanation** panel and tweak settings if you’d like a different tone.
87+
88+
Tip: Use the Quick Start buttons to prefill common React/Python/JavaScript snippets for demos.
89+
90+
---
91+
92+
## 🏗️ Architecture Overview
93+
94+
- `app/page.tsx` – Client-side UI with state, validation, and user interactions.
95+
- `components/filters/advanced-filters.tsx` – Reusable filter and preference controls.
96+
- `app/api/explain/route.ts` – Next.js route handler that sanitizes input and proxies Groq.
97+
- `lib/groq.ts` – GroqService wrapper that crafts bilingual prompts and calls the API.
98+
- `types/index.ts` – Shared TypeScript contracts for requests/responses.
99+
- `app/providers/theme-provider.tsx` & `components/ui/theme-toggle.tsx` – Theming logic with persisted preferences.
100+
101+
### API Contract
102+
103+
`POST /api/explain`
61104

62105
```bash
63-
npm run dev
64-
# or
65-
yarn dev
106+
curl -X POST http://localhost:3000/api/explain \
107+
-H "Content-Type: application/json" \
108+
-d '{
109+
"code": "const greet = (name) => `Hello, ${name}!`;",
110+
"language": "english",
111+
"explanationStyle": "beginner",
112+
"includeExamples": true,
113+
"programmingLanguage": "auto",
114+
"explanationDepth": "basic",
115+
"targetAudience": "student"
116+
}'
66117
```
67118

68-
Open [Local Host](http://localhost:3000) with your browser to see the application.
119+
---
120+
121+
## 🚢 Deployment
69122

70-
## ⚙️ How It Works
123+
The project is optimized for [Vercel](https://vercel.com/) (default Next.js hosting), but any platform that supports Next.js 16 will work:
71124

72-
1. The user enters their code into the `<textarea>` on the client-side page (`app/page.tsx`).
73-
2. Clicking the "Explain" button triggers a **Next.js Server Action** (`explainCode`) defined in `app/actions.ts`.
74-
3. This Server Action (running securely on the server) fetches the `DEEPSEEK_API_KEY` from environment variables.
75-
4. It makes a `POST` request to the DeepSeek API, sending the user's code and a system prompt.
76-
5. The AI's response is parsed and returned directly to the client component.
77-
6. The client component updates its state with the explanation, displaying it to the user.
125+
1. Set environment variables in your hosting dashboard (`GROQ_API_KEY` at minimum).
126+
2. Run the production build: `pnpm build`.
127+
3. Serve with `pnpm start` or let Vercel handle the build & deploy pipeline automatically.
78128

79129
---
80130

0 commit comments

Comments
 (0)