# A+ Academy - Tutoring Company Website

A professional Flask-based website for A+ Academy, offering tutoring services for Grade 10-12 Science and Computer Applications Technology (CAT) subjects, including Grade 12 rewrite and upgrade programs.

## Features

### Frontend
- **Modern Soft-UI Design**: Professional blue and platinum white color scheme with soft shadows and hover effects
- **Responsive Layout**: Bootstrap 5 framework ensuring mobile-first design
- **Subject Showcase**: Display of Grade 10, 11, 12, and Rewrite/Upgrade subjects
- **Contact Form**: Functional contact form with email notifications
- **About Page**: Company information and team showcase

### Admin Portal
- **Secure Authentication**: Login system with session management
- **Dashboard**: Overview of messages, subjects, and site statistics
- **Message Management**: View, reply to, and manage contact form submissions
- **Content Management**: Edit frontend content dynamically
- **Subject Management**: Add, edit, activate/deactivate subjects
- **Email Integration**: Reply to messages directly from admin panel


## Technology Stack
- **Backend**: Python 3, Flask
- **Database**: SQLAlchemy (SQLite default, PostgreSQL/MySQL compatible)
- **Frontend**: HTML5, CSS3, Bootstrap 5, Jinja2 Templates
- **Authentication**: Flask-Login, Werkzeug Security
- **Forms**: Flask-WTF, WTForms
- **Email**: Flask-Mail
- **Icons**: Bootstrap Icons

## Installation

1. Clone the repository:
```bash
cd a_plus_academy
```

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

3. Install dependencies:
```bash
pip install -r requirements.txt
```

4. Configure environment variables:
```bash
cp .env.example .env
# Edit .env with your configuration
```

5. Run the application:
```bash
python run.py
```

6. Access the website:
- Frontend: http://localhost:5000
- Admin Panel: http://localhost:5000/admin/login
  - Default credentials: username: `admin`, password: `admin123`
  - **Change these immediately in production!**

## Email Configuration

To enable email notifications and replies:

### Gmail Setup:
1. Enable 2-Factor Authentication on your Gmail account
2. Generate an App Password at: Google Account > Security > App Passwords
3. Use the generated password in MAIL_PASSWORD

### Other Providers:
Update MAIL_SERVER, MAIL_PORT, and MAIL_USE_TLS according to your provider's settings.

## Project Structure

```
a_plus_academy/
├── app/
│   ├── __init__.py          # App factory and initialization
│   ├── models.py            # Database models
│   ├── forms.py             # WTForms classes
│   ├── routes.py            # Frontend routes
│   ├── admin_routes.py      # Admin portal routes
│   ├── email_service.py     # Email functionality
│   ├── static/
│   │   ├── css/
│   │   ├── js/
│   │   └── uploads/
│   └── templates/
│       ├── base.html
│       ├── index.html
│       ├── about.html
│       ├── subjects.html
│       ├── contact.html
│       ├── success.html
│       └── admin/
│           ├── login.html
│           ├── dashboard.html
│           ├── messages.html
│           ├── view_message.html
│           ├── reply.html
│           ├── content.html
│           ├── content_form.html
│           ├── subjects.html
│           └── subject_form.html
├── config.py                # Configuration settings
├── run.py                   # Application entry point
├── requirements.txt         # Python dependencies
├── .env.example            # Environment variables template
└── README.md               # This file
```

## Database Models

### Admin
- User authentication for admin portal
- Username, email, password hash

### Subject
- Subject name, code, description
- Grade level (10, 11, 12, rewrite)
- Icon, color theme, display order
- Active/inactive status

### ContactMessage
- Name, email, phone, subject, message
- Read/unread status
- Reply tracking with timestamps

### SiteContent
- Dynamic content sections (hero, about, etc.)
- Key-value storage for editable content
- Content type support (text, html, image)

## Security Features

- CSRF protection on all forms
- Password hashing with Werkzeug
- Session-based authentication
- SQL injection protection via SQLAlchemy ORM
- XSS protection through Jinja2 auto-escaping

## Customization

### Adding Subjects
1. Log in to admin panel
2. Navigate to Subjects
3. Click "Add Subject"
4. Fill in details (name, code, grade level, etc.)
5. Choose an icon from Bootstrap Icons

### Editing Content
1. Go to Site Content in admin panel
2. Add or edit content sections
3. Use keys like `hero_title`, `about_text` for specific sections
4. Access in templates via `content(section, key, default)`

### Styling
- Main colors defined in CSS variables in base.html
- Modify `--primary-blue`, `--platinum`, etc.
- Soft shadows and transitions customizable

## Production Deployment

1. Set `DEBUG=False` in config
2. Use a production WSGI server (Gunicorn, uWSGI)
3. Use PostgreSQL/MySQL instead of SQLite
4. Set strong SECRET_KEY
5. Configure proper email settings
6. Use HTTPS
7. Change default admin credentials

Example Gunicorn command:
```bash
gunicorn -w 4 -b 0.0.0.0:8000 "run:create_app()"
```

## License

This project is proprietary software for A+ Academy.

## Support

For support or inquiries, contact info@aplusacademy.co.za
