Skip to content

Komatlakarthik/E2E_Project-CodePath_Ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodePath AI - An AI-Assisted Beginner Coding Platform

React FastAPI MongoDB Python

🌍 Live Website

https://codepath-ai-frontend.onrender.com/

🎯 Overview

CodePath AI is a production-ready web application designed to help beginners learn programming through:

  • Micro-Lessons: Bite-sized lessons covering programming fundamentals
  • Hands-On Coding: In-browser code editor with real-time execution
  • AI-Guided Hints: Intelligent mentoring that guides without giving solutions
  • Progress Tracking: Streaks, badges, and leaderboards to keep you motivated

⚠️ Core Philosophy

The AI Mentor NEVER provides complete solutions. Instead, it offers:

  • Conceptual explanations
  • Logical hints and guiding questions
  • Error reasoning and debugging guidance
  • Optimization suggestions and best practices

This approach ensures learners develop problem-solving skills rather than just copying code.

πŸš€ Learning Tracks

  1. Java with DSA - Java fundamentals and Data Structures & Algorithms
  2. Data Science - Python, NumPy, Pandas, and data analysis
  3. AI Engineer - Machine learning concepts and implementations

πŸ› οΈ Tech Stack

Backend

  • FastAPI - Modern Python web framework
  • MongoDB - NoSQL database with Motor async driver
  • JWT - Secure authentication with access & refresh tokens
  • Piston API - Safe code execution in isolated containers

Frontend

  • React 18 - UI library with hooks
  • Vite - Lightning-fast build tool
  • Tailwind CSS - Utility-first styling
  • Monaco Editor - VS Code's editor in the browser
  • Zustand - Lightweight state management
  • React Router v6 - Client-side routing

πŸ“ Project Structure

🧩 Team Module Architecture (4 Modules)

Project ownership is divided into these modules:

  1. User Management & Authentication
  2. Learning Content & Micro-Lessons
  3. Coding Practice & AI Guidance
  4. Progress Tracking & Recommendation

The backend now registers routes through module entrypoints in backend/modules/, and the frontend route wiring imports module entrypoints from frontend/src/modules/.

For full file ownership mapping and push order, see MODULE_SPLIT.md.

codepath-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                 # FastAPI application entry
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ database.py         # MongoDB connection
β”‚   β”‚   └── settings.py         # Environment settings
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ user.py             # User model
β”‚   β”‚   β”œβ”€β”€ lesson.py           # Lesson model
β”‚   β”‚   β”œβ”€β”€ problem.py          # Problem model
β”‚   β”‚   β”œβ”€β”€ progress.py         # Progress model
β”‚   β”‚   └── ai_hint.py          # AI hint model
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.py             # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ lessons.py          # Lesson CRUD
β”‚   β”‚   β”œβ”€β”€ practice.py         # Problem solving
β”‚   β”‚   β”œβ”€β”€ progress.py         # Progress tracking
β”‚   β”‚   └── ai_mentor.py        # AI hint endpoints
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ auth_service.py     # Auth business logic
β”‚   β”‚   β”œβ”€β”€ lesson_service.py   # Lesson operations
β”‚   β”‚   β”œβ”€β”€ problem_service.py  # Problem operations
β”‚   β”‚   β”œβ”€β”€ code_execution_service.py  # Piston API
β”‚   β”‚   β”œβ”€β”€ progress_service.py # Stats & badges
β”‚   β”‚   └── ai_mentor_service.py # AI mentoring
β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   └── prompts.py          # AI prompt templates
β”‚   └── utils/
β”‚       └── security.py         # JWT & password utils
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.jsx            # React entry
β”‚   β”‚   β”œβ”€β”€ App.jsx             # Routes & layouts
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ layouts/        # MainLayout, AuthLayout
β”‚   β”‚   β”‚   └── editor/         # CodeEditor, OutputPanel, AIHintPanel
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ DashboardPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LessonsPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProblemsPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProblemSolvePage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProgressPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfilePage.jsx
β”‚   β”‚   β”‚   └── auth/
β”‚   β”‚   β”œβ”€β”€ services/           # API service layer
β”‚   β”‚   └── stores/             # Zustand stores
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── tailwind.config.js
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .env.example
└── README.md

πŸ”§ Installation & Setup

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • MongoDB (local or Atlas)
  • OpenAI or Anthropic API key

Backend Setup

  1. Clone the repository

    git clone https://github.com/yourusername/codepath-ai.git
    cd codepath-ai
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment

    cp .env.example .env
    # Edit .env with your settings
  5. Run the backend

    cd backend
    uvicorn main:app --reload --host 0.0.0.0 --port 8000

Frontend Setup

  1. Install dependencies

    cd frontend
    npm install
  2. Start development server

    npm run dev
  3. Build for production

    npm run build

πŸ” Environment Variables

Create a .env file with the following:

# MongoDB
MONGODB_URL=mongodb://localhost:27017
DATABASE_NAME=codepath_ai

# JWT
JWT_SECRET_KEY=your-super-secret-key-min-32-chars
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7

# AI Provider (choose one)
OPENAI_API_KEY=sk-your-openai-key
# OR
ANTHROPIC_API_KEY=your-anthropic-key

# Piston API
PISTON_API_URL=https://emkc.org/api/v2/piston

# Frontend URL (for CORS)
FRONTEND_URL=http://localhost:5173

# Environment
ENVIRONMENT=development

🌐 API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login Login user
POST /api/auth/refresh Refresh access token
POST /api/auth/change-password Change password
GET /api/auth/me Get current user
PUT /api/auth/profile Update profile

Lessons

Method Endpoint Description
GET /api/lessons List lessons
GET /api/lessons/{id} Get lesson details
GET /api/lessons/tracks Get learning tracks
POST /api/lessons/{id}/complete Mark as complete

Practice

Method Endpoint Description
GET /api/practice/problems List problems
GET /api/practice/problems/{id} Get problem
POST /api/practice/problems/{id}/run Run code
POST /api/practice/problems/{id}/submit Submit solution

AI Mentor

Method Endpoint Description
POST /api/ai/hint Get AI hint
POST /api/ai/analyze-error Analyze code error
POST /api/ai/ask Ask AI question

Progress

Method Endpoint Description
GET /api/progress/stats Get user stats
GET /api/progress/badges Get earned badges
GET /api/progress/leaderboard Get leaderboard

🐳 Docker Deployment

# Build the image
docker build -t codepath-ai .

# Run the container
docker run -d -p 8000:8000 \
  -e MONGODB_URL=your-mongo-url \
  -e JWT_SECRET_KEY=your-secret \
  -e OPENAI_API_KEY=your-key \
  codepath-ai

πŸš€ Deployment on Render

  1. Create a new Web Service on Render
  2. Connect your GitHub repository
  3. Set build command: pip install -r requirements.txt
  4. Set start command: cd backend && uvicorn main:app --host 0.0.0.0 --port $PORT
  5. Add environment variables in Render dashboard

πŸ§ͺ Testing

# Backend tests
cd backend
pytest

# Frontend tests
cd frontend
npm test

🎨 Features

For Learners

  • πŸ“š Structured micro-lessons by track
  • πŸ’» In-browser code editor with syntax highlighting
  • πŸ€– AI mentor for guidance (never gives solutions!)
  • πŸ“Š Progress tracking with streaks and badges
  • πŸ† Leaderboard to compete with others

For Admins

  • Create and manage lessons
  • Add coding problems with test cases
  • Configure AI prompt settings
  • View user analytics

πŸ€– AI Mentoring Rules

The AI strictly follows these guidelines:

  1. NEVER provide complete code solutions
  2. NEVER write the function body or implementation
  3. ALWAYS guide with questions and hints
  4. FOCUS on teaching concepts and problem-solving

Example AI response:

"I notice you're trying to find the maximum element. Think about this: what happens when you compare two numbers? How could you use that comparison as you go through each element?"

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“§ Support

For questions or issues, please open a GitHub issue or contact the team.


Built with ❀️ for aspiring developers

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors