Skip to content

Commit df490ec

Browse files
committed
readme file updated
1 parent 8635ec9 commit df490ec

3 files changed

Lines changed: 115 additions & 108 deletions

File tree

README.md

Lines changed: 102 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,126 @@
1-
# 🚀 CodeScribeAI
1+
# CodeScribeAI
2+
3+
CodeScribeAI is a local-first coding assistant with:
4+
- FastAPI backend
5+
- React + Vite frontend
6+
- GitHub repository analysis
7+
- Ollama-powered AI responses
8+
9+
## Current Architecture
10+
- Backend: `main.py` (FastAPI)
11+
- Frontend: `frontend/` (React, Vite)
12+
- Session store: SQLite (`sessions.db`)
13+
- Optional async workers: Celery + Redis
14+
15+
## Prerequisites
16+
- Python 3.10+
17+
- Node.js 18+
18+
- Ollama installed and running
19+
- (Optional) Redis for async chat endpoints
20+
21+
## Environment Setup
22+
1. Copy `.env.example` to `.env`
23+
2. Fill real credentials and secrets
224

3-
🚧 Note: The Project is in development
4-
<br>
5-
**CodeScribeAI** is an AI-powered coding assistant that helps you **explore, debug, and understand code** effortlessly.
6-
Built with **React**, **Node.js**, and **Ollama LLM**, it’s designed to boost developer productivity and make coding more intuitive.
7-
8-
---
9-
10-
## ✨ Features
11-
12-
- 🤖 **AI-Powered Assistance** – Get instant explanations, debugging help, and code insights.
13-
- 📂 **File Analysis** – Upload or select files for detailed breakdowns.
14-
- 💡 **Smart Suggestions** – Improve your code with AI-driven recommendations.
15-
- 🎨 **Clean UI** – Minimal and distraction-free interface built with React + Tailwind.
16-
- 🛠️ **Extensible Backend** – Node.js + Express API with modular routes.
17-
- 🔒 **In Progress** – Actively being developed with new features coming soon!
18-
19-
---
20-
21-
## 🛠️ Tech Stack
22-
23-
**Frontend**
24-
- ⚛️ React
25-
- 🎨 Tailwind CSS
26-
- 🔄 React Router
27-
- ✨ GSAP (animations)
28-
29-
**Backend**
30-
- 🟢 Node.js + Express
31-
- 🗄️ MySQL2 (with SSL for DigitalOcean)
32-
- 📦 Multer (file uploads)
33-
- 📧 Nodemailer (email handling)
34-
35-
**AI**
36-
- 🧠 [Ollama](https://ollama.ai) – Local LLM integration
37-
38-
---
25+
```bash
26+
cp .env.example .env
27+
```
3928

40-
## 🚀 Getting Started
29+
Required keys:
30+
```env
31+
APP_ENV=development
32+
SECRET_KEY=replace-with-a-long-random-string
33+
FRONTEND_URL=http://localhost:5173
34+
SESSION_TTL_SECONDS=3600
35+
SESSIONS_DB_PATH=sessions.db
36+
GITHUB_CLIENT_ID=your_github_client_id
37+
GITHUB_CLIENT_SECRET=your_github_client_secret
38+
GITHUB_TOKEN=your_github_token
39+
OLLAMA_URL=http://127.0.0.1:11434
40+
OLLAMA_MODEL=phi3:mini
41+
OLLAMA_FALLBACK_MODELS=
42+
```
4143

42-
Follow these steps to set up CodeScribeAI locally:
44+
Optional async keys:
45+
```env
46+
CELERY_BROKER_URL=redis://localhost:6379/0
47+
CELERY_RESULT_BACKEND=redis://localhost:6379/0
48+
```
4349

44-
### 1️⃣ Clone the Repository
50+
## Install
51+
### Backend
4552
```bash
46-
git clone https://github.com/your-username/codescribeAI.git
47-
cd codescribeAI
53+
# from repo root
54+
python -m venv venv
55+
# Windows PowerShell
56+
.\venv\Scripts\Activate.ps1
57+
pip install fastapi uvicorn httpx python-dotenv itsdangerous pydantic celery
4858
```
49-
### 2️⃣ Install Dependencies
59+
60+
### Frontend
5061
```bash
51-
Frontend:
5262
cd frontend
5363
npm install
54-
Backend:
55-
cd backend
56-
npm install
5764
```
58-
### 3️⃣ Configure Environment
59-
Copy `.env.example` to `.env` and fill values:
65+
66+
## Run Locally
67+
### 1) Start Ollama
6068
```bash
61-
cp .env.example .env
69+
ollama serve
70+
ollama pull phi3:mini
6271
```
63-
Required values:
72+
73+
### 2) Start backend
6474
```bash
65-
APP_ENV=development
66-
SECRET_KEY=replace-with-a-long-random-string
67-
GITHUB_CLIENT_ID=your_github_client_id
68-
GITHUB_CLIENT_SECRET=your_github_client_secret
69-
GITHUB_TOKEN=your_github_token
70-
OLLAMA_URL=http://127.0.0.1:11434
75+
# from repo root
76+
.\venv\Scripts\Activate.ps1
77+
uvicorn main:app --reload --host 127.0.0.1 --port 8000
7178
```
72-
Security notes:
73-
- Never commit `.env` to git.
74-
- Rotate secrets immediately if they were ever shared.
75-
### 4️⃣ Run the Project
76-
Start backend:
79+
80+
### 3) Start frontend
7781
```bash
78-
cd backend
79-
npm run dev
80-
Start frontend:
8182
cd frontend
8283
npm run dev
8384
```
8485

85-
---
86-
87-
## 📌 Roadmap
88-
AI-powered debugging suggestions
89-
90-
Multi-file context awareness
91-
92-
Chat-like interface for conversations with AI
93-
94-
Cloud deployment (Vercel + DigitalOcean)
95-
96-
Authentication & user profiles
97-
98-
## 🤝 Contributing
99-
Contributions are welcome!
86+
Open: `http://localhost:5173`
10087

101-
Fork the repo
88+
## Optional: Async Worker (Celery)
89+
Only needed if you use async task endpoints.
10290

103-
Create a feature branch (git checkout -b feature-name)
104-
105-
Commit changes (git commit -m "Add feature")
106-
107-
Push to your branch (git push origin feature-name)
108-
109-
Open a Pull Request 🎉
110-
111-
## 📜 License
112-
This project is licensed under the MIT License.
113-
See the LICENSE file for details.
114-
115-
## 🌟 Support
116-
If you like this project, please consider giving it a ⭐ on GitHub – it helps a lot!
91+
```bash
92+
# requires Redis running
93+
.\venv\Scripts\Activate.ps1
94+
celery -A main:celery_app worker --loglevel=info --pool=solo
95+
```
11796

118-
## 📸 Screenshots (Coming Soon)
97+
## Testing and Quality
98+
### Backend tests
99+
```bash
100+
python -m unittest discover -s tests -v
101+
```
119102

103+
### Frontend lint
104+
```bash
105+
cd frontend
106+
npm run lint
107+
```
120108

109+
## Key API Endpoints
110+
- `GET /health`
111+
- `GET /api/ai-status`
112+
- `POST /api/chat`
113+
- `POST /api/chat-async` (optional, Celery)
114+
- `GET /repos/{username}`
115+
- `GET /repos/{owner}/{repo}/files?recursive=true`
116+
- `GET /repos/{owner}/{repo}/file-content?path=...`
117+
118+
## Security Notes
119+
- Never commit `.env`.
120+
- Rotate any leaked credentials immediately.
121+
- For non-development environments:
122+
- set a strong `SECRET_KEY`
123+
- use secure deployment secrets management
124+
125+
## Production Readiness
126+
See `PRODUCTION_READINESS.md` for checklist and current status.

frontend/src/components/FilePreview.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from "react";
1+
import { useState, useEffect } from "react";
22
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
33
import { materialDark } from "react-syntax-highlighter/dist/esm/styles/prism";
44

@@ -96,7 +96,7 @@ export default function FilePreview({ owner, repo, filePath, askAI }) {
9696
<span className="absolute inset-0 w-full h-full bg-gradient-to-br from-blue-600 via-purple-600 to-pink-700"></span>
9797
<span className="absolute bottom-0 right-0 block w-64 h-64 mb-32 mr-4 transition duration-500 origin-bottom-left transform rotate-45 translate-x-24 bg-pink-500 rounded-full opacity-30 group-hover:rotate-90 ease"></span>
9898
<span className="relative text-white text-sm font-semibold">
99-
🤖 Ask AI
99+
Ask AI
100100
</span>
101101
</button>
102102
</div>
@@ -124,3 +124,4 @@ export default function FilePreview({ owner, repo, filePath, askAI }) {
124124
</div>
125125
);
126126
}
127+

main.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,11 @@ async def chat(req: ChatRequest):
667667

668668
intent = detect_intent(msg)
669669

670-
# 1) Structured intents → GitHub API (deterministic answers)
670+
# 1) Structured intents -> GitHub API (deterministic answers)
671671
try:
672672
if intent == "summarize_file":
673673
if not req.file_content:
674-
return ChatResponse(reply="⚠️ To explain a file, please select one first.", meta={"grounded": False})
674+
return ChatResponse(reply="[WARN] To explain a file, please select one first.", meta={"grounded": False})
675675

676676
# Large files (especially notebooks) can time out local models.
677677
max_chars = 12000
@@ -741,7 +741,7 @@ async def chat(req: ChatRequest):
741741
if intent == "get_stars":
742742
meta = await get_repo_meta(req.github_user, req.repo)
743743
stars = meta.get("stargazers_count", 0)
744-
return ChatResponse(reply=f"{req.repo} has ⭐ {stars} stars.", meta={"stars": stars})
744+
return ChatResponse(reply=f"{req.repo} has * {stars} stars.", meta={"stars": stars})
745745

746746
if intent == "get_repo_name":
747747
return ChatResponse(reply=f"The name of this repository is **{req.repo}**.")
@@ -752,28 +752,28 @@ async def chat(req: ChatRequest):
752752

753753
except HTTPException as e:
754754
if e.status_code == 429:
755-
return ChatResponse(reply="⚠️ GitHub rate limit reached. Please try again later.")
756-
return ChatResponse(reply=f"⚠️ GitHub error: {e.detail}")
755+
return ChatResponse(reply="[WARN] GitHub rate limit reached. Please try again later.")
756+
return ChatResponse(reply=f"[WARN] GitHub error: {e.detail}")
757757
except Exception as e:
758-
# Don’t block — we’ll still try LLM with context
758+
# Do not block; still try LLM with context
759759
pass
760760

761-
# 2) Repo-related open questions → LLM grounded with context
761+
# 2) Repo-related open questions -> LLM grounded with context
762762
if intent == "summarize_repo":
763763
ctx = await build_repo_context(req.github_user, req.repo, include_readme=True)
764764
ctx_block = format_context_block(ctx)
765765
prompt = (
766766
"You are a helpful software assistant. Use the provided repository context when relevant. "
767-
"If the context is weak or missing details, say what you’re unsure about.\n\n"
767+
"If the context is weak or missing details, say what you're unsure about.\n\n"
768768
f"User question:\n{msg}\n\n"
769769
f"Repository context:\n{ctx_block}\n\n"
770770
"Answer clearly and concisely."
771771
)
772772
ans = await call_llm(prompt, req.model)
773773
return ChatResponse(reply=ans, sources=[], meta={"grounded": True})
774774

775-
# 3) Anything else (general world questions, arbitrary chat) → ChatGPT-like
776-
# Still include repo context in case it helps, but don’t force it.
775+
# 3) Anything else (general world questions, arbitrary chat) -> ChatGPT-like
776+
# Still include repo context in case it helps, but do not force it.
777777
ctx = await build_repo_context(req.github_user, req.repo, include_readme=False)
778778
repo_signal = re.search(r"\b(repo|repository|project|file|folder|directory|codebase|this repo)\b", msg.lower())
779779
if repo_signal and not (ctx.get("files") or ctx.get("dirs") or ctx.get("readme")):

0 commit comments

Comments
 (0)