Share Store is a web-based file sharing and storage application built using Django and Python for the backend, and JavaScript and Bootstrap for the frontend. It is the final project for CS50's Web Programming with Python and JavaScript. This project contains a single app 'drive'.
Share Store allows users to register, log in, upload files, and manage access permissions for those files. Users can share their files with specific individuals or make them accessible to everyone. Additionally, users can view files shared with them by others. Share Store employs Firebase Storage for file storage and retrieval. It provides features like user authentication, file upload/download, access control, password change, and account deletion, making it a versatile file-sharing platform.
- Discord Integration: Enhanced the platform with a new feature that automates the process of uploading files
(college lecture slides in my case)
to Discord. Now, when users upload files containing specific keywords (e.g., lecture names or topics like Math or TOC) from their accounts, these files are automatically sent to a designated Discord channel, as specified in the environment variables. This integration eliminates the need for manual file transfers, saving time and ensuring that the content is promptly shared with the relevant Discord community.
Screenshots
Note
The screenshot below demonstrates the Discord integration feature, specifically how the bot posts files to a designated thread/channel on your Discord server. This functionality is triggered by the CHANNEL_MAPPINGS
configuration, such as including "Maths": "maths thread/channel ID"
to direct math-related files to the appropriate Discord location.
Project demo video is a bit old, so it does not showcase this feature.
- Distinctiveness:
- Unique Purpose: Share Store specializes in secure file sharing and storage, setting it apart from traditional social networks or e-commerce sites.
- Targeted File Sharing: Its main focus is on organized file sharing, not social interactions or product sales. The recent addition of Discord integration for file (automatic lecture slide) uploads further enhances its role as a specialized platform for content sharing.
- Firebase Integration: Share Store integrates with Firebase Storage, enhancing file management.
- Complexity:
- Django Backend: Utilizes Django for user authentication, file metadata, and access control.
- JavaScript and Bootstrap: Employs JavaScript and Bootstrap for a responsive frontend.
- User Authentication: Implements secure user registration and login.
- File Management: Handles complex tasks like file uploads, downloads, and access permissions.
-
static/drive
: Contains JavaScript for handling access permissions, the application's logo, and a stylesheet for styling. -
templates/drive
: Contains HTML templates responsible for rendering web pages. -
firebase.py
: Initializes the Firebase Admin SDK and creates a reference to Firebase Storage. -
models.py
: Defines data models for the application, includingFile
,User
, andShare
. -
tests.py
: Includes database tests for creating files, shares, and users. -
urls.py
: Defines URL patterns for the 'drive' app. -
utils.py
: Contains a utility function for iterating over files fetched from external URLs. -
views.py
: Houses view functions that handle HTTP requests and define how web pages are rendered. -
discord_integration.py
: Manages the automation of uploading files to a specified Discord channel based on certain criteria, utilizing the Discord API. -
requirements.txt
: Lists external Python packages and dependencies required for the project.
-
Create a Virtual Environment (Optional): If you prefer to work within a virtual environment (recommended for isolation), you can create and activate one. Navigate to your project directory and run the following commands:
# Create a virtual environment python -m venv myenv # Activate the virtual environment (Windows) myenv\Scripts\activate # Activate the virtual environment (macOS/Linux) source myenv/bin/activate
-
Install Requirements: Make sure you have Python installed on your system. Navigate to your project directory and install the required Python packages listed in
requirements.txt
. You can do this usingpip
:pip install -r requirements.txt
-
Create .env File: Create a file named .env in your project directory. In the .env file, add the following lines, replacing placeholder values with your actual configuration details:
STORAGE_BUCKET="Storage Bucket Name" GOOGLE_APPLICATION_CREDENTIALS="Path to your Firebase Admin SDK JSON credential file" SECRET_KEY="Your Django secret key" CONNECTION_STRING="Your database connection string (production only)" SERVER_ID="Your Discord Server ID" BOT_TOKEN="Your Discord Bot Token" CHANNEL_MAPPINGS={"substring_1": "Channel_ID_1", "substring_2": "Channel_ID_2"} P_USERNAME="Specific platform username whose files will be checked for Discord posting."
Each of these variables serves a specific purpose in your application, such as connecting to databases, integrating with Discord, and configuring Firebase services.
Tip
If you want to look for more substrings, just add the mapping in the CHANNEL_MAPPINGS
environment variable like so: CHANNEL_MAPPINGS={"substring_1": "Channel_ID_1", "substring_2": "Channel_ID_2", "additional_substring": "Additional_Channel_ID"}
.
Note
You should obtain the Firebase Admin SDK JSON credential file from your Firebase project settings. If you haven't already created a Firebase project, you can do so here: Firebase Console
Additionally, for setting up and obtaining your Discord Bot Token, refer to the Discord Developer Portal. Detailed instructions for creating a bot and inviting it to your server can be found here: Discord Developer Portal.
- Database Migrations:
Run the following commands to create and apply database migrations:
python manage.py makemigrations
python manage.py migrate
- Run the Server:
Finally, start the development server with the following command:
python manage.py runserver
- Access the Application: Open a web browser and navigate to `http://localhost:8000`` to access the Share Store application.
- Create a Firebase Project:
- Go to the Firebase Console.
- Click "Add project" to create a new project.
- Follow the setup instructions, including choosing a project name and enabling Google Analytics if needed.
- Navigate to Project Settings:
- After creating the project, click the gear icon (settings) next to "Project Overview" in the left sidebar.
- Select "Project settings" from the dropdown.
- Add an App to Your Project:
- After creating the project, click the gear icon (settings) next to "Project Overview" in the left sidebar.
- Select "Project settings" from the dropdown.
- Generate JSON Service Account Key:
- In your Firebase project settings, go to the "Service accounts" tab.
- Under "Firebase Admin SDK," click "Generate new private key."
- Download the JSON key file containing your credentials.
- Use the JSON Key File:
- Set the
GOOGLE_APPLICATION_CREDENTIALS
environment variable in your Share Store's.env
file to the path of the downloaded JSON key file.
- Set the
We welcome contributions to Share Store! To get started, please read our Contributing Guidelines and follow the instructions for submitting issues and pull requests.
Please read our Code of Conduct to understand our expectations for participants and contributors.