Back to Projects

Enetdocs Database

A Flask-based web application for managing and organizing academic resources from Google Drive with MongoDB integration

FlaskMongoDBGoogle Drive APIPython

Overview

ENET'Com Academic Archive is a comprehensive web application designed to streamline the management of academic resources for the ENET'Com institution. The project combines Flask, MongoDB, and Google Drive API to create a robust system for organizing and accessing educational materials across multiple programs, years, and semesters.

The Problem

Educational institutions often struggle with organizing and managing vast amounts of academic content spread across different programs and years. Students need an efficient way to browse, search, and access course materials, documents, and resources without getting lost in complex folder structures.

The Solution

This application provides a centralized platform that:

  • Automatically scrapes and organizes Google Drive folders containing academic materials
  • Stores hierarchical data in MongoDB for fast querying and retrieval
  • Provides an intuitive admin interface for managing content without touching code
  • Supports multiple academic programs (IDSD, GII, GT, GEC) across different years and semesters
  • Maintains file hierarchy while providing easy navigation and search capabilities

Key Features

1. Google Drive Integration

The application seamlessly connects to Google Drive to fetch and organize academic files. It intelligently processes folder structures and maintains metadata about each file.

python
def get_file_link(file_id, mime_type):
    """Generate a direct link to a Google Drive file based on its ID and MIME type."""
    if "folder" in mime_type:
        return f"https://drive.google.com/drive/folders/{file_id}"
    else:
        return f"https://drive.google.com/file/d/{file_id}/view?usp=drive_link"

2. MongoDB Database Architecture

The application uses MongoDB to store a flexible document structure that represents the hierarchical nature of academic content. Each document contains program, year, semester, and file metadata.

python
client = MongoClient('mongodb://localhost:27017/')
db = client['academic_files']
collection = db['files']

# Query with filters
query = {}
if program:
    query['program'] = program
if year and year.isdigit():
    query['year'] = int(year)
if semester:
    query['semester'] = semester

entries = list(collection.find(query).sort([('is_folder', -1), ('level', 1), ('name', 1)]))

3. Smart File Icon Detection

The system automatically assigns appropriate icons to different file types, making the interface more intuitive and visually appealing.

python
def get_file_icon(mime_type, name):
    """Determine the appropriate Font Awesome icon based on file type."""
    _, ext = os.path.splitext(name.lower())

    if ext in ['.pdf']:
        return "fas fa-file-pdf"
    elif ext in ['.py']:
        return "fab fa-python"
    elif ext in ['.java']:
        return "fab fa-java"
    # ... and more file types

4. Admin Interface

A user-friendly admin panel allows authorized users to:

  • View and edit JSON configuration files
  • Add new academic entries
  • Manage Google Drive folder links
  • Organize content by section, year, and semester

5. RESTful API

The Flask backend provides clean API endpoints for querying and managing academic resources:

python
@app.route('/list')
def list_entries():
    program = request.args.get('program', '')
    year = request.args.get('year', '')
    semester = request.args.get('semester', '')

    programs = collection.distinct('program')
    years = sorted(collection.distinct('year'))
    semesters = sorted(collection.distinct('semester'))

    return render_template('index.html',
                          programs=programs,
                          years=years,
                          semesters=semesters)

Technical Stack

  • Backend: Flask (Python web framework)
  • Database: MongoDB (NoSQL document database)
  • External API: Google Drive API for file management
  • Frontend: HTML templates with Jinja2 templating
  • Containerization: Docker Compose for easy deployment

Project Structure

The application follows a clean, modular architecture:

  • app.py - Main Flask application with routing and database queries
  • scrapers.py - Google Drive scraping functionality
  • driveapi.py - Google Drive API integration
  • admin_server.py - Admin interface server
  • import_data.py - Data import and migration utilities
  • templates/ - HTML templates for the web interface
  • static/data/ - JSON files for each program and year

Challenges & Learning

Building this project involved several interesting challenges:

  1. Hierarchical Data Modeling: Designing a MongoDB schema that efficiently represents nested folder structures while maintaining query performance
  2. Google Drive API Integration: Handling API rate limits and authentication while scraping large folder structures
  3. Dynamic Filtering: Creating a flexible query system that allows filtering by multiple parameters
  4. Data Consistency: Ensuring synchronization between JSON files and MongoDB documents

Future Enhancements

  • Implement user authentication and role-based access control
  • Add full-text search across all documents
  • Create a mobile-responsive frontend interface
  • Implement caching for frequently accessed resources
  • Add analytics to track most accessed materials

Deployment

The application can be easily deployed using Docker Compose, making it simple to set up in any environment with minimal configuration.


This project demonstrates proficiency in building full-stack web applications with Python, working with NoSQL databases, integrating third-party APIs, and creating maintainable, scalable code architectures.