A complete social media news feed application built with React, TypeScript, Node.js, Express, and PostgreSQL.
- User Authentication: Register, login, logout with JWT tokens
- News Feed: View posts from followed users with infinite scroll
- Post Creation: Create text posts (max 200 characters)
- Follow System: Follow/unfollow other users
- User Discovery: Browse and discover users to follow
- JWT Refresh Tokens: Automatic token refresh for seamless user experience
- Infinite Scroll: Smooth pagination with automatic loading
- Real-time Updates: Feed refreshes on new posts and follow changes
- Responsive Design: Mobile-friendly interface
- Error Handling: Comprehensive error management and user feedback
- Rate Limiting: API protection with configurable rate limits
- Docker Support: Full containerization for easy deployment
- Components: Modular React components with TypeScript
- State Management: React Context API for global state
- API Integration: Axios with automatic token refresh interceptors
- Styling: CSS modules for component styling
- Error Boundaries: React error boundaries for graceful error handling
- RESTful API: Clean API design with proper HTTP status codes
- Authentication: JWT with refresh token rotation
- Database: PostgreSQL with connection pooling
- Validation: Input validation using Joi schemas
- Security: Helmet, CORS, rate limiting, password hashing
- Error Handling: Centralized error handling middleware
- Users Table: User accounts with hashed passwords
- Posts Table: User posts with content and timestamps
- Follows Table: User follow relationships
- Refresh Tokens Table: Secure token management
- Node.js (v18 or higher)
- PostgreSQL (v13 or higher)
- Docker and Docker Compose (optional)
-
Clone the repository
git clone <repository-url> cd news-feed-system
-
Start with Docker Compose
# Start all services docker-compose up -d # View logs docker-compose logs -f
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001
- Health Check: http://localhost:3001/health
-
Navigate to backend directory
cd backend -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your configuration -
Set up PostgreSQL database
# Create database createdb news_feed_db # Run migrations (optional - tables are auto-created) npm run migrate
-
Start the backend server
# Development mode npm run dev # Production mode npm run build npm start
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Set up environment variables
cp .env.example .env # Edit .env with your API URL -
Start the frontend server
# Development mode npm start # Production build npm run build
NODE_ENV=development
PORT=3001
DB_HOST=localhost
DB_PORT=5432
DB_NAME=news_feed_db
DB_USER=postgres
DB_PASSWORD=password
JWT_SECRET=your_super_secret_jwt_key_change_in_production
JWT_REFRESH_SECRET=your_super_secret_refresh_key_change_in_production
JWT_EXPIRES_IN=1h
JWT_REFRESH_EXPIRES_IN=7d
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=100REACT_APP_API_URL=http://localhost:3001/api