Skip to content

shiroonigami23-ui/Share-Study

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š StudyShare - Study Material Sharing Platform

A complete full-stack web application for sharing study materials with community chat, user profiles, and admin controls. It now includes an assembly learning toolkit (asm/) for low-level systems study.

🌟 Features

For All Users:

  • βœ… User registration and login
  • πŸ“€ Upload study materials (PDFs, images, documents, etc.)
  • πŸ“₯ Download shared files
  • πŸ’¬ Community chat for discussions
  • πŸ‘€ User profiles with customizable profile pictures
  • πŸ† Achievement badges based on contributions
  • πŸ” Search and filter files
  • πŸ“Š Personal statistics (uploads, messages)

For Admin (ShiroOni):

  • πŸ—‘οΈ Delete any user's files
  • πŸ—‘οΈ Delete any user's messages
  • πŸ‘‘ Admin badge on profile
  • πŸ›‘οΈ Full moderation capabilities

πŸ“ Project Structure

StudyShare_App/
β”œβ”€β”€ frontend/           # Client-side application
β”‚   β”œβ”€β”€ index.html     # Main HTML file
β”‚   β”œβ”€β”€ styles.css     # Styling
β”‚   └── app.js         # Frontend logic
β”‚
β”œβ”€β”€ backend/           # Server-side application
β”‚   β”œβ”€β”€ server.js      # Main server file
β”‚   β”œβ”€β”€ package.json   # Node.js dependencies
β”‚   β”œβ”€β”€ .env          # Environment variables
β”‚   β”œβ”€β”€ config/       # Database configuration
β”‚   β”œβ”€β”€ routes/       # API routes
β”‚   β”œβ”€β”€ middleware/   # Authentication middleware
β”‚   └── uploads/      # File storage
β”‚
└── database/         # Database files
    β”œβ”€β”€ schema.sql    # Database schema
    β”œβ”€β”€ init_admin.js # Admin initialization
    └── README.md     # Database setup guide

β”œβ”€β”€ asm/              # Assembly language enrichment toolkit
β”‚   β”œβ”€β”€ x86_64/       # NASM sources
β”‚   β”œβ”€β”€ aarch64/      # ARM64 sources
β”‚   β”œβ”€β”€ build.sh      # Build helper
β”‚   └── README.md     # Assembly docs

πŸš€ Installation & Setup

Prerequisites

  • Node.js (v14 or higher)
  • MySQL or MariaDB
  • npm or yarn

Step 1: Database Setup

  1. Install MySQL/MariaDB
  2. Create database:
mysql -u root -p
CREATE DATABASE studyshare_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
exit;
  1. Import schema:
cd database
mysql -u root -p studyshare_db < schema.sql
  1. Initialize admin user:
node init_admin.js

Step 2: Backend Setup

  1. Navigate to backend folder:
cd backend
  1. Install dependencies:
npm install
  1. Configure .env file:
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_mysql_password
DB_NAME=studyshare_db
DB_PORT=3306

PORT=3000
NODE_ENV=development

JWT_SECRET=change_this_to_random_secret_key

MAX_FILE_SIZE=10485760
UPLOAD_DIR=uploads
  1. Start backend server:
npm start

The API will be available at http://localhost:3000

Step 3: Frontend Setup

  1. Open frontend/app.js and verify API_BASE_URL:
const API_BASE_URL = 'http://localhost:3000/api';
  1. Serve the frontend:

Option A - Using Python:

cd frontend
python -m http.server 8080

Option B - Using Node.js:

npm install -g http-server
cd frontend
http-server -p 8080

Option C - Using VS Code Live Server:

  • Install Live Server extension
  • Right-click on index.html
  • Select "Open with Live Server"
  1. Access the application at http://localhost:8080

πŸ” Admin Credentials

  • Username: ShiroOni
  • Password: Shiro

🌐 AWS Deployment Guide

Prerequisites for AWS:

  • AWS Account
  • EC2 instance (Ubuntu recommended)
  • Security Group configured for ports: 22, 80, 443, 3000, 8080

Deployment Steps:

1. Launch EC2 Instance

  • Choose Ubuntu Server 20.04 LTS or higher
  • t2.micro or larger
  • Configure security group to allow HTTP (80), HTTPS (443), and custom ports

2. Connect to EC2 and Install Dependencies

# Update system
sudo apt update && sudo apt upgrade -y

# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

# Install MySQL
sudo apt install -y mysql-server

# Secure MySQL
sudo mysql_secure_installation

3. Upload Application Files

# From your local machine
scp -r StudyShare_App ubuntu@your-ec2-ip:/home/ubuntu/

Or use Git:

# On EC2 instance
git clone your-repository-url
cd StudyShare_App

4. Setup Database on EC2

sudo mysql -u root -p
CREATE DATABASE studyshare_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'studyshare_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON studyshare_db.* TO 'studyshare_user'@'localhost';
FLUSH PRIVILEGES;
exit;

# Import schema
cd database
mysql -u root -p studyshare_db < schema.sql

# Initialize admin
node init_admin.js

5. Configure Backend

cd backend
npm install

# Update .env with production settings
nano .env

Update .env:

DB_HOST=localhost
DB_USER=studyshare_user
DB_PASSWORD=secure_password
DB_NAME=studyshare_db

PORT=3000
NODE_ENV=production

JWT_SECRET=generate_random_secret_here

6. Setup Process Manager (PM2)

# Install PM2
sudo npm install -g pm2

# Start backend
cd backend
pm2 start server.js --name studyshare-api

# Set PM2 to start on boot
pm2 startup
pm2 save

7. Setup Nginx for Frontend

# Install Nginx
sudo apt install -y nginx

# Create Nginx configuration
sudo nano /etc/nginx/sites-available/studyshare

Nginx config:

server {
    listen 80;
    server_name your-domain.com;  # or EC2 public IP

    # Frontend
    location / {
        root /home/ubuntu/StudyShare_App/frontend;
        index index.html;
        try_files $uri $uri/ /index.html;
    }

    # API proxy
    location /api {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    # Uploads
    location /uploads {
        proxy_pass http://localhost:3000;
    }
}

Enable site:

sudo ln -s /etc/nginx/sites-available/studyshare /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

8. Configure Firewall

sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable

9. Setup SSL (Optional but Recommended)

# Install Certbot
sudo apt install -y certbot python3-certbot-nginx

# Get SSL certificate
sudo certbot --nginx -d your-domain.com

Accessing Your Application

  • Frontend: http://your-ec2-ip or http://your-domain.com
  • API: http://your-ec2-ip/api or http://your-domain.com/api

πŸ“Š API Endpoints

Authentication

  • POST /api/auth/signup - Register new user
  • POST /api/auth/login - User login

Files

  • GET /api/files - Get all files
  • POST /api/files/upload - Upload file
  • GET /api/files/download/:id - Download file
  • DELETE /api/files/:id - Delete file

Chat

  • GET /api/chat/messages - Get all messages
  • POST /api/chat/send - Send message
  • DELETE /api/chat/messages/:id - Delete message

Users

  • GET /api/users/profile - Get user profile
  • POST /api/users/profile-image - Upload profile image

πŸ› οΈ Technologies Used

Frontend:

  • HTML5
  • CSS3 (with modern gradients and animations)
  • Vanilla JavaScript (ES6+)
  • Fetch API for HTTP requests

Backend:

  • Node.js
  • Express.js
  • MySQL2
  • JWT for authentication
  • Bcrypt for password hashing
  • Multer for file uploads

Database:

  • MySQL/MariaDB

🎨 Features in Detail

Badge System

Users earn badges based on contributions:

  • 🌟 First Upload - Upload first file
  • πŸ“š Knowledge Sharer - Upload 5 files
  • πŸ† Top Contributor - Upload 10 files
  • πŸ’Ž Elite Member - Upload 20 files
  • πŸ‘‘ Administrator - Admin role

File Type Support

  • πŸ“„ PDFs
  • πŸ–ΌοΈ Images (JPG, PNG, GIF, WebP)
  • πŸ“ Documents (DOC, DOCX, TXT)
  • πŸŽ₯ Videos (MP4, AVI, MOV)
  • 🎡 Audio (MP3, WAV, OGG)
  • πŸ“¦ Archives (ZIP, RAR, 7Z)
  • πŸ’» Code files (JS, PY, JAVA, etc.)

πŸ”’ Security Features

  • Password hashing with bcrypt
  • JWT-based authentication
  • File size limits
  • SQL injection protection
  • XSS protection
  • CORS configured
  • Admin-only routes protected

πŸ› Troubleshooting

Backend won't start

  • Check if MySQL is running
  • Verify .env configuration
  • Ensure database exists
  • Check if port 3000 is available

Frontend can't connect to backend

  • Verify backend is running
  • Check API_BASE_URL in app.js
  • Check browser console for CORS errors
  • Ensure CORS is enabled in backend

File upload fails

  • Check file size limits
  • Verify uploads directory exists and is writable
  • Check disk space

Database connection errors

  • Verify MySQL credentials
  • Check if database exists
  • Ensure MySQL is running
  • Check firewall settings

πŸ“ License

MIT License - Feel free to use for educational purposes

πŸ‘¨β€πŸ’» Developer

Created by ShiroOni

🀝 Contributing

This is a complete educational project. Feel free to fork and enhance!


Happy Studying! πŸ“šβœ¨

About

Full-stack-study-sharing-platform-with-assembly-learning-toolkit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors