Skip to content
DivyanshuChipa edited this page Jan 22, 2026 · 1 revision

Welcome to the IntraChat-Android-FastAPI wiki!

πŸ”§ API Endpoints

Authentication

Method Endpoint Description
POST /register Register new user
POST /login Login and get JWT token
POST /delete_account Delete user account (requires password)

Chat

Method Endpoint Description
WebSocket /ws/{username} Real-time messaging
GET /messages Get recent messages (last 100)
GET /users Get all registered users with profile photos

Files

Method Endpoint Description
POST /upload Upload a file (chat attachments)
GET /uploads/{filename} Download/view uploaded file
POST /profile/upload_profile Upload profile photo
GET /uploads/profiles/{filename} Get user profile photo

Static Files

Method Endpoint Description
GET / Web client (index.html)
GET /chat.html Chat interface
GET /style.css Stylesheets
GET /app.js JavaScript logic

πŸ› οΈ Technologies Used

Backend

  • FastAPI - Modern, fast web framework
  • Uvicorn - ASGI server
  • WebSockets - Real-time communication
  • SQLite - Lightweight database
  • JWT - Secure authentication
  • Passlib - Password hashing
  • Pillow - Image processing for profile photos
  • Aiofiles - Async file operations

Web Client

  • HTML5 - Semantic markup
  • CSS3 - Modern styling with CSS variables (dark/light themes)
  • Vanilla JavaScript - No frameworks, pure JS
  • WebSocket API - Real-time messaging
  • Fetch API - RESTful API calls
  • LocalStorage - Client-side session management
  • Responsive Design - Mobile-first approach

Android App

  • Kotlin - Modern Android development
  • Jetpack Compose - Declarative UI
  • Room Database - Local data persistence
  • Retrofit - HTTP client
  • OkHttp - WebSocket client
  • Coroutines - Asynchronous programming
  • Material Design 3 - Modern UI components
  • Coil - Image loading library

πŸ”’ Security Features

  • πŸ” Password hashing with PBKDF2-SHA256
  • 🎫 JWT token-based authentication (30-day expiry)
  • πŸ›‘οΈ CORS protection configured for LAN access
  • πŸ“ Input sanitization for file uploads
  • πŸ”’ Secure WebSocket connections
  • 🚫 SQL injection prevention via parameterized queries
  • πŸ“ File upload size limits and type validation
  • πŸ—‘οΈ Secure account deletion with password verification

πŸ› Troubleshooting

Server Issues

Problem: Server won't start

# Check if port 8000 is already in use
sudo lsof -i :8000

# Kill the process if needed
sudo kill -9 <PID>

Problem: Can't access from other devices

  • βœ… Ensure server is running with --host 0.0.0.0
  • βœ… Check firewall settings:
    sudo ufw allow 8000/tcp
  • βœ… Verify all devices are on the same Wi-Fi network

Problem: Profile photos not loading

# Check uploads folder permissions
ls -la uploads/
chmod 755 uploads/
chmod 755 uploads/profiles/

Web Client Issues

Problem: Can't connect to server

  • βœ… Check browser console (F12) for errors
  • βœ… Verify server IP address is correct in URL
  • βœ… Ensure server is running (http://IP:8000 should show login page)

Problem: WebSocket connection fails

  • βœ… Check browser console for WebSocket errors
  • βœ… Some browsers block ws:// on HTTPS pages (use HTTP for both)
  • βœ… Restart server if WebSocket hangs

Problem: Theme not switching

  • βœ… Clear browser cache (Ctrl+Shift+Delete)
  • βœ… Check LocalStorage in DevTools (F12 β†’ Application β†’ LocalStorage)

Android App Issues

Problem: Build errors in Android Studio

# Clean and rebuild
./gradlew clean
./gradlew build

Problem: App can't connect to server

  • βœ… Check ApiClient.kt for correct server IP (or use in-app settings)
  • βœ… Ensure server is running and reachable
  • βœ… Test connection in browser first: http://SERVER_IP:8000
  • βœ… Check Logcat for detailed error messages

Problem: Profile photos not showing

  • βœ… Grant storage permissions in Android settings
  • βœ… Clear app cache: Settings β†’ Apps β†’ Intra β†’ Storage β†’ Clear Cache
  • βœ… Re-upload photo from Settings screen