Code scanning β’ Risk scoring β’ Human-readable findings β’ Fix recommendations β’ Markdown reports
https://devguard-ai-urly.onrender.com/ui/
DevGuard AI is a Python/FastAPI security reviewer that scans source code for common risky patterns, explains findings in simple language, stores review history, and generates Markdown security reports.
DevGuard AI is a defensive developer-security tool built to help programmers understand risky code before it becomes a real problem.
The project analyzes pasted code or uploaded files and looks for common security mistakes such as hardcoded passwords, possible API keys, weak password examples, SQL injection-style patterns, unsafe shell execution, debug mode configuration, and insecure hashing.
Instead of only showing warnings, DevGuard AI explains why each issue matters and gives safer recommendations.
DevGuard AI is not a professional SAST replacement.
It is an educational, portfolio-focused backend project that demonstrates secure coding awareness, API design, and AI-style explanation logic.
Beginner developers often push secrets, weak passwords, debug settings, or unsafe patterns into their projects without realizing the risk.
I built DevGuard AI to create a tool that helps developers learn from their code. My goal was to build something more serious than a simple scanner: a backend system that accepts code, reviews it, scores the risk, stores results, and generates readable reports.
This project is part of my AI engineering, backend development, and cybersecurity portfolio.
DevGuard AI works like a guardian pipeline: code enters the system, scanner services inspect it, the risk engine scores it, and the output layer turns the results into explanations and reports.
flowchart LR
subgraph Input["π₯ Input Layer"]
A["User pastes code"] --> B["Review API"]
C["User uploads file"] --> B
end
subgraph GuardCore["π‘οΈ Guard Core"]
B --> D["Code Scanner"]
D --> E["Secret Detector"]
D --> F["Pattern Rules"]
E --> G["Risk Scoring Engine"]
F --> G
end
subgraph Intelligence["π§ Explanation Layer"]
G --> H["AI-Style Explanation Generator"]
H --> I["Fix Recommendations"]
end
subgraph Output["π€ Output Layer"]
I --> J["SQLite Review History"]
J --> K["Review Detail API"]
J --> L["Markdown Report Builder"]
J --> M["Built-in Web UI"]
end
| Feature | Description |
|---|---|
| Code Review API | Accepts source code and returns structured security findings |
| File Upload UI | Supports local code file upload through the built-in interface |
| Risk Scoring | Generates a 0β100 risk score |
| Risk Levels | Classifies reviews as LOW, MEDIUM, HIGH, or CRITICAL |
| Secret Detection | Looks for hardcoded passwords, tokens, API keys, and secrets |
| Unsafe Pattern Detection | Flags risky code patterns like debug mode or unsafe shell execution |
| SQL Injection-Style Detection | Detects risky string-built query patterns |
| AI-Style Explanations | Explains findings in human-readable language |
| Fix Recommendations | Suggests safer coding practices |
| Review History | Stores previous reviews in SQLite |
| Markdown Reports | Generates clean security review reports |
| Built-in UI | Provides a simple browser interface served by FastAPI |
| Render Deployment Ready | Includes deployment configuration files |
DevGuard AI uses static, rule-based code analysis.
| Rule | What it Detects |
|---|---|
| Hardcoded Password | Password-like variables written directly in code |
| API Key / Token Pattern | Possible hardcoded tokens, keys, or secrets |
| Weak Password Example | Common weak values such as admin123 or password123 |
| SQL Injection-Style Pattern | Query strings built with direct user input |
| Unsafe Shell Execution | Risky command execution patterns |
| Debug Mode Enabled | Development debug settings left enabled |
| Insecure Hash Usage | Weak hash functions such as MD5 or SHA1 |
| Environment File Exposure | Mentions of .env or local secret files |
DevGuard AI reports possible risks. It does not claim certainty, execute code, exploit code, or interact with external systems.
| Layer | Technology |
|---|---|
| Language | Python |
| Backend Framework | FastAPI |
| Validation | Pydantic |
| Database ORM | SQLAlchemy |
| Database | SQLite |
| Security Logic | Regex-based static scanner |
| Explanation Engine | Template-based AI-style explanations |
| Frontend | HTML, CSS, JavaScript served by FastAPI |
| Deployment | Render |
| Server | Uvicorn |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/health |
Service health check |
POST |
/api/v1/reviews |
Submit code for security review |
GET |
/api/v1/reviews |
List review history |
GET |
/api/v1/reviews/{review_id} |
Get a saved review |
GET |
/api/v1/reports/{review_id}/markdown |
Generate a Markdown report |
GET |
/ui |
Open the built-in web interface |
GET |
/docs |
Open FastAPI Swagger documentation |
git clone https://github.com/FluxKnight/DevGuard-AI.git
cd DevGuard-AIpython -m venv .venvmacOS / Linux:
source .venv/bin/activateWindows PowerShell:
.venv\Scripts\Activate.ps1pip install -r requirements.txtuvicorn app.main:app --reloadAPI docs:
http://127.0.0.1:8000/docs
Built-in UI:
http://127.0.0.1:8000/ui
curl -X POST "http://127.0.0.1:8000/api/v1/reviews" \
-H "Content-Type: application/json" \
-d '{
"filename": "login.py",
"language": "python",
"code": "password = \"admin123\"\nquery = \"SELECT * FROM users WHERE name = \" + username\ndebug = True"
}'{
"id": 1,
"filename": "login.py",
"language": "python",
"risk_score": 85,
"risk_level": "CRITICAL",
"summary": "This file contains multiple security risks, including hardcoded credentials, risky query construction, and debug configuration.",
"findings": [
{
"code": "HARDCODED_PASSWORD",
"title": "Hardcoded password detected",
"severity": "HIGH",
"line": 1,
"explanation": "A password-like value appears to be written directly in the source code.",
"recommendation": "Move secrets into environment variables or a secure secret manager."
},
{
"code": "SQL_INJECTION_STYLE_PATTERN",
"title": "Risky SQL query construction",
"severity": "HIGH",
"line": 2,
"explanation": "The query appears to be built through string concatenation.",
"recommendation": "Use parameterized queries or an ORM query builder."
},
{
"code": "DEBUG_MODE_ENABLED",
"title": "Debug mode enabled",
"severity": "MEDIUM",
"line": 3,
"explanation": "Debug mode can expose sensitive application details if enabled in production.",
"recommendation": "Disable debug mode in production environments."
}
],
"created_at": "2026-05-25T12:00:00"
}DevGuard AI includes a simple web interface served directly by FastAPI.
The UI supports:
- Pasting source code
- Uploading local code files
- Running a security review
- Viewing risk score and risk level
- Reading findings and recommendations
- Opening Markdown reports
- Loading review history
Open it locally at:
http://127.0.0.1:8000/ui
# DevGuard AI Security Review Report
## Summary
This review found several security risks in the submitted code.
## File
Filename: login.py
Language: python
## Risk
Score: 85
Level: CRITICAL
## Findings
- Hardcoded password detected
- Risky SQL query construction
- Debug mode enabled
## Recommendations
- Move secrets into environment variables.
- Use parameterized queries.
- Disable debug mode in production.
## Note
This review is based on static pattern analysis only. It does not execute the submitted code.DevGuard-AI/
βββ app/
β βββ api/
β β βββ routes/
β β βββ router.py
β βββ core/
β βββ db/
β βββ models/
β βββ schemas/
β βββ services/
β β βββ code_scanner.py
β β βββ secret_detector.py
β β βββ risk_scoring.py
β β βββ explanation.py
β β βββ report_builder.py
β βββ static/
β βββ templates/
β βββ main.py
β
βββ demo-assets/
βββ docs/
βββ Procfile
βββ render.yaml
βββ requirements.txt
βββ README.md
This project includes Render deployment support.
Build command:
pip install -r requirements.txtStart command:
uvicorn app.main:app --host 0.0.0.0 --port $PORTAfter deployment:
https://your-render-service-url.onrender.com/docs
https://your-render-service-url.onrender.com/ui
DevGuard AI demonstrates:
- Python backend engineering
- FastAPI API design
- Clean service-layer architecture
- Static code security analysis
- Rule-based risk detection
- AI-style explanation generation
- SQLAlchemy database modeling
- Security report generation
- Built-in UI integration
- Render deployment readiness
- Defensive cybersecurity thinking
DevGuard AI is my backend-focused AI engineering and cybersecurity project.
It analyzes source code for common security risks, explains issues in human language, and generates safer recommendations. I built it to show that I can design APIs, structure backend services, create rule-based analysis systems, and apply cybersecurity thinking to developer tools.
This project is not just a script.
It is structured like a real backend service with API endpoints, database storage, UI, reports, and documentation.
DevGuard AI is defensive and educational only.
It does not:
- exploit applications
- execute submitted code
- steal secrets
- attack systems
- bypass security
- generate malware
- perform credential collection
- interact with external targets
DevGuard AI only performs static pattern analysis on code submitted by the user.
- Code review API
- Rule-based scanner
- Secret detection
- Risk scoring
- Human-readable explanations
- SQLite review history
- Markdown report generation
- Built-in frontend UI
- Render deployment configuration
- GitHub repository scan mode
- ZIP project upload support
- Docker setup
- PostgreSQL support
- API key authentication
- Export reports as PDF
- Optional LLM-powered review layer
python fastapi cybersecurity backend devsecops security-tools code-review static-analysis secure-coding ai-engineering developer-tools hackathon-project portfolio-project
Hvslen Ganbat
GitHub: @FluxKnight
Built as part of my portfolio for AI engineering, backend development, cybersecurity, and hackathon preparation.