Skip to content

A full-stack photo storage and sharing application built using React, Node.js, MySQL, and styled with Tailwind CSS. Photopia allows users to securely upload, store, and share their photos with a clean and modern user interface.

License

Notifications You must be signed in to change notification settings

rsayyed591/photopia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Photopia πŸ“Έ

A full-stack photo storage and sharing application built using React, Node.js, MySQL, and styled with Tailwind CSS. Photopia allows users to securely upload, store, and share their photos with a clean and modern user interface.


Author

Rehan Feroz Sayyed


Features

  • User authentication (Login/Registration).
  • Secure JWT authentication.
  • Upload photos to the platform.
  • Simple, responsive UI built with Tailwind CSS.
  • Dark mode for enhanced user experience.

File Structure

Photopia/
β”‚
β”œβ”€β”€ user-backend/                      # Backend code
β”‚   β”œβ”€β”€ config/                        # Database configuration
β”‚   β”‚   └── db.js                      # MySQL database setup
β”‚   β”œβ”€β”€ controllers/                   # Backend logic for authentication and file uploads
β”‚   β”‚   └── fileController.js          # Logic for handling file uploads
β”‚   β”œβ”€β”€ models/                        # Models for user data and file storage
β”‚   β”‚   └── User.js                    # User model for authentication
β”‚   β”œβ”€β”€ routes/                        # API routes for user management and file uploads
β”‚   β”‚   └── fileRoutes.js              # Routes for file upload functionality
β”‚   β”‚   └── jwtMiddleware.js           # Middleware to protect routes with JWT authentication
β”‚   β”‚   └── login.js                   # Login route
β”‚   β”‚   └── register.js                # Registration route
β”‚   β”‚   └── User.js                    # User API routes
β”‚   β”œβ”€β”€ index.js                       # Entry point for the backend
β”‚   β”œβ”€β”€ package.json                   # Backend dependencies and scripts
β”‚   └── .env                           # Environment variables for the backend
β”‚   └── database_setup.sql             # SQL Queries for the Database  
β”‚
β”œβ”€β”€ user-frontend/                     # Frontend code
β”‚   β”œβ”€β”€ src/                           # React source code
β”‚   β”‚   β”œβ”€β”€ components/                # React components (Navbar, Footer, FileUpload, etc.)
β”‚   β”‚   β”œβ”€β”€ pages/                     # Pages for Home, Login, Register, etc.
β”‚   β”‚   β”œβ”€β”€ utils/                     # Helper functions (API calls)
β”‚   β”‚   β”œβ”€β”€ main.jsx                   # React entry point
β”‚   β”‚   β”œβ”€β”€ App.jsx                    # Main application component
β”‚   β”‚   └── index.css                  # Global styles
β”‚   β”œβ”€β”€ tailwind.config.js             # Tailwind CSS configuration
β”‚   β”œβ”€β”€ package.json                   # Frontend dependencies and scripts
β”‚   └── vite.config.js                 # Vite configuration
β”‚   β”œβ”€β”€ .env                           # Environment variables for the frontend
β”‚   β”œβ”€β”€ index.html                     # HTML template for the frontend
β”‚
β”œβ”€β”€ README.md                          # Documentation for the project
└── LICENSE                            # License file


Setup

Follow these steps to run the project locally:

Database Setup

To set up the database for the project, you can run the provided SQL script. This will create the necessary tables (users and user_files) for the application.

  1. Download the database_setup.sql file from the repository.
  2. Connect to your MySQL database.
  3. Run the following commands in your MySQL client:
-- Create the database
CREATE DATABASE user_auth_system;

-- Use the database
USE user_auth_system;

-- Create the users table
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(255) NOT NULL,
    email VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Create the user_files table
CREATE TABLE user_files (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    file_path VARCHAR(255) NOT NULL,
    uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
  1. After running the above SQL commands, your database schema will be set up and ready to use with the application.

Backend

  1. Navigate to the user-backend/ directory:

    cd user-backend
  2. Install dependencies:

    npm install
  3. Create a .env file in the user-backend/ directory and add:

    JWT_SECRET = your-secret-jwt-token
    DB_HOST= your-localhost (e.g., localhost)
    DB_USER= your-database-user (e.g., root)
    DB_PASSWORD= your-database-password
    DB_NAME= your-database-name
  4. Start the backend server:

    npm start

Frontend

  1. Navigate to the user-frontend/ directory:

    cd user-frontend
  2. Install dependencies:

    npm install
  3. Create a .env file in the user-frontend/ directory and add:

    VITE_API_URL='http://localhost:5000'
  4. Start the frontend development server:

    npm run dev

Technologies

Frontend

  • React
  • Tailwind CSS
  • Vite
  • Axios

Backend

  • Node.js
  • Express.js
  • MySQL (using Sequelize ORM)
  • JWT (JSON Web Tokens for authentication)

Usage

  1. Start the backend server (refer to Setup > Backend).
  2. Start the frontend server (refer to Setup > Frontend).
  3. Open http://localhost:5173 in your browser to access the app.

Default Credentials for Offline Use

For testing, offline usage, you can use the following credentials:


API Endpoints

Base URL: http://localhost:5000/api/

Method Endpoint Description
POST /login Login a user and return a JWT token
POST /register Register a new user
POST /change-password Change Password of the user
POST /upload Upload a photo
GET /files Get the files of the logged-in user

Screenshots

Login Page

Minimalistic and user-friendly login page.
Login Page

Register Page

Easy registration form to create a new account.
Register Page

Home Page

A minimalistic UI to upload, store, and manage your photos.
Home Page 1 Home Page 2


Host

The application is hosted on Vercel (Frontend). However, the backend is not hosted. To access the application, use the following default credentials:

You can view the application here.


Contributing

If you want to contribute to this project, follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

For any questions or issues, please reach out to:

About

A full-stack photo storage and sharing application built using React, Node.js, MySQL, and styled with Tailwind CSS. Photopia allows users to securely upload, store, and share their photos with a clean and modern user interface.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published