Skip to content

Latest commit

Β 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Smart Campus Analytics Platform

An end-to-end data platform that ingests, processes, and analyzes synthetic higher education data, complete with AI-powered insights and automated reporting.

Campus Data Dashboard

Python Version License

πŸš€ Quick Start

# 1. Clone the repository
git clone https://github.com/jromer242/Campus_Data.git
cd Campus_Data

# 2. Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# 3. Install the package in development mode
pip install -e .

# 4. Start the API server
uvicorn src.api.campus_api:app --reload

Then visit http://localhost:8000/docs for interactive API documentation.


πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • SQLite (included with Python)
  • pip (Python package installer)
  • Git

πŸ› οΈ Installation

Step 1: Clone the Repository

git clone https://github.com/jromer242/Campus_Data.git
cd Campus_Data

Step 2: Create Virtual Environment

On macOS/Linux:

python3 -m venv .venv
source .venv/bin/activate

On Windows:

python -m venv .venv
.venv\Scripts\activate

Step 3: Install Dependencies

Option A - Install with setup.py (Recommended):

pip install -e .

Option B - Install with requirements.txt:

pip install -r requirements.txt

Option C - Install development dependencies:

pip install -e ".[dev]"

Step 4: Verify Installation

python -c "from src.database import Student, Course, Enrollment; print('βœ… Installation successful!')"

πŸš€ Running the Application

Start the API Server

uvicorn src.api.campus_api:app --reload

Alternative methods:

# Using Python module syntax
python -m uvicorn src.api.campus_api:app --reload

# Custom port
uvicorn src.api.campus_api:app --reload --port 8080

# Allow external access
uvicorn src.api.campus_api:app --reload --host 0.0.0.0

The server will start at http://localhost:8000

Access Points

Run the Dashboard

In a new terminal window (keep the API running):

cd Campus_Data
source .venv/bin/activate  # Activate venv
python dashboard.py

πŸ“Š Project Structure

Campus_Data/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── campus_api.py        # Main FastAPI application
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ __init__.py          # Database models (Student, Course, Enrollment)
β”‚   β”‚   └── connection.py        # Database connection and session management
β”‚   β”œβ”€β”€ ml/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── student_predictor.py # ML prediction models
β”‚   └── data_generation/
β”œβ”€β”€ models/                       # Trained ML models
β”œβ”€β”€ notebooks/                    # Jupyter notebooks
β”œβ”€β”€ tests/                        # Unit tests
β”œβ”€β”€ campus_data.db               # SQLite database
β”œβ”€β”€ dashboard.py                 # Dashboard application
β”œβ”€β”€ setup.py                     # Package setup configuration
β”œβ”€β”€ requirements.txt             # Python dependencies
└── README.md                    # This file

πŸ”§ API Endpoints

Health & Info

  • GET / - API root with basic information
  • GET /health - Health check and system status

Students

  • GET /students - List all students (with pagination and filters)
  • GET /students/{student_id} - Get specific student
  • POST /students - Create new student
  • GET /students/{student_id}/enrollments - Get student enrollments

Courses

  • GET /courses - List all courses
  • GET /courses/{course_id} - Get specific course

Enrollments

  • GET /enrollments - List all enrollments

Predictions (ML)

  • POST /predict - Predict student success with custom data
  • GET /predict/student/{student_id} - Predict success for existing student

Statistics

  • GET /stats/overview - Get overview statistics

For complete API documentation with examples, visit http://localhost:8000/docs after starting the server.


πŸ§ͺ Testing the API

Using the Interactive Docs

Visit http://localhost:8000/docs and use the "Try it out" button on any endpoint.

Using curl

# Health check
curl http://localhost:8000/health

# Get students
curl http://localhost:8000/students?limit=5

# Get specific student
curl http://localhost:8000/students/S12345

# Predict success
curl -X POST http://localhost:8000/predict \
  -H "Content-Type: application/json" \
  -d '{
    "gpa": 3.5,
    "year_level": 2,
    "total_enrollments": 10,
    "completed_courses": 8,
    "dropped_courses": 1,
    "completion_rate": 80.0
  }'

Using Python

import requests

# Get health status
response = requests.get("http://localhost:8000/health")
print(response.json())

# Get students
response = requests.get("http://localhost:8000/students?limit=5")
students = response.json()
print(f"Found {len(students)} students")

Using the API Tester Script

python api_tester.py

πŸ” Features

  • RESTful API with FastAPI
  • SQLite Database with SQLAlchemy ORM
  • Student Management - CRUD operations for students, courses, and enrollments
  • ML Predictions - Student success prediction with risk assessment
  • Data Analytics - Statistical overview and insights
  • Interactive Documentation - Auto-generated API docs with Swagger UI
  • CORS Support - Ready for frontend integration
  • Type Validation - Pydantic models for request/response validation

πŸ› Troubleshooting

ImportError: cannot import name 'DatabaseSession'

Make sure src/database/connection.py has the DatabaseSession class. If missing, check the installation.

Port Already in Use

# Use a different port
uvicorn src.api.campus_api:app --reload --port 8080

Database Not Found

The SQLite database should be created automatically. If issues persist:

python -c "from src.database.connection import init_database; init_database()"

Module Not Found Errors

# Reinstall in development mode
pip install -e .

πŸ§‘β€πŸ’» Development

Running Tests

pytest tests/

Code Formatting

black src/

Type Checking

mypy src/

πŸ“ Configuration

Database Configuration

Edit src/database/connection.py to change the database:

# For PostgreSQL
DATABASE_URL = "postgresql://user:password@localhost/dbname"

# For MySQL
DATABASE_URL = "mysql+pymysql://user:password@localhost/dbname"

API Configuration

Modify settings in src/api/campus_api.py:

app = FastAPI(
    title="Campus Data API",
    version="1.0.0",
    # Add your custom settings
)

🀝 Contributing

  1. Fork the repository
  2. Create a 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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘€ Author

Your Name


πŸ™ Acknowledgments

  • FastAPI for the excellent web framework
  • SQLAlchemy for database ORM
  • All contributors and supporters

πŸ“ž Support

If you have any questions or run into issues:

  1. Check the API Documentation (after starting the server)
  2. Review the Troubleshooting section
  3. Open an Issue
  4. Contact the maintainer

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages