I want to make report for my final year project

The project name is Encrypted Cloud Storage & Symmetric Searchable Encryption

And the code are given below

Main.py

from flask import Flask, request, render_template, redirect, url_for, flash, send_file
from flask_login import LoginManager, login_user, login_required, logout_user, current_user
from flask_sqlalchemy import SQLAlchemy
from werkzeug.security import generate_password_hash, check_password_hash
from encryption_utils import make_key, encrypt_text, decrypt_text
from sse import SearchableEncryption
from flask_login import UserMixin
import os, time

─── App & DB Setup ─────────────────────────────────────────────────────────────
app = Flask(name)
app.secret_key = "CHANGE_THIS_TO_A_RANDOM_SECRET"
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///users.db'
db = SQLAlchemy(app)

login_mgr = LoginManager()
login_mgr.login_view = "login"
login_mgr.init_app(app)

─── Models ──────────────────────────────────────────────────────────────────────
class User(UserMixin,db.Model):
tablename = "users"
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
pw_hash = db.Column(db.String(128), nullable=False)
role = db.Column(db.String(20), nullable=False) # "admin" or "user"
active = db.Column(db.Boolean, default=True)


def set_password(self, password):
    self.pw_hash = generate_password_hash(password)

def check_password(self, password):
    return check_password_hash(self.pw_hash, password)

def is_active(self):
    return self.active
─── Encryption / SSE Setup ────────────────────────────────────────────────────
PASSPHRASE = "NinjaAi@123"
AES_KEY = make_key(PASSPHRASE)
sse_engine = SearchableEncryption()
os.makedirs('uploads', exist_ok=True)

track admin‑encrypted files
ENCRYPTED_FILES = []

─── Flask‑Login User Loader ───────────────────────────────────────────────────
@login_mgr.user_loader
def load_user(user_id):
return User.query.get(int(user_id))

─── Authentication Routes ─────────────────────────────────────────────────────
@app.route('/login', methods=['GET','POST'])
def login():
if request.method == 'POST':
u = User.query.filter_by(username=request.form['username']).first()
if u and u.check_password(request.form['password']):
if not u.active:
flash("Your account is disabled.")
return redirect(url_for('login'))
login_user(u)
return redirect(url_for('admin') if u.role=='admin' else url_for('index'))
flash("Invalid credentials.")
return render_template('login.html')

@app.route('/logout')
@login_required
def logout():
logout_user()
return redirect(url_for('login'))

─── Admin Dashboard & User Management ────────────────────────────────────────
@app.route('/admin', methods=['GET','POST'])
@login_required
def admin():
if current_user.role != 'admin':
flash("Admins only.")
return redirect(url_for('index'))


if request.method == 'POST':
    uname = request.form['username']
    pwd   = request.form['password']
    role  = request.form['role']
    if User.query.filter_by(username=uname).first():
        flash("Username exists.")
    else:
        newu = User(username=uname, role=role)
        newu.set_password(pwd)
        db.session.add(newu)
        db.session.commit()
        flash(f"User {uname} created.")
users = User.query.all()
return render_template('admin.html',
                       users=users,
                       encrypted_files=ENCRYPTED_FILES,
                       role=current_user.role)
─── Main User View ────────────────────────────────────────────────────────────
@app.route('/')
@login_required
def index():
return render_template('index.html',
role=current_user.role,
encrypted_files=ENCRYPTED_FILES)

─── Encryption Route (Admin Only) ────────────────────────────────────────────
@app.route('/encrypt', methods=['POST'])
@login_required
def encrypt_file():
if current_user.role != 'admin':
flash("Only admins may encrypt new files.")
return redirect(url_for('index'))


f = request.files['file']
fname = f.filename
out_name = f"{current_user.username}_{int(time.time())}_{fname}"
data = f.read().decode('utf-8')
cipher = encrypt_text(data, AES_KEY)
path = os.path.join('uploads', out_name)
with open(path, 'wb') as o:
    o.write(cipher)
ENCRYPTED_FILES.append(out_name)
return render_template('result.html', message=f"Encrypted saved as {out_name}")
─── Decryption Route ──────────────────────────────────────────────────────────
@app.route('/decrypt', methods=['POST'])
@login_required
def decrypt_file():
fn = request.form.get('file_select')
if not fn or fn not in ENCRYPTED_FILES:
plain = "Invalid file selection."
else:
with open(os.path.join('uploads', fn), 'rb') as f:
try:
plain = decrypt_text(f.read(), AES_KEY)
except Exception as e:
plain = f"Error: {e}"
return render_template('result.html', message=plain)

─── SSE Encrypt & Index File ─────────────────────────────────────────────────
@app.route('/sse_encrypt_file', methods=['POST'])
@login_required
def sse_encrypt_file():
f = request.files['file']
text = f.read().decode('utf-8')
sse_engine.encrypt(f.filename, text)
return render_template('result.html', message=f"{f.filename} indexed.")

─── SSE Search ───────────────────────────────────────────────────────────────
@app.route('/sse_search', methods=['POST'])
@login_required
def sse_search():
kw = request.form['keyword']
res = sse_engine.search(kw)
if res:
msg = "

" + "".join(f"
{doc}: {txt}
" for doc,txt in res.items()) + "
"
else:
msg = "No matches"
return render_template('result.html', message=msg)
─── Startup: Create DB + Default Admin ────────────────────────────────────────
if name == 'main':
with app.app_context():
db.create_all()
if not User.query.filter_by(username="admin").first():
admin = User(username="admin", role="admin", active=True)
admin.set_password("SuperSecret123")
db.session.add(admin)
db.session.commit()
print("🚀 Default admin created → username: admin | password: SuperSecret123")
app.run(debug=True)

sse.py

import hashlib
from cryptography.fernet import Fernet

class SearchableEncryption:
    def __init__(self):
        self.key = Fernet.generate_key()
        self.cipher = Fernet(self.key)
        self.encrypted_data = {}   # doc_id → bytes
        self.index = {}            # hashed_word → set(doc_id)

    def _hash(self, keyword: str) -> str:
        return hashlib.sha256(keyword.encode()).hexdigest()

    def encrypt(self, doc_id: str, text: str):
        token = self.cipher.encrypt(text.encode())
        self.encrypted_data[doc_id] = token
        for w in set(text.lower().split()):
            h = self._hash(w)
            self.index.setdefault(h, set()).add(doc_id)

    def search(self, keyword: str) -> dict:
        h = self._hash(keyword.lower())
        docs = {}
        for doc_id in self.index.get(h, ()):
            pt = self.cipher.decrypt(self.encrypted_data[doc_id]).decode()
            docs[doc_id] = pt
        return docs

models.py

from flask_sqlalchemy import SQLAlchemy
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash

db = SQLAlchemy()

class User(UserMixin, db.Model):
    __tablename__ = "users"
    id       = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    pw_hash  = db.Column(db.String(128), nullable=False)
    role     = db.Column(db.String(20), nullable=False)   # "admin" or "user"
    active   = db.Column(db.Boolean, default=True)

    def set_password(self, password):
        self.pw_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.pw_hash, password)

    def is_active(self):
        return self.active

encryption.py

import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES

def pad_(s, bs=16):
    return s + (bs - len(s) % bs) * chr(bs - len(s) % bs)

def unpad_(s):
    return s[:-ord(s[len(s) - 1:])]

# derive a 256‑bit AES key from your passphrase
def make_key(passphrase: str):
    return hashlib.sha256(passphrase.encode()).digest()

def encrypt_text(text: str, key: bytes) -> bytes:
    raw = pad_(text)
    iv = Random.new().read(AES.block_size)
    cipher = AES.new(key, AES.MODE_CBC, iv)
    return base64.b64encode(iv + cipher.encrypt(raw.encode()))

def decrypt_text(cipher_bytes: bytes, key: bytes) -> str:
    data = base64.b64decode(cipher_bytes)
    iv = data[:AES.block_size]
    cipher = AES.new(key, AES.MODE_CBC, iv)
    decrypted = cipher.decrypt(data[AES.block_size:])
    return unpad_(decrypted).decode('utf-8')


So extract this code and generate this points
- Abstract
- Introduction
- Literature Survey/Feasibility Study
- Problem Statement
- Solution Approach/Design/Architecture Diagram/Data Flow
- Algorithms(If any)
- Implementation Details
- Results Obtained
- Future Plan
- Conclusion
- References


I need all this points in text and latex code also