Skip to content

CodeSentinel-Core-Team/CodeSentinel_AI

Repository files navigation

CodeSentinel AI - Backend

AI-powered code security analysis for GitHub repositories with automated vulnerability detection.

Features

  • Real-time security analysis on pull requests
  • AI-powered vulnerability detection using DeepSeek
  • GitHub App integration with webhooks
  • Comprehensive security reports
  • Automated code review comments

Tech Stack

  • FastAPI: Modern Python web framework
  • PostgreSQL: Primary database
  • Redis: Caching and job queue
  • OpenAI-compatible DeepSeek: AI analysis engine
  • Prisma: Canonical PostgreSQL schema and migration workflow
  • GitHub API: Repository integration

Prerequisites

  • Python 3.11+
  • PostgreSQL 14+
  • Redis 6+
  • GitHub App credentials
  • OpenAI-compatible DeepSeek API key

Installation

  1. Clone the repository:
git clone <repository-url>
cd CodeSentinel_AI
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your credentials
  1. Generate Prisma client and apply the database schema:
npm install
npx prisma generate
npx prisma db push
  1. Start the application:
uvicorn app.main:app --reload

Environment Variables

See .env.example for required configuration.

Transactional Email

CodeSentinel sends OTP, welcome, and billing emails through SMTP. Brevo is the recommended production provider.

Brevo SMTP settings:

SMTP_HOST=smtp-relay.brevo.com
SMTP_PORT=587
SMTP_USERNAME=your-brevo-smtp-login
SMTP_PASSWORD=your-brevo-smtp-key
SMTP_USE_TLS=True
SMTP_USE_SSL=False
EMAIL_FROM_ADDRESS=no-reply@yourdomain.com
EMAIL_FROM_NAME=CodeSentinel AI

Before sending production email, make sure you:

  1. Authenticate your sending domain in Brevo.
  2. Create and verify the transactional sender address you want to use in EMAIL_FROM_ADDRESS.
  3. Use your Brevo SMTP login and SMTP key, not your Brevo account password or API key.

You can send a live SMTP test email with:

node scripts/send_test_email.js recipient@example.com

Database Schema Governance

  • Canonical schema source: prisma/schema.prisma.
  • scripts/init_db.py and scripts/init_db_standalone.py are bootstrap helpers, not authoritative schema definitions.
  • Schema changes should be made in Prisma schema first.
  • For production releases, create and review Prisma migrations, then run npx prisma migrate deploy during deployment. Use npx prisma db push only for local/bootstrap environments.

API Documentation

Once running, visit:

Project Structure

app/
├── api/          # API routes and endpoints
├── core/         # Security and logging
├── db/           # Database configuration
├── models/       # SQLAlchemy models
├── schemas/      # Pydantic schemas
├── services/     # Business logic
├── agents/       # AI analysis agents
├── webhooks/     # GitHub webhook handlers
├── github/       # GitHub API integration
└── utils/        # Utility functions

Development

Run tests:

pytest

Run with coverage:

pytest --cov=app tests/

Docker

docker-compose up -d

License

MIT

About

CodeSentinel is a Github App with the dashboard integration for bigtech organisations

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages