Skip to content

ShynCode/Final-year-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± Subscription Management Website

A beginner-friendly web application to track and manage your subscriptions (Netflix, Amazon Prime, Gym memberships, etc.). Built with Flask (Python) and includes a Django alternative version.

✨ Features

  • βœ… User registration and login
  • βœ… Add, edit, and delete subscriptions
  • βœ… Dashboard showing all subscriptions
  • βœ… Monthly and yearly spending calculations
  • βœ… Automatic email notifications for upcoming renewals
  • βœ… Analytics page with charts
  • βœ… Mobile-friendly responsive design
  • βœ… Secure password hashing
  • βœ… SQLite database (development) or MySQL (production)

πŸš€ Quick Start Guide (For Beginners)

Step 1: Install Python

  1. Download Python from python.org
  2. Install Python (check "Add Python to PATH" during installation)
  3. Verify installation:
    python --version
    Should show: Python 3.x.x

Step 2: Create Virtual Environment

A virtual environment keeps your project dependencies separate:

# Navigate to project folder
cd FYPNew

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate

You should see (venv) in your terminal prompt.

Step 3: Install Dependencies

pip install -r requirements.txt

This installs all required packages (Flask, SQLAlchemy, etc.).

Step 4: Set Up Environment Variables

  1. Copy .env.example to .env:

    # On Windows:
    copy .env.example .env
    # On Mac/Linux:
    cp .env.example .env
  2. Edit .env file and add your settings:

    SECRET_KEY=your-random-secret-key-here
    DATABASE_URL=sqlite:///subscriptions.db
    MAIL_USERNAME=your-email@gmail.com
    MAIL_PASSWORD=your-gmail-app-password

    Note: For Gmail, you need an "App Password":

    • Go to Google Account β†’ Security β†’ 2-Step Verification β†’ App Passwords
    • Generate a password for "Mail"

Step 5: Run the Application

python run.py

You should see:

==================================================
Subscription Management Website
==================================================
Server starting on http://127.0.0.1:5000
Press CTRL+C to stop the server
==================================================

Step 6: Open in Browser

Open your web browser and go to:

http://127.0.0.1:5000

Step 7: Create Your Account

  1. Click "Register"
  2. Fill in username, email, and password
  3. Click "Register"
  4. You'll be redirected to login

Step 8: Add Sample Subscriptions

After logging in:

  1. Click "Add Subscription"
  2. Add these examples:
    • Netflix: $10/month, Next renewal: (30 days from today)
    • Amazon Prime: $6/month, Next renewal: (30 days from today)
    • Gym: $15/month, Next renewal: (30 days from today)

πŸ“ Project Structure

project/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py          # Flask app factory
β”‚   β”œβ”€β”€ routes.py             # URL routes and page handlers
β”‚   β”œβ”€β”€ models.py             # Database models (User, Subscription)
β”‚   β”œβ”€β”€ forms.py              # Form definitions
β”‚   β”œβ”€β”€ utils.py              # Helper functions (notifications, calculations)
β”‚   β”œβ”€β”€ templates/            # HTML templates
β”‚   β”‚   β”œβ”€β”€ layout.html
β”‚   β”‚   β”œβ”€β”€ register.html
β”‚   β”‚   β”œβ”€β”€ login.html
β”‚   β”‚   β”œβ”€β”€ dashboard.html
β”‚   β”‚   β”œβ”€β”€ subscription_form.html
β”‚   β”‚   └── analytics.html
β”‚   └── static/
β”‚       β”œβ”€β”€ css/style.css     # Stylesheet
β”‚       └── js/charts.js      # Chart utilities
β”œβ”€β”€ config.py                 # Configuration settings
β”œβ”€β”€ run.py                    # Application entry point
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ Procfile                  # For deployment (Heroku/Render)
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ tests/
β”‚   └── test_basic.py         # Basic tests
└── README.md                 # This file

πŸ”§ Configuration

Database

Development (SQLite):

  • No setup needed! SQLite is included with Python.
  • Database file: subscriptions.db (created automatically)

Production (MySQL):

  1. Install MySQL server
  2. Create database:
    CREATE DATABASE subscriptions_db;
  3. Update .env:
    DATABASE_URL=mysql+pymysql://username:password@localhost/subscriptions_db
  4. Install MySQL driver:
    pip install PyMySQL cryptography

Email Notifications

Email notifications are sent 3 days before subscription renewal.

Setup Gmail:

  1. Enable 2-Step Verification in Google Account
  2. Generate App Password: Security β†’ App Passwords β†’ Mail
  3. Add to .env:
    MAIL_USERNAME=your-email@gmail.com
    MAIL_PASSWORD=your-app-password

πŸ“Š Features Explained

Dashboard

  • Shows all your subscriptions in a table
  • Displays monthly and yearly totals
  • Highlights upcoming renewals (next 7 days)
  • Quick actions: Edit or Delete subscriptions

Analytics

  • Visual charts showing spending by category
  • Monthly vs Yearly spending comparison
  • Total subscription count

Notifications

  • Automatic email reminders 3 days before renewal
  • Runs daily at 9 AM (configurable in run.py)

🚒 Deployment Guide

Deploy to Render (Recommended - Easy!)

  1. Create Render Account:

  2. Create New Web Service:

    • Click "New" β†’ "Web Service"
    • Connect your GitHub repository
    • Or upload files manually
  3. Configure Settings:

    • Build Command: pip install -r requirements.txt
    • Start Command: gunicorn run:app
    • Python Version: 3.11
  4. Set Environment Variables:

    • Go to Environment tab
    • Add all variables from .env:
      • SECRET_KEY (generate random string)
      • DATABASE_URL (use Render's PostgreSQL or MySQL)
      • MAIL_USERNAME
      • MAIL_PASSWORD
  5. Deploy:

    • Click "Create Web Service"
    • Wait for deployment (2-3 minutes)
    • Your site is live!

Deploy to Heroku (Alternative)

  1. Install Heroku CLI:

  2. Login:

    heroku login
  3. Create App:

    heroku create your-app-name
  4. Set Environment Variables:

    heroku config:set SECRET_KEY=your-secret-key
    heroku config:set DATABASE_URL=your-database-url
    heroku config:set MAIL_USERNAME=your-email@gmail.com
    heroku config:set MAIL_PASSWORD=your-app-password
  5. Deploy:

    git push heroku main
  6. Open:

    heroku open

πŸ”’ Security Basics (Simple Explanation)

Password Hashing

  • What: Passwords are never stored as plain text
  • How: Uses Werkzeug's generate_password_hash() function
  • Why: If database is hacked, passwords can't be read

CSRF Protection

  • What: Prevents fake form submissions
  • How: Flask-WTF automatically adds hidden tokens to forms
  • Why: Stops attackers from submitting forms on your behalf

Environment Variables (.env)

  • What: Stores sensitive data (passwords, keys) outside code
  • How: Loaded from .env file (never commit to git!)
  • Why: Keeps secrets safe and allows different settings per environment

SQL Injection Prevention

  • What: Prevents malicious database queries
  • How: SQLAlchemy ORM automatically escapes inputs
  • Why: Protects your database from attacks

βœ… One-Page Checklist

  • Install Python 3.8+
  • Create virtual environment (python -m venv venv)
  • Activate virtual environment
  • Install dependencies (pip install -r requirements.txt)
  • Copy .env.example to .env and fill in values
  • Run application (python run.py)
  • Open browser to http://127.0.0.1:5000
  • Register a new account
  • Login with your account
  • Add your first subscription
  • View dashboard with subscription
  • Check analytics page
  • Test edit and delete functions
  • Verify email notifications (if configured)

🎀 Viva / Demo Script (4-5 Lines)

Demo Flow:

  1. Login - Show secure authentication system
  2. Add Subscription - Demonstrate adding Netflix subscription with form validation
  3. Dashboard Updates - Show how totals automatically calculate (monthly/yearly)
  4. Chart Updates - Display analytics page with visual spending breakdown
  5. Notification System - Explain automatic email reminders for upcoming renewals

πŸ§ͺ Running Tests

# Install pytest
pip install pytest

# Run tests
python -m pytest tests/

πŸ†š Flask vs Django Version

Flask Version (Main - Recommended for Beginners)

  • βœ… Simpler - Easier to understand
  • βœ… Flexible - More control over structure
  • βœ… Faster to learn - Less concepts
  • βœ… Better for small projects - Lightweight

Django Version (Alternative)

  • βœ… More structured - Follows conventions
  • βœ… Built-in admin - Automatic admin panel
  • βœ… More features - Includes ORM, auth, etc.
  • ⚠️ Steeper learning curve - More to learn

Recommendation: Start with Flask version if you're a beginner!

πŸ“ Sample Data

After creating your account, add these subscriptions:

Name Price Billing Cycle Category
Netflix $10 Monthly Streaming
Amazon Prime $6 Monthly Shopping
Gym Membership $15 Monthly Fitness

πŸ› Troubleshooting

"ModuleNotFoundError"

  • Solution: Make sure virtual environment is activated and dependencies are installed

"Port 5000 already in use"

  • Solution: Change port in run.py: app.run(port=5001)

"Email not sending"

  • Solution: Check Gmail App Password is correct, enable "Less secure app access" (if needed)

"Database errors"

  • Solution: Delete subscriptions.db and restart app (database will be recreated)

πŸ“š Learning Resources

πŸ“„ License

This project is open source and available for educational purposes.

πŸ‘€ Author

Created for Final Year Project (FYP) - Beginner-friendly subscription management system.


🎯 Quick Commands Reference

# Activate virtual environment
source venv/bin/activate  # Mac/Linux
venv\Scripts\activate      # Windows

# Install dependencies
pip install -r requirements.txt

# Run application
python run.py

# Run tests
python -m pytest tests/

# Create database (automatic on first run)
# Database file: subscriptions.db

Happy Coding! πŸš€

If you have questions or issues, check the troubleshooting section or review the code comments - everything is explained in beginner-friendly terms!

SubscriptionManagmentWeb

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors