Skip to content

DwikyAnggarda/insta-app-web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Έ SimpleInsta - Instagram Clone

A full-stack social media application built with modern web technologies

SimpleInsta adalah aplikasi social media yang terinspirasi dari Instagram, memiliki fitur-fitur lengkap untuk berbagi foto, memberi like, berkomentar, dan mengelola profil pengguna.


πŸš€ Tech Stack

Frontend

  • React 18 - UI Library
  • Vite - Build Tool & Dev Server
  • React Router DOM - Client-side Routing
  • Tailwind CSS - Utility-first CSS Framework
  • Lucide React - Icon Library
  • Axios - HTTP Client
  • Canvas Confetti - Celebration Animations

Backend

  • Laravel 10 - PHP Framework
  • Laravel Sanctum - API Authentication
  • PostgreSQL - Database
  • Laravel Storage - File Management

Development Tools

  • ESLint - Code Linting
  • PostCSS - CSS Processing
  • Composer - PHP Dependency Manager
  • NPM - JavaScript Package Manager

✨ Features

πŸ” Authentication

  • βœ… User Registration dengan validasi lengkap
  • βœ… User Login dengan Remember Me
  • βœ… Logout functionality
  • βœ… Protected Routes (hanya user login yang bisa akses)
  • βœ… Welcome Animation setelah registrasi berhasil
  • βœ… Token-based authentication (Laravel Sanctum)

πŸ“ Post Management

  • βœ… Create Post - Text + Image (opsional)
  • βœ… Edit Post - Update caption atau ganti gambar
  • βœ… Delete Post - Hapus post beserta likes & comments
  • βœ… View Posts - Feed timeline dengan infinite scroll
  • βœ… Post Validation - Minimal ada text atau image
  • βœ… Authorization - Hanya owner yang bisa edit/delete

❀️ Like System

  • βœ… Like/Unlike post dengan satu klik
  • βœ… Realtime like count update
  • βœ… Optimistic UI update (instant feedback)
  • βœ… Like state persistence (tetap tersimpan saat navigasi)
  • βœ… Visual indicator (red heart untuk liked posts)

πŸ’¬ Comment System

  • βœ… Add Comment - Tulis komentar di post
  • βœ… View Comments - Lihat semua komentar dalam modal
  • βœ… Delete Comment - Hapus komentar sendiri
  • βœ… Comment Modal - Full-screen modal untuk fokus membaca
  • βœ… Timestamp - Relative time (just now, 5m ago, dll)
  • βœ… User Avatar - Tampilkan foto profil di setiap komentar

πŸ‘€ User Profile

  • βœ… Profile Page - Halaman profil user
  • βœ… User Stats - Total posts, followers, following
  • βœ… Posts Grid - Tampilan grid untuk semua post user
  • βœ… Avatar - Profile picture dengan UI-Avatars fallback

🎨 UI/UX Features

  • βœ… Responsive Design - Mobile-first approach
  • βœ… Bottom Navigation - Easy navigation (Home, Add, Profile)
  • βœ… Loading States - Skeleton screens & spinners
  • βœ… Error Handling - User-friendly error messages
  • βœ… Empty States - Informative empty state messages
  • βœ… Smooth Animations - Transitions & micro-interactions
  • βœ… Modern UI - Clean, minimalist design dengan Tailwind CSS

πŸ”’ Security & Authorization

  • βœ… Role-based Access - User vs Admin roles
  • βœ… Post Ownership - Hanya owner bisa edit/delete post
  • βœ… Comment Ownership - Hanya owner bisa delete comment
  • βœ… CORS Configuration - Secure cross-origin requests
  • βœ… Rate Limiting - Prevent spam & abuse
  • βœ… Input Sanitization - XSS protection

πŸ“ Project Structure

insta-app-web/
β”œβ”€β”€ backend/              # Laravel Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ Http/
β”‚   β”‚   β”‚   β”œβ”€β”€ Controllers/   # API Controllers
β”‚   β”‚   β”‚   β”œβ”€β”€ Resources/     # API Resources (transformers)
β”‚   β”‚   β”‚   └── Middleware/    # Custom middleware
β”‚   β”‚   β”œβ”€β”€ Models/            # Eloquent Models
β”‚   β”‚   └── Policies/          # Authorization policies
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ migrations/        # Database migrations
β”‚   β”‚   β”œβ”€β”€ factories/         # Model factories
β”‚   β”‚   └── seeders/           # Database seeders
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ api.php            # API routes
β”‚   β”‚   └── web.php            # Web routes
β”‚   └── tests/                 # Backend tests
β”‚
β”œβ”€β”€ frontend/             # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # Reusable components
β”‚   β”‚   β”œβ”€β”€ pages/             # Page components
β”‚   β”‚   β”œβ”€β”€ context/           # React Context (AuthContext)
β”‚   β”‚   β”œβ”€β”€ hooks/             # Custom hooks
β”‚   β”‚   └── lib/               # API client & utilities
β”‚   β”œβ”€β”€ public/                # Static assets
β”‚   └── index.html             # HTML template
β”‚
└── README.md             # This file

πŸ› οΈ Installation & Setup

Prerequisites

Pastikan sudah terinstall:

  • PHP >= 8.1
  • Composer >= 2.0
  • Node.js >= 18.0
  • PostgreSQL >= 13.0
  • Git

Step 1: Clone Repository

git clone https://github.com/yourusername/insta-app-web.git
cd insta-app-web

Step 2: Backend Setup (Laravel)

# Masuk ke folder backend
cd backend

# Install dependencies
composer install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Setup database di .env
# Edit file .env dan sesuaikan:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=insta_app
DB_USERNAME=your_username
DB_PASSWORD=your_password

# Create database (via psql)
createdb insta_app

# Run migrations
php artisan migrate

# Create storage symlink
php artisan storage:link

# (Optional) Run seeders
php artisan db:seed

# Start Laravel development server
php artisan serve
# Backend running at: http://localhost:8000

Step 3: Frontend Setup (React + Vite)

# Buka terminal baru, masuk ke folder frontend
cd frontend

# Install dependencies
npm install

# Setup environment variables
# Create .env file dan tambahkan:
echo "VITE_API_URL=http://localhost:8000/api" > .env

# Start Vite development server
npm run dev
# Frontend running at: http://localhost:5173

Step 4: Access Application

Buka browser dan akses:


πŸ“– Usage Guide

1. Register New Account

  1. Buka http://localhost:5173
  2. Klik "Sign Up" atau navigate ke /register
  3. Isi form:
    • Full Name (required)
    • Email (required, must be valid)
    • Password (required, min 6 characters)
    • Confirm Password (must match)
  4. Klik "Sign Up"
  5. Welcome animation akan muncul πŸŽ‰
  6. Automatically redirected ke Home page

2. Login

  1. Navigate ke /login
  2. Isi email & password
  3. Klik "Sign In"
  4. Redirected ke Home page

3. Create Post

  1. Klik tombol "+" di bottom navigation
  2. Modal "Create Post" akan muncul
  3. Isi caption (optional)
  4. Upload image (optional)
  5. Note: Minimal ada caption ATAU image
  6. Klik "Post"
  7. Post baru muncul di feed

4. Like a Post

  1. Klik icon heart di post
  2. Icon berubah merah = liked
  3. Like count bertambah
  4. Klik lagi untuk unlike

5. Comment on Post

  1. Klik icon comment di post
  2. Modal comments akan muncul
  3. Tulis komentar di bottom form
  4. Klik Send
  5. Komentar muncul di list
  6. Klik trash icon untuk delete komentar sendiri

6. Edit Post

  1. Klik menu (3 dots) di post milik sendiri
  2. Pilih "Edit Post"
  3. Update caption atau image
  4. Klik "Save Changes"

7. Delete Post

  1. Klik menu (3 dots) di post milik sendiri
  2. Pilih "Delete Post"
  3. Konfirmasi delete
  4. Post terhapus beserta likes & comments

8. View Profile

  1. Klik icon user di bottom navigation
  2. Lihat stats: Posts count, Followers, Following
  3. Lihat grid semua post user
  4. Klik Logout untuk keluar

πŸ§ͺ Testing

Backend Testing

cd backend

# Run all tests
php artisan test

# Run specific test
php artisan test --filter PostTest

# Run with coverage
php artisan test --coverage

Frontend Testing

cd frontend

# Run linter
npm run lint

# Build for production (test build)
npm run build

# Preview production build
npm run preview

πŸ”§ Configuration

Backend Configuration

File: backend/.env

# Application
APP_NAME="SimpleInsta"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

# Database
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=insta_app
DB_USERNAME=postgres
DB_PASSWORD=secret

# CORS (allow frontend)
SANCTUM_STATEFUL_DOMAINS=localhost:5173
SESSION_DOMAIN=localhost

Frontend Configuration

File: frontend/.env

# API URL
VITE_API_URL=http://localhost:8000/api

πŸ“ API Documentation

Authentication Endpoints

Method Endpoint Description Auth Required
POST /api/register Register new user No
POST /api/login Login user No
POST /api/logout Logout user Yes
GET /api/user Get current user Yes

Post Endpoints

Method Endpoint Description Auth Required
GET /api/posts Get all posts No
GET /api/posts/{id} Get single post No
POST /api/posts Create post Yes
PUT /api/posts/{id} Update post Yes (owner)
DELETE /api/posts/{id} Delete post Yes (owner)

Like Endpoints

Method Endpoint Description Auth Required
POST /api/posts/{id}/like Toggle like Yes

Comment Endpoints

Method Endpoint Description Auth Required
POST /api/posts/{id}/comments Add comment Yes
DELETE /api/comments/{id} Delete comment Yes (owner)

πŸ› Known Issues & Fixes

Issue 1: Like Color Not Persisting βœ… FIXED

Problem: Like icon color resets after navigation
Solution: Update parent state on like action
Details: See BUGFIX_LIKE_PERSISTENCE_FINAL.md

Issue 2: MessageCircle Not Defined βœ… FIXED

Problem: Error when opening comment modal on post with 0 comments
Solution: Added MessageCircle to import statement


πŸš€ Deployment

Backend Deployment (Laravel)

# Build for production
composer install --optimize-autoloader --no-dev

# Set environment
php artisan config:cache
php artisan route:cache
php artisan view:cache

# Run migrations
php artisan migrate --force

# Set permissions
chmod -R 755 storage bootstrap/cache

Frontend Deployment (React)

# Build for production
npm run build

# Output: dist/ folder
# Deploy dist/ to your hosting (Vercel, Netlify, etc.)

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

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


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

  • Your Name - Initial work - GitHub

Screenshots


πŸ™ Acknowledgments

  • Inspired by Instagram
  • Built with ❀️ using Laravel & React
  • Icons by Lucide React
  • UI design with Tailwind CSS

πŸ“ž Support

For support, email your.email@example.com or open an issue in the repository.


Happy Coding! πŸš€

About

Aplikasi social media semi mirip Instagram.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published