Skip to content

Repository files navigation

CloudPortal — Self-Service Cloud Efficient Resource Provisioning

A SEAI college project demonstrating a cloud resource management system with real AI (Claude), persistent storage, a policy engine, ML demand forecasting, and a full admin panel with role management.

What's New vs. the Original

Area Original Upgraded
Storage In-memory lists (resets on restart) JSON file-backed (persistent)
Secret key Hardcoded fallback secrets.token_hex random fallback
Admin role Self-assignable via form Server-side only; first user auto-promoted; admins promote/demote
Input validation int() with no error handling _safe_int() with bounds checking
AI Optimizer Hardcoded lookup table Real Claude API — free-text → structured recommendation
AI Assistant None Full multi-turn chat widget (sidebar)
Violation analysis None AI explains rejection + suggests compliant alternative
ML model Linear regression Linear regression + R² score reported
Cost tracking None Estimated monthly cost per resource
Resource types 3 5 (+ Database, Kubernetes Cluster)
Role management None Admin promote/demote UI

Tech Stack

  • Backend: Python Flask 3
  • Frontend: HTML + Tailwind CSS + Vanilla JS
  • Storage: JSON file-based (thread-safe)
  • ML: scikit-learn Linear Regression
  • AI: Anthropic Claude (claude-sonnet-4-20250514)
  • Auth: bcrypt + Flask sessions

Setup

pip install -r requirements.txt

Set your Anthropic API key (required for AI features):

export ANTHROPIC_API_KEY=sk-ant-...

Optionally set a stable secret key for sessions:

export SECRET_KEY=your-random-secret-here

Run

python app.py

App runs at http://127.0.0.1:5000

First Login

Register an account — the first registered user automatically becomes admin. All subsequent registrations are regular users. Admins can promote/demote from the Admin Panel.

AI Features

AI Optimizer (/optimizer)

Describe your workload in plain English. Claude returns:

  • Optimal resource type, CPU, RAM, storage, region
  • Reasoning explanation
  • Monthly cost estimate
  • Policy compliance warnings
  • Practical tips

AI Assistant (sidebar)

Click the robot icon in the sidebar for a multi-turn chat assistant. Aware of your resources and violations. Answers questions about cloud infrastructure, costs, sizing, and policy rules.

Violation Explainer (/violations)

Click "Explain" on any rejected request. Claude explains why it was rejected and suggests a fully compliant alternative configuration.

Project Structure

cppe/
├── app.py              # Flask routes + auth + API endpoints
├── policy_engine.py    # Configurable policy validation
├── data_storage.py     # Thread-safe JSON file storage
├── ml_model.py         # Linear regression demand forecaster
├── ai_advisor.py       # Claude API integration (optimize, chat, analyze)
├── requirements.txt
├── data/               # Auto-created; holds users.json etc.
└── templates/
    ├── base.html           # Layout + AI chat widget
    ├── login.html
    ├── register.html       # No role selection (security fix)
    ├── dashboard.html      # Stats, charts, ML forecast
    ├── request_resource.html
    ├── my_resources.html   # With per-resource cost estimate
    ├── violations.html     # With AI explanation button
    ├── optimizer.html      # Real AI optimizer
    └── admin.html          # Users, resources, role management

Policy Rules

Rule Limit
Max CPU 4 cores
Max RAM 8 GB
Max Storage 100 GB
Allowed Regions Asia, India
Allowed Types Virtual Machine, Storage, Container, Database, Kubernetes Cluster

Demo Flow

  1. Register (first account = auto admin)
  2. Log in
  3. Open AI Optimizer → describe a workload → get recommendation
  4. Open AI Assistant (sidebar robot icon) → ask a question
  5. Request Resource → submit a valid config → see it provisioned
  6. Submit a violating config → see it rejected
  7. Go to Violations → click "Explain" → see AI analysis
  8. Visit Dashboard → click "Run Model" → see 7-day ML forecast
  9. Visit Admin Panel → manage users, resources, roles

About

Self-service cloud resource portal with Flask, ML demand forecasting, and AI integration

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages