Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Next.js Frontend Starter

Next.js React TypeScript Prisma Tailwind CSS Socket.io License Status Docker

Enterprise-Grade Next.js Frontend Application with Real-time Features

A comprehensive, production-ready Next.js 15 frontend application built with React 19, featuring JWT authentication, real-time WebSocket communication, advanced media management, role-based access control, internationalization, and a beautiful modern UI with shadcn/ui components.

πŸ“‹ Table of Contents

✨ Features

🎯 Core Capabilities

  • πŸ” Advanced Authentication System

    • Multi-token JWT authentication (Access, Session, Refresh tokens)
    • OTP verification via Email, SMS, and WhatsApp
    • Password management (set, change, reset)
    • Email/Phone verification
    • Session management with token rotation
    • Secure logout with token blacklisting
  • πŸ‘₯ User Management

    • Comprehensive user profiles with rich metadata
    • User status management (active, inactive, suspended, verified)
    • User type classification
    • Profile picture upload with MediaPicker integration
    • User search and filtering
    • Bulk operations support
  • πŸ”‘ Role-Based Access Control (RBAC)

    • Flexible permission system with groups and permissions
    • Permission-based route guards
    • Component-level permission checks
    • User group management
    • Permission analytics and statistics
  • πŸ“Š Real-time Dashboard

    • Live statistics with WebSocket updates
    • Interactive charts (Line, Bar, Pie, Area)
    • User growth tracking
    • Analytics by status, type, country, language, auth type
    • Recent sign-ins monitoring
    • Real-time data refresh
  • πŸ“ Advanced Media Management

    • Google Cloud Storage & Local Storage support
    • MediaPicker component for easy media selection
    • Folder organization system
    • Public/Private media with access keys
    • Image caching and optimization
    • Bulk upload and delete operations
    • Media statistics and analytics
    • Thumbnail generation
    • File type detection and organization
  • πŸ“ Activity Logging

    • Comprehensive audit trail
    • Real-time activity updates via WebSocket
    • User action tracking
    • Filtering and search capabilities
    • Activity statistics (INFO, WARNING, ERROR)
    • Detailed activity metadata
  • 🌍 Internationalization (i18n)

    • Full English and Arabic support
    • RTL (Right-to-Left) layout support
    • Dynamic language switching
    • Module-based translation system
    • Automatic locale detection
  • 🎨 Modern UI/UX

    • Beautiful, responsive design with Tailwind CSS
    • shadcn/ui component library
    • Dark/Light/System theme support
    • Collapsible sidebar navigation
    • Advanced search functionality
    • Toast notifications
    • Confirmation dialogs
    • Loading states and skeletons
  • ⚑ Real-time Communication

    • WebSocket integration with Socket.io
    • Real-time dashboard updates
    • Live activity log updates
    • Instant media library updates
    • Notification system
    • Room-based subscriptions
  • πŸ’Ύ Caching & Performance

    • Redis caching layer
    • Client-side image caching
    • Media list caching
    • Cache invalidation strategies
    • Optimized API calls
    • Lazy loading and code splitting
  • πŸ”” Notification System

    • Real-time notifications
    • Unread count tracking
    • Notification dropdown
    • Mark as read functionality
  • βš™οΈ Project Settings

    • Logo management (Main, Header, Footer)
    • Social media links configuration
    • SEO & Meta tags management
    • Contact & support information
    • General project information
  • πŸ“ˆ System Analytics

    • System health monitoring
    • Error tracking and logging
    • Cache statistics
    • Docker status
    • Top processes monitoring
    • Log viewer with filtering
  • πŸ‘₯ Account Sharing

    • Share account access with other users
    • Send and receive access invitations
    • Request access to other accounts
    • Manage shared access permissions
    • View account sharing activity
    • Access level control (view, edit, full)
    • Real-time notifications for sharing events

πŸ”§ Technical Features

  • Next.js 15.1+: App Router, Server Components, API Routes
  • React 19.2: Latest React features with concurrent rendering
  • TypeScript 5.0: Full type safety across the application
  • Prisma ORM: Type-safe database access with PostgreSQL
  • Socket.io: Real-time bidirectional communication
  • Tailwind CSS 3.4: Utility-first CSS framework
  • shadcn/ui: Beautiful, accessible component library
  • Redis: Caching and session management
  • Winston: Professional logging system
  • Recharts: Beautiful chart library
  • Axios: HTTP client for API calls
  • ioredis: Redis client for Node.js

🎨 UI Components

  • Layout Components: Navbar, Sidebar, Footer, MainLayout
  • Form Components: Input, Textarea, Select, OTP Input, Country Selector
  • Data Display: Card, Badge, Avatar, Tabs, Charts
  • Feedback: Toast, Dialog, Confirm Dialog, Loading States
  • Media: MediaPicker, FolderManager, CachedImage
  • Navigation: Side Panel, Dropdown Menu
  • Authentication: PageGuard, StatusGuard, PermissionGuard

πŸ—οΈ Architecture

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Client Browser                             β”‚
β”‚                    (React 19 + Next.js 15)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Next.js Application                         β”‚
β”‚                    (Port 3000)                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Client-Side Features:                                   β”‚  β”‚
β”‚  β”‚  - React Components (Client Components)                  β”‚  β”‚
β”‚  β”‚  - Context Providers (Auth, Theme, i18n, WebSocket)      β”‚  β”‚
β”‚  β”‚  - Hooks (useApiCall, usePermissions, useToast)          β”‚  β”‚
β”‚  β”‚  - Real-time WebSocket Client                            β”‚  β”‚
β”‚  β”‚  - Client-side Caching (Media, Images)                   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Server-Side Features:                                   β”‚  β”‚
β”‚  β”‚  - API Routes (Next.js API Routes)                       β”‚  β”‚
β”‚  β”‚  - Server Components                                     β”‚  β”‚
β”‚  β”‚  - Database Access (Prisma)                              β”‚  β”‚
β”‚  β”‚  - Redis Caching                                         β”‚  β”‚
β”‚  β”‚  - WebSocket Server (Socket.io)                          β”‚  β”‚
β”‚  β”‚  - Authentication Middleware                             β”‚  β”‚
β”‚  β”‚  - Permission Checking                                   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β–Ό                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL Database    β”‚   β”‚   Redis Cache            β”‚
β”‚   (Port 5432)            β”‚   β”‚   (Port 6379)            β”‚
β”‚   - User Data            β”‚   β”‚   - Session Storage      β”‚
β”‚   - Permissions          β”‚   β”‚   - Media Cache          β”‚
β”‚   - Activity Logs        β”‚   β”‚   - API Response Cache   β”‚
β”‚   - Groups               β”‚   β”‚   - Token Blacklist      β”‚
β”‚   - Media                β”‚   β”‚   - Rate Limiting        β”‚
β”‚   - Notifications        β”‚   β”‚                          β”‚
β”‚   - Account Sharing      β”‚   β”‚                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   pgAdmin                β”‚
β”‚   (Port 5050)            β”‚
β”‚   - Database Management  β”‚
β”‚   - Query Interface      β”‚
β”‚   - Visual Schema Editor β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Google Cloud Storage   β”‚
β”‚   (Media & Static Files) β”‚
β”‚   - User Uploads         β”‚
β”‚   - Generated Content    β”‚
β”‚   - Static Assets        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Request Flow

1. User Action (Click, Form Submit, etc.)
   β”‚
   β”œβ”€β–Ί Client Component
   β”‚   β”œβ”€β–Ί Context (Auth, Theme, i18n)
   β”‚   β”œβ”€β–Ί Custom Hooks (useApiCall, usePermissions)
   β”‚   └─► API Service Call
   β”‚
   β”œβ”€β–Ί Next.js API Route (/api/*)
   β”‚   β”œβ”€β–Ί Authentication Middleware
   β”‚   β”œβ”€β–Ί Permission Check
   β”‚   β”œβ”€β–Ί Request Validation
   β”‚   β”œβ”€β–Ί Business Logic
   β”‚   β”œβ”€β–Ί Database Operations (Prisma)
   β”‚   β”œβ”€β–Ί Cache Management (Redis)
   β”‚   β”œβ”€β–Ί WebSocket Event Emission
   β”‚   └─► Response Formatting
   β”‚
   β”œβ”€β–Ί WebSocket Update (Real-time)
   β”‚   └─► Client Receives Update
   β”‚       └─► UI Updates Automatically
   β”‚
   └─► Response
       β”œβ”€β–Ί Success/Error Handling
       β”œβ”€β–Ί Toast Notification
       └─► UI State Update

Component Architecture

App Layout
β”œβ”€β”€ Providers (Auth, Theme, i18n, WebSocket, Toast)
β”œβ”€β”€ MainLayout
β”‚   β”œβ”€β”€ Navbar (Collapsible, Search, Theme Toggle)
β”‚   β”œβ”€β”€ Sidebar (Navigation, Appearance Settings)
β”‚   β”œβ”€β”€ TopNav (User Menu, Notifications)
β”‚   └── Content Area
β”‚       β”œβ”€β”€ PageGuard (Authentication Check)
β”‚       β”œβ”€β”€ PermissionGuard (Permission Check)
β”‚       └── Page Content
β”‚           β”œβ”€β”€ Dashboard (Charts, Statistics)
β”‚           β”œβ”€β”€ Users (List, Create, Edit, Delete)
β”‚           β”œβ”€β”€ Media (Library, Upload, Manage)
β”‚           β”œβ”€β”€ Activity (Logs, Filtering)
β”‚           β”œβ”€β”€ Settings (Profile, Project, System)
β”‚           └── Admin (Access Control, Analytics)
└── Footer

πŸ› οΈ Tech Stack

Frontend Framework

  • Next.js 15.1.5: React framework with App Router
  • React 19.2.0: UI library with concurrent features
  • TypeScript 5.0: Type-safe JavaScript

Styling & UI

  • Tailwind CSS 3.4: Utility-first CSS framework
  • shadcn/ui: High-quality React components
  • Lucide React: Beautiful icon library
  • Recharts 3.5: Charting library

State Management & Data

  • React Context API: Global state management
  • React Hooks: Custom hooks for data fetching
  • Axios: HTTP client
  • Prisma Client: Database ORM

Real-time & Communication

  • Socket.io Client 4.8: Real-time WebSocket communication
  • Socket.io Server: WebSocket server integration

Caching & Storage

  • Redis 7 (ioredis): Server-side caching (included in Docker setup)
  • Client-side Cache: Media and image caching
  • localStorage: Client-side persistence
  • Docker Volumes: Persistent data storage for database and cache

Authentication & Security

  • JWT (jsonwebtoken): Token-based authentication
  • bcryptjs: Password hashing
  • Session Management: Secure session handling

Database & ORM

  • PostgreSQL 16: Relational database (included in Docker setup)
  • Prisma 7.0: Next-generation ORM
  • Prisma Client: Type-safe database access
  • pgAdmin 4: Database management UI (included in Docker setup)

Utilities

  • Winston: Logging system
  • UUID: Unique identifier generation
  • Class Variance Authority: Component variants
  • clsx & tailwind-merge: Conditional class names

πŸ“¦ Installation & Setup

Prerequisites

System Requirements:

  • OS: Linux (Ubuntu 20.04+), macOS, or Windows with WSL2
  • Docker: 20.10+ (recommended for easy setup)
  • Docker Compose: 2.0+ (for multi-container orchestration)
  • Node.js: 18.0 or higher (for local development without Docker)
  • npm: 9.0 or higher (for local development without Docker)
  • PostgreSQL: 16+ (included in Docker setup)
  • Redis: 7+ (included in Docker setup)

Development Tools:

  • Git 2.30+
  • Code editor (VS Code recommended)
  • Postman or similar API testing tool
  • Make (optional, for convenient commands)

Quick Start

Option 1: Docker (Recommended - Easiest Setup)

Step 1: Clone Repository

git clone <repository-url>
cd nextjs-frontend-starter

Step 2: Setup Environment

# Copy example environment file
cp example.env .env

# Edit .env file with your configuration (optional - defaults work)
nano .env

Step 3: Start All Services with Docker Compose

# Using Make (recommended)
make up

# Or using Docker Compose directly
docker compose up -d

This will automatically:

  • βœ… Start PostgreSQL database
  • βœ… Start Redis cache
  • βœ… Start Next.js application
  • βœ… Start pgAdmin (database management UI)
  • βœ… Run database migrations
  • βœ… Seed database with default data

Step 4: Access Application

Useful Commands:

make help           # Show all available commands
make logs           # View all service logs
make logs-app       # View app logs only
make db-shell       # Open PostgreSQL shell
make db-migrate     # Run Prisma migrations
make db-seed        # Seed the database
make shell          # Open app container shell
make down           # Stop all services
make clean          # Stop and remove volumes

Option 2: Local Development (Without Docker)

Step 1: Clone Repository

git clone <repository-url>
cd nextjs-frontend-starter

Step 2: Install Dependencies

npm install

Step 3: Setup Environment

# Copy example environment file
cp example.env .env

# Edit .env file with your configuration
nano .env

Required Environment Variables:

# Application
APP_MODE=development
APP_INTERNAL_PORT=3000

# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:3000
API_INTERNAL_URL=http://localhost:3000

# Database (PostgreSQL)
DATABASE_HOST=localhost
DATABASE_NAME=postgres
DATABASE_USER=nextjs_db
DATABASE_PASSWORD=postgres123
DATABASE_PORT=5432
DATABASE_URL=postgresql://nextjs_db:postgres123@localhost:5432/postgres?schema=public

# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_URL=redis://localhost:6379
REDIS_CACHE_ENABLED=true

# JWT
JWT_SECRET=your-secret-key
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRY_MINUTES=60
SESSION_TOKEN_EXPIRY_MINUTES=10080
REFRESH_TOKEN_EXPIRY_MINUTES=43200

# Storage (Optional - for media uploads)
GOOGLE_STORAGE_BUCKET_NAME=your-bucket-name
STORAGE_BUCKET=your-bucket-name

# Media Access
MEDIA_ENABLE_ACCESS_KEY=true
MEDIA_ACCESS_KEY_LENGTH=32
MEDIA_REQUIRE_ACCESS_KEY_FOR_PUBLIC=false
MEDIA_ALLOW_ADMIN_ACCESS_WITHOUT_KEY=true

# pgAdmin (for Docker setup)
PGADMIN_EMAIL=admin@example.com
PGADMIN_PASSWORD=admin@123
PGADMIN_PORT=5050

Step 4: Setup Database

# Generate Prisma Client
npm run db:generate

# Push schema to database
npm run db:push

# Seed database with default data
npm run db:seed

Step 5: Start Development Server

# Development mode with hot reload
npm run dev

# Or start production build
npm run build
npm start

Step 6: Access Application

πŸš€ Quick Start

Docker Deployment (Recommended)

Start All Services:

# Using Make (recommended)
make up

# Or using Docker Compose directly
docker compose up -d

View Logs:

# All services
make logs

# Specific service
make logs-app
make logs-db
make logs-redis
make logs-pgadmin

# Or using Docker Compose
docker compose logs -f
docker compose logs -f app

Database Management:

# Open PostgreSQL shell
make db-shell

# Run migrations
make db-migrate

# Seed database
make db-seed

# Open Prisma Studio
make db-studio

# Reset database
make db-reset

Stop Services:

# Stop all services
make down

# Stop and remove volumes
make clean

# Or using Docker Compose
docker compose down
docker compose down -v

Access Points:

Local Development (Without Docker)

Development Mode:

# Install dependencies
npm install

# Setup environment
cp example.env .env
# Edit .env with your configuration

# Setup database (requires PostgreSQL running)
npm run db:generate
npm run db:push
npm run db:seed

# Start development server
npm run dev

Production Build:

# Build application
npm run build

# Start production server
npm start

# Or use PM2
npm run pm2:start

Development with Docker

Start in Development Mode:

# Start with development overrides
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d

# Or using Make
make up-dev

This enables:

  • Hot-reload for code changes
  • Development optimizations
  • Easier debugging

πŸ“š Project Structure

nextjs-frontend-starter/
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ app/                          # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ πŸ“ (auth)/                   # Authentication pages
β”‚   β”‚   β”‚   β”œβ”€β”€ login/                   # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ signup/                  # Signup page
β”‚   β”‚   β”‚   β”œβ”€β”€ verify/                  # Email/Phone verification
β”‚   β”‚   β”‚   β”œβ”€β”€ set-password/            # Set password
β”‚   β”‚   β”‚   └── forgot-password/         # Password recovery
β”‚   β”‚   β”œβ”€β”€ πŸ“ api/                      # API Routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                    # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ users/                   # User management
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/               # Dashboard statistics
β”‚   β”‚   β”‚   β”œβ”€β”€ media/                   # Media management
β”‚   β”‚   β”‚   β”œβ”€β”€ activity/                # Activity logs
β”‚   β”‚   β”‚   β”œβ”€β”€ permissions/             # Permissions & groups
β”‚   β”‚   β”‚   β”œβ”€β”€ settings/                # User settings
β”‚   β”‚   β”‚   └── notifications/           # Notifications
β”‚   β”‚   β”œβ”€β”€ πŸ“ admin/                    # Admin pages
β”‚   β”‚   β”‚   β”œβ”€β”€ users/                   # User management
β”‚   β”‚   β”‚   β”œβ”€β”€ access-control/          # Permissions & groups
β”‚   β”‚   β”‚   β”œβ”€β”€ project-settings/        # Project configuration
β”‚   β”‚   β”‚   └── system-analytics/        # System monitoring
β”‚   β”‚   β”œβ”€β”€ dashboard/                   # Dashboard page
β”‚   β”‚   β”œβ”€β”€ media/                       # Media library
β”‚   β”‚   β”œβ”€β”€ activity/                    # Activity logs
β”‚   β”‚   β”œβ”€β”€ profile-settings/            # User profile settings
β”‚   β”‚   β”œβ”€β”€ notifications/               # Notifications page
β”‚   β”‚   β”œβ”€β”€ layout.tsx                   # Root layout
β”‚   β”‚   └── page.tsx                     # Home page
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ components/                    # React Components
β”‚   β”‚   β”œβ”€β”€ πŸ“ auth/                     # Authentication components
β”‚   β”‚   β”‚   β”œβ”€β”€ PageGuard.tsx            # Route protection
β”‚   β”‚   β”‚   └── StatusGuard.tsx          # User status check
β”‚   β”‚   β”œβ”€β”€ πŸ“ layout/                   # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ MainLayout.tsx           # Main app layout
β”‚   β”‚   β”‚   β”œβ”€β”€ Navbar.tsx               # Sidebar navigation
β”‚   β”‚   β”‚   └── TopNav.tsx               # Top navigation bar
β”‚   β”‚   β”œβ”€β”€ πŸ“ dashboard/                 # Dashboard components
β”‚   β”‚   β”‚   β”œβ”€β”€ ChartCard.tsx            # Chart container
β”‚   β”‚   β”‚   β”œβ”€β”€ LineChart.tsx            # Line chart
β”‚   β”‚   β”‚   β”œβ”€β”€ BarChart.tsx             # Bar chart
β”‚   β”‚   β”‚   β”œβ”€β”€ PieChart.tsx             # Pie chart
β”‚   β”‚   β”‚   └── AreaChart.tsx            # Area chart
β”‚   β”‚   β”œβ”€β”€ πŸ“ media/                     # Media components
β”‚   β”‚   β”‚   β”œβ”€β”€ MediaPicker.tsx          # Media selection component
β”‚   β”‚   β”‚   β”œβ”€β”€ FolderManager.tsx        # Folder management
β”‚   β”‚   β”‚   └── CachedImage.tsx          # Optimized image component
β”‚   β”‚   β”œβ”€β”€ πŸ“ ui/                       # shadcn/ui components
β”‚   β”‚   β”‚   β”œβ”€β”€ button.tsx               # Button component
β”‚   β”‚   β”‚   β”œβ”€β”€ card.tsx                 # Card component
β”‚   β”‚   β”‚   β”œβ”€β”€ input.tsx                # Input component
β”‚   β”‚   β”‚   β”œβ”€β”€ dialog.tsx               # Dialog component
β”‚   β”‚   β”‚   └── ...                      # More UI components
β”‚   β”‚   └── πŸ“ permissions/               # Permission components
β”‚   β”‚       β”œβ”€β”€ PermissionGuard.tsx      # Permission check
β”‚   β”‚       └── PermissionButton.tsx     # Permission-based button
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ context/                      # React Context Providers
β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx              # Authentication context
β”‚   β”‚   β”œβ”€β”€ ThemeContext.tsx             # Theme management
β”‚   β”‚   β”œβ”€β”€ I18nContext.tsx              # Internationalization
β”‚   β”‚   β”œβ”€β”€ WebSocketContext.tsx         # WebSocket connection
β”‚   β”‚   └── Provider.tsx                 # Combined providers
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ hooks/                         # Custom React Hooks
β”‚   β”‚   β”œβ”€β”€ useApiCall.ts                # API call hook
β”‚   β”‚   β”œβ”€β”€ useAuth.ts                   # Authentication hook
β”‚   β”‚   β”œβ”€β”€ usePermissions.ts            # Permission checking
β”‚   β”‚   β”œβ”€β”€ useToast.ts                  # Toast notifications
β”‚   β”‚   └── useDebounce.ts               # Debounce utility
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ services/                      # API Service Layer
β”‚   β”‚   β”œβ”€β”€ auth.service.ts              # Authentication service
β”‚   β”‚   β”œβ”€β”€ user.service.ts              # User service
β”‚   β”‚   β”œβ”€β”€ media.service.ts             # Media service
β”‚   β”‚   β”œβ”€β”€ dashboard.service.ts         # Dashboard service
β”‚   β”‚   β”œβ”€β”€ permission.service.ts        # Permission service
β”‚   β”‚   └── websocket.service.ts         # WebSocket service
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ lib/                          # Utility Libraries
β”‚   β”‚   β”œβ”€β”€ πŸ“ api/                      # API utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ ApiService.ts            # API service class
β”‚   β”‚   β”‚   └── ApiServiceFactory.ts    # API factory
β”‚   β”‚   β”œβ”€β”€ πŸ“ cache/                     # Caching utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ cache.ts                # Redis cache
β”‚   β”‚   β”‚   β”œβ”€β”€ mediaCache.ts           # Media cache
β”‚   β”‚   β”‚   └── imageCache.ts           # Image cache
β”‚   β”‚   β”œβ”€β”€ πŸ“ authenticate/             # Auth utilities
β”‚   β”‚   β”‚   β”œβ”€β”€ helpers.ts              # Auth helpers
β”‚   β”‚   β”‚   └── session-manager.ts      # Session management
β”‚   β”‚   β”œβ”€β”€ πŸ“ middleware/               # Middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts                 # Auth middleware
β”‚   β”‚   β”‚   └── permission-check.ts     # Permission middleware
β”‚   β”‚   └── πŸ“ multilingual/             # i18n utilities
β”‚   β”‚       └── i18n.ts                  # Translation loader
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ models/                       # TypeScript Models
β”‚   β”‚   β”œβ”€β”€ user.model.ts               # User types
β”‚   β”‚   β”œβ”€β”€ media.model.ts              # Media types
β”‚   β”‚   β”œβ”€β”€ permission.model.ts          # Permission types
β”‚   β”‚   └── api.model.ts                # API response types
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ locales/                      # Translation Files
β”‚   β”‚   β”œβ”€β”€ πŸ“ en/                       # English translations
β”‚   β”‚   β”‚   β”œβ”€β”€ general.json            # General terms
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.json               # Auth terms
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.json          # Dashboard terms
β”‚   β”‚   β”‚   └── ...                     # More modules
β”‚   β”‚   └── πŸ“ ar/                       # Arabic translations
β”‚   β”‚       └── ...                     # Same structure
β”‚   β”‚
β”‚   └── πŸ“ types/                        # TypeScript Types
β”‚       β”œβ”€β”€ axios.ts                    # Axios types
β”‚       └── cache.d.ts                  # Cache types
β”‚
β”œβ”€β”€ πŸ“ prisma/                           # Prisma ORM
β”‚   β”œβ”€β”€ schema.prisma                    # Database schema
β”‚   β”œβ”€β”€ seed-defaults.js                 # Seed data
β”‚   └── migrations/                     # Database migrations
β”‚
β”œβ”€β”€ πŸ“ scripts/                          # Helper Scripts
β”‚   β”œβ”€β”€ init-db.sql                      # PostgreSQL initialization
β”‚   └── pgadmin-servers.json             # pgAdmin server config
β”‚
β”œβ”€β”€ πŸ“ public/                           # Static Assets
β”‚   └── uploads/                         # Uploaded media (local)
β”‚
β”œβ”€β”€ πŸ“„ server.js                         # Custom Next.js server
β”œβ”€β”€ πŸ“„ start.sh                          # Startup script (auto migrations)
β”œβ”€β”€ πŸ“„ Makefile                          # Docker management commands
β”œβ”€β”€ πŸ“„ next.config.ts                    # Next.js configuration
β”œβ”€β”€ πŸ“„ tailwind.config.js                # Tailwind configuration
β”œβ”€β”€ πŸ“„ tsconfig.json                     # TypeScript configuration
β”œβ”€β”€ πŸ“„ package.json                      # Dependencies
β”œβ”€β”€ πŸ“„ docker-compose.yaml               # Docker Compose config
β”œβ”€β”€ πŸ“„ docker-compose.dev.yaml            # Development override
β”œβ”€β”€ πŸ“„ Dockerfile                        # Docker image
β”œβ”€β”€ πŸ“„ example.env                        # Environment variables template
└── πŸ“„ README.md                         # This file

🎨 Key Features Explained

πŸ” Authentication System

Multi-Token Architecture:

  • Access Token: Short-lived (1 hour) for API authentication
  • Session Token: Medium-lived (7 days) with full user data
  • Refresh Token: Long-lived (30 days) for token renewal

Features:

  • Login with password or OTP
  • Email/Phone verification
  • Password management (set, change, reset)
  • Secure session management
  • Token rotation on refresh

Usage Example:

import { useAuth } from "@context/AuthContext"

function MyComponent() {
  const { user, login, logout, isAuthenticated } = useAuth()
  
  if (!isAuthenticated) {
    return <LoginForm onLogin={login} />
  }
  
  return <div>Welcome, {user?.email}</div>
}

πŸ“Š Real-time Dashboard

Features:

  • Live statistics with WebSocket updates
  • Interactive charts (Line, Bar, Pie, Area)
  • User growth tracking
  • Analytics by multiple dimensions
  • Real-time data refresh

WebSocket Integration:

import { useWebSocket } from "@context/WebSocketContext"

function Dashboard() {
  const { onUserCreated, onUserUpdated, onDashboardStatsUpdate } = useWebSocket()
  
  useEffect(() => {
    onUserCreated(() => {
      // Refresh dashboard data
      refreshDashboard()
    })
  }, [])
}

πŸ“ Media Management

Features:

  • Google Cloud Storage & Local Storage support
  • MediaPicker component for easy selection
  • Folder organization
  • Public/Private media with access keys
  • Image caching and optimization
  • Bulk operations

MediaPicker Usage:

import { MediaPicker } from "@components/media/MediaPicker"

function MyComponent() {
  const [pickerOpen, setPickerOpen] = useState(false)
  
  return (
    <>
      <Button onClick={() => setPickerOpen(true)}>
        Select Media
      </Button>
      <MediaPicker
        open={pickerOpen}
        onClose={() => setPickerOpen(false)}
        onSelect={(media) => {
          // Handle selected media
          console.log(media)
        }}
        mode="image"
        allowUrl={true}
        allowUpload={true}
      />
    </>
  )
}

🌍 Internationalization

Features:

  • English and Arabic support
  • RTL layout support
  • Dynamic language switching
  • Module-based translations

Usage:

import { useModuleI18n } from "@context/I18nContext"

function MyComponent() {
  const { t } = useModuleI18n("general")
  const { t: tAuth } = useModuleI18n("auth")
  
  return (
    <div>
      <h1>{t("welcome")}</h1>
      <button>{tAuth("login")}</button>
    </div>
  )
}

πŸ”‘ Permission System

Features:

  • Permission-based route guards
  • Component-level permission checks
  • User group management
  • Permission analytics

Usage:

import { PermissionGuard } from "@components/permissions/PermissionGuard"
import { usePermissions } from "@hooks/usePermissions"

function MyComponent() {
  const { hasPermission } = usePermissions()
  
  return (
    <PermissionGuard requirePermission="manage_users">
      <UserManagementPanel />
    </PermissionGuard>
  )
}

πŸ”Œ API Integration

API Service

The application uses a centralized API service for all HTTP requests:

import { createPublicApiService } from "@lib/api/ApiServiceFactory"

const apiService = createPublicApiService()

// GET request
const response = await apiService.get("/api/users")

// POST request
const response = await apiService.post("/api/users", { name: "John" })

// With authentication
const authApi = createPublicApiService({
  "X-Session-Token": sessionToken
})

Custom Hook for API Calls

import { useApiCall } from "@hooks/useApiCall"

function MyComponent() {
  const fetchUsers = useApiCall(
    async () => {
      return await userService.getUsers()
    },
    {
      onSuccess: (data) => {
        console.log("Users loaded:", data)
      },
      onError: (error) => {
        console.error("Error:", error)
      },
      showErrorToast: true,
    }
  )
  
  useEffect(() => {
    fetchUsers.execute()
  }, [])
  
  return (
    <div>
      {fetchUsers.loading && <Loader />}
      {fetchUsers.data && <UserList users={fetchUsers.data} />}
    </div>
  )
}

πŸ“± Real-time Features

WebSocket Integration

Connection:

import { useWebSocket } from "@context/WebSocketContext"

function MyComponent() {
  const { 
    connected,
    subscribeToDashboard,
    onUserCreated,
    onMediaUpdated 
  } = useWebSocket()
  
  useEffect(() => {
    subscribeToDashboard()
    
    onUserCreated((user) => {
      console.log("New user created:", user)
    })
    
    onMediaUpdated((media) => {
      console.log("Media updated:", media)
    })
  }, [])
}

Available Events:

  • user:created - New user registered
  • user:updated - User profile updated
  • user:deleted - User deleted
  • media:created - New media uploaded
  • media:updated - Media updated
  • media:deleted - Media deleted
  • folder:created - Folder created
  • folder:updated - Folder updated
  • folder:deleted - Folder deleted
  • activity:new - New activity log
  • dashboard:stats:update - Dashboard statistics updated

🎯 Usage Examples

Creating a New Page

"use client"

import { MainLayout } from "@components/layout/MainLayout"
import { PageGuard } from "@components/auth/PageGuard"
import { PermissionGuard } from "@components/permissions/PermissionGuard"

export default function MyPage() {
  return (
    <PageGuard requireAuth>
      <PermissionGuard requirePermission="view_my_feature">
        <MainLayout
          title="My Page"
          description="Page description"
        >
          <div>
            {/* Your page content */}
          </div>
        </MainLayout>
      </PermissionGuard>
    </PageGuard>
  )
}

Using MediaPicker in Forms

import { MediaPicker } from "@components/media/MediaPicker"
import { useState } from "react"

function ProfileForm() {
  const [mediaPickerOpen, setMediaPickerOpen] = useState(false)
  const [logoUrl, setLogoUrl] = useState("")
  
  return (
    <>
      <Input 
        value={logoUrl}
        placeholder="Logo URL"
      />
      <Button onClick={() => setMediaPickerOpen(true)}>
        Select Logo
      </Button>
      
      <MediaPicker
        open={mediaPickerOpen}
        onClose={() => setMediaPickerOpen(false)}
        onSelect={(media) => {
          const url = typeof media === 'string' 
            ? media 
            : media.public_url
          setLogoUrl(url)
          setMediaPickerOpen(false)
        }}
        mode="image"
      />
    </>
  )
}

Using Toast Notifications

import { useToast } from "@hooks/useToast"

function MyComponent() {
  const { showSuccess, showError, showInfo } = useToast()
  
  const handleSave = async () => {
    try {
      await saveData()
      showSuccess("Data saved successfully!")
    } catch (error) {
      showError("Failed to save data")
    }
  }
}

🐳 Docker Deployment

Docker Compose Services

The project includes a complete Docker Compose setup with all required services:

Services:

  • app: Next.js application (Port 3000)
  • postgres: PostgreSQL 16 database (Port 5432)
  • redis: Redis 7 cache (Port 6379)
  • pgadmin: Database management UI (Port 5050)
  • nginx: Reverse proxy (Port 9080, optional)

Quick Start with Docker

# Start all services
make up
# or
docker compose up -d

# View logs
make logs
# or
docker compose logs -f

# Stop services
make down
# or
docker compose down

Docker Compose Configuration

The docker-compose.yaml includes:

  • Automatic database migrations on startup
  • Database seeding with default data
  • Health checks for all services
  • Volume persistence for data
  • Network isolation for security
  • Resource limits for production

Environment Variables

Key environment variables for Docker:

# Database (auto-configured for Docker)
DATABASE_HOST=postgres
DATABASE_NAME=postgres
DATABASE_USER=nextjs_db
DATABASE_PASSWORD=postgres123
DATABASE_PORT=5432
DATABASE_URL=postgresql://nextjs_db:postgres123@postgres:5432/postgres?schema=public

# Redis (auto-configured for Docker)
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://redis:6379

# pgAdmin
PGADMIN_EMAIL=admin@example.com
PGADMIN_PASSWORD=admin@123
PGADMIN_PORT=5050

# Migration & Seed settings
WAIT_FOR_DB=true
DB_WAIT_TIMEOUT=60
SKIP_MIGRATIONS=false
SKIP_SEED=false

Database Management with pgAdmin

Access pgAdmin:

  1. Open http://localhost:5050
  2. Login with:
    • Email: admin@example.com (or your PGADMIN_EMAIL)
    • Password: admin@123 (or your PGADMIN_PASSWORD)

Connect to Database:

  • The database server is pre-configured in pgAdmin
  • Server name: "Next.js Frontend DB"
  • Host: postgres (internal Docker network)
  • Port: 5432
  • Username: nextjs_db (or your DATABASE_USER)
  • Password: postgres123 (or your DATABASE_PASSWORD)

Build and Deploy

Build Docker Image:

# Build image
make build
# or
docker compose build

# Build for production (no cache)
make prod-build

Deploy to Production:

# Pull latest images and deploy
make prod-deploy
# or
docker compose pull
docker compose up -d --build
docker compose exec app npx prisma migrate deploy

View Service Status:

# Check container status
make status
# or
docker compose ps

# Check health
make health

Development with Docker

Start in Development Mode:

# With hot-reload and development optimizations
make up-dev
# or
docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d

Access Container Shell:

# App container
make shell
# or
docker compose exec app sh

# PostgreSQL container
make shell-postgres
# or
docker compose exec postgres sh

# Redis container
make shell-redis
# or
docker compose exec redis sh

Database Operations

Run Migrations:

# Production migrations
make db-migrate
# or
docker compose exec app npx prisma migrate deploy

# Development migrations
make db-migrate-dev
# or
docker compose exec app npx prisma migrate dev

Seed Database:

make db-seed
# or
docker compose exec app npx prisma db seed

Open Prisma Studio:

make db-studio
# or
docker compose exec app npx prisma studio

Reset Database:

make db-reset
# or
docker compose exec app npx prisma migrate reset --force

Cleanup

Stop and Remove:

# Stop services
make down

# Stop and remove volumes (clean slate)
make clean

# Remove images
make clean-images

# Full cleanup (prune everything)
make prune

Automatic Database Setup

The start.sh script automatically handles database setup on container startup:

Features:

  • βœ… Waits for database to be ready (configurable timeout)
  • βœ… Runs Prisma migrations automatically
  • βœ… Seeds database with default data (if empty)
  • βœ… Generates Prisma Client if needed
  • βœ… Handles errors gracefully with retries

Environment Variables:

# Database wait settings
WAIT_FOR_DB=true              # Wait for database (default: true)
DB_WAIT_TIMEOUT=60            # Wait timeout in seconds (default: 60)

# Migration & seed settings
SKIP_MIGRATIONS=false         # Skip migrations (default: false)
SKIP_SEED=false               # Skip seeding (default: false)
FORCE_SEED=false              # Force seed even if data exists (default: false)

Manual Control:

# Skip migrations on startup
SKIP_MIGRATIONS=true docker compose up -d

# Skip seeding on startup
SKIP_SEED=true docker compose up -d

# Force seed even if data exists
FORCE_SEED=true docker compose up -d

Production Deployment

Recommended Production Setup:

  1. Use external PostgreSQL (managed database service)
  2. Use external Redis (managed cache service)
  3. Configure environment variables for production
  4. Enable Nginx reverse proxy (optional)
  5. Set up SSL/TLS certificates
  6. Configure backups for database
  7. Set up monitoring and logging

Start with Nginx:

make up-nginx
# or
docker compose --profile with-nginx up -d

Database Connection

From Host Machine:

# Connect to PostgreSQL
psql -h localhost -p 5432 -U nextjs_db -d postgres

# Or using Docker
docker compose exec postgres psql -U nextjs_db -d postgres

Connection String:

postgresql://nextjs_db:postgres123@localhost:5432/postgres

From Application (Docker Network):

postgresql://nextjs_db:postgres123@postgres:5432/postgres

πŸ“ Available Scripts

NPM Scripts

# Development
npm run dev              # Start development server
npm run build            # Build for production
npm start                # Start production server

# Database
npm run db:generate      # Generate Prisma Client
npm run db:push          # Push schema to database
npm run db:seed          # Seed database
npm run db:studio        # Open Prisma Studio
npm run db:migrate       # Run migrations

# PM2 (Process Manager)
npm run pm2:start        # Start with PM2
npm run pm2:stop         # Stop PM2 process
npm run pm2:restart      # Restart PM2 process
npm run pm2:logs         # View PM2 logs

# Linting & Formatting
npm run lint             # Run ESLint
npm run format           # Format code with Prettier

Make Commands (Docker Management)

The project includes a comprehensive Makefile for convenient Docker management:

# Docker Commands
make build               # Build Docker images
make up                  # Start all services
make up-dev              # Start in development mode
make up-nginx            # Start with Nginx reverse proxy
make down                # Stop all services
make restart             # Restart all services
make logs                # View all service logs
make logs-app            # View app logs only
make logs-db             # View database logs only
make logs-redis          # View Redis logs only
make logs-pgadmin        # View pgAdmin logs only

# Database Commands
make db-shell            # Open PostgreSQL shell
make db-migrate          # Run Prisma migrations
make db-migrate-dev      # Run development migrations
make db-seed             # Seed the database
make db-reset            # Reset database (migrate + seed)
make db-studio           # Open Prisma Studio
make db-generate         # Generate Prisma Client
make db-push             # Push schema to database

# Utility Commands
make shell               # Open bash shell in app container
make shell-postgres      # Open shell in postgres container
make shell-redis         # Open shell in redis container
make status              # Show container status
make health              # Check service health

# Cleanup Commands
make clean               # Stop services and remove volumes
make clean-images        # Remove Docker images
make prune               # Clean up all Docker resources

# Development Commands
make dev                 # Start local development server
make install             # Install dependencies
make lint                # Run linter
make format              # Format code

# Production Commands
make prod-build          # Build for production (no cache)
make prod-up             # Start production services
make prod-deploy         # Deploy to production

# Help
make help                # Show all available commands

Quick Reference:

Command Description
make up Start all services
make down Stop all services
make logs View logs
make db-shell Open database shell
make db-migrate Run migrations
make shell Open app container
make clean Clean up everything

πŸ”’ Security Features

  • JWT Authentication: Secure token-based authentication
  • Password Hashing: bcrypt with configurable salt rounds
  • Token Blacklisting: Redis-based token invalidation
  • Permission Guards: Route and component-level protection
  • Input Validation: Server-side validation for all inputs
  • CORS Protection: Configurable CORS origins
  • Rate Limiting: Request throttling (via backend)
  • Secure Headers: Helmet.js security headers
  • Media Access Control: Access keys for private media

🎨 Theming

The application supports three theme modes:

  • Light Mode: Bright, clean interface
  • Dark Mode: Dark, eye-friendly interface
  • System Mode: Automatically follows system preference

Theme Switching:

import { useTheme } from "@context/ThemeContext"

function ThemeToggle() {
  const { theme, setTheme } = useTheme()
  
  return (
    <select value={theme} onChange={(e) => setTheme(e.target.value)}>
      <option value="light">Light</option>
      <option value="dark">Dark</option>
      <option value="dynamic">System</option>
    </select>
  )
}

πŸ“Š Performance Optimizations

  • Image Optimization: Next.js Image component with caching
  • Code Splitting: Automatic route-based code splitting
  • Lazy Loading: Dynamic imports for heavy components
  • Client-side Caching: Media and image caching
  • Server-side Caching: Redis caching for API responses
  • Optimistic Updates: Immediate UI updates with background sync
  • Debouncing: Debounced search and input handlers
  • Memoization: React.memo and useMemo for expensive computations

πŸ§ͺ Testing

# Run tests (when implemented)
npm test

# Run tests in watch mode
npm test:watch

# Run tests with coverage
npm test:coverage

πŸ”§ Troubleshooting

Docker Issues

Services won't start:

# Check if ports are already in use
netstat -tulpn | grep -E '3000|5432|6379|5050'

# Stop conflicting services or change ports in .env

Database connection errors:

# Check if database is ready
make health
# or
docker compose exec postgres pg_isready -U postgres

# View database logs
make logs-db

Migrations failing:

# Reset database and try again
make db-reset

# Or manually run migrations
make db-migrate

Volume permission issues:

# Fix permissions
sudo chown -R $USER:$USER ./volumes

Container won't start:

# Check logs
make logs

# Rebuild containers
make clean
make build
make up

Database Issues

Can't connect to database:

  1. Check if PostgreSQL container is running: docker compose ps
  2. Verify environment variables in .env
  3. Check database logs: make logs-db
  4. Try connecting manually: make db-shell

Migrations not running:

  1. Check SKIP_MIGRATIONS environment variable
  2. Manually run: make db-migrate
  3. Check Prisma schema: npx prisma validate

Seed data not loading:

  1. Check if database is empty: make db-shell then SELECT COUNT(*) FROM "User";
  2. Force seed: FORCE_SEED=true docker compose up -d
  3. Manually seed: make db-seed

pgAdmin Issues

Can't access pgAdmin:

  1. Check if pgAdmin is running: docker compose ps pgadmin
  2. Verify port 5050 is not in use
  3. Check logs: make logs-pgadmin
  4. Verify credentials in .env file

Can't connect to database in pgAdmin:

  1. Use postgres as hostname (Docker network)
  2. Port: 5432
  3. Username: postgres (or your DATABASE_USER)
  4. Password: postgres123 (or your DATABASE_PASSWORD)

Redis Issues

Redis connection errors:

# Check if Redis is running
docker compose ps redis

# Test Redis connection
docker compose exec redis redis-cli ping

# View Redis logs
make logs-redis

Application Issues

App won't start:

  1. Check logs: make logs-app
  2. Verify environment variables
  3. Check database connection
  4. Rebuild: make clean && make build && make up

Build errors:

# Clean build
make clean
make build

# Check for TypeScript errors
npm run lint

πŸ“„ License

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

πŸ™ Acknowledgments

Built with amazing open-source technologies:


Made with ❀️ using modern web technologies

This project is free to use, modify, and distribute for any purpose without restrictions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages