A web application for viewing and managing user profiles and activity timelines, built with Python Flask, connected to an AWS PostgreSQL database.
This is the Python version of the original TypeScript/Angular application, with all features preserved.
- Overview
- Features
- Technology Stack
- Quick Start
- Step-by-Step Installation
- Configuration
- Using the Application
- Project Structure
- API Endpoints
- Troubleshooting
- Development Notes
The User Activity Management System provides a clean interface to:
- View all users from the database
- Search users by email, username, or first name
- View detailed activity timelines for each user, including:
- Joined groups
- Applied to groups
- Created invites
- Redeemed invites
- Expressions
- User posts
- Welcome page with system overview
- Quick navigation to main features
- Display all users from the database
- Search functionality (email, username, first name)
- Quick access to view each user's timeline
- Displays user profiles with key information
- Comprehensive activity timeline for each user
- 6 types of activities:
- 👥 Joined Group (Green) - When user joins a group
- 📝 Applied to Group (Blue) - Group applications with status
- ✉️ Created Invite (Orange) - Invites created by the user
- 🎟️ Redeemed Invite (Purple) - Invites redeemed by the user
- 💭 Expression (Cyan) - User expressions (can exist without groups)
- 📄 User Post (Pink) - Posts created by the user
- Chronological display with timestamps
- Color-coded activity types
- Group information (when applicable)
- Backend: Python 3.8+ with Flask
- Frontend: HTML5, CSS3, JavaScript (Vanilla)
- Database: PostgreSQL (AWS RDS)
- API Communication: RESTful API with CORS enabled
- Icons: Font Awesome 6
On macOS/Linux:
# 1. Navigate to project directory
cd User-Interface-for-Group-Activity-Python
# 2. Run setup (one time only)
chmod +x setup.sh run.sh
./setup.sh
# 3. Kill any process using port 5000 (if needed)
lsof -ti:5000 | xargs kill -9 2>/dev/null || true
# 4. Run the application
./run.sh
# 5. Open browser to: http://localhost:5000On Windows:
REM 1. Navigate to project directory
cd User-Interface-for-Group-Activity-Python
REM 2. Run setup (one time only)
setup.bat
REM 3. Kill any process using port 5000 (if needed)
REM Check what's using port 5000: netstat -ano | findstr :5000
REM Then kill it: taskkill /PID <PID> /F
REM 4. Run the application
run.bat
REM 5. Open browser to: http://localhost:5000To stop the application: Press Ctrl + C in the terminal
Note about Port 5000:
- On macOS, AirPlay Receiver uses port 5000 by default
- Step 3 ensures the port is free before starting the application
- Alternative: Disable AirPlay Receiver in System Settings → General → AirDrop & Handoff
Before you begin, verify you have Python installed:
On macOS/Linux:
python3 --versionOn Windows:
python --versionRequired: Python 3.8 or higher
If Python is not installed:
- Download from: https://www.python.org/downloads/
- Important for Windows: Check "Add Python to PATH" during installation
cd User-Interface-for-Group-Activity-PythonVerify you're in the correct directory by checking for these files:
# On macOS/Linux
ls
# On Windows
dirYou should see: app.py, mock_data.py, requirements.txt, templates/, static/
On macOS/Linux:
python3 -m venv venvOn Windows:
python -m venv venvWhat this does: Creates an isolated Python environment in a folder called venv
On macOS/Linux:
source venv/bin/activateOn Windows:
venv\Scripts\activateHow to verify: You should see (venv) at the beginning of your command prompt:
(venv) $
On macOS/Linux:
pip3 install -r requirements.txtOn Windows:
pip install -r requirements.txtExpected output:
Collecting Flask==3.0.0
Collecting Flask-Cors==4.0.0
Collecting psycopg2-binary==2.9.9
Collecting Werkzeug==3.0.1
...
Successfully installed Flask-3.0.0 Flask-Cors-4.0.0 psycopg2-binary-2.9.9 Werkzeug-3.0.1
This installs:
- Flask (web framework)
- Flask-CORS (CORS support)
- psycopg2-binary (PostgreSQL adapter)
- Werkzeug (WSGI utility library)
On macOS/Linux:
python3 app.pyOn Windows:
python app.pyExpected output:
If database connects successfully:
✅ Connected to AWS PostgreSQL database
Database: wander_app
Host: 3.20.185.35
🚀 Server starting on port 5000
📊 Using REAL AWS DATABASE
* Serving Flask app 'app'
* Debug mode: on
* Running on http://0.0.0.0:5000
If database connection fails (this is OK!):
❌ Database connection failed: ...
⚠️ Using MOCK DATA mode
To connect to real database:
1. Connect to VPN if required
2. Verify AWS RDS security group allows your IP
3. Test connection with a PostgreSQL client
🚀 Server starting on port 5000
📊 Running in MOCK DATA mode
* Running on http://0.0.0.0:5000
✅ Both scenarios are fine! The mock data mode lets you explore all features without a database connection.
- Open your web browser (Chrome, Firefox, Safari, or Edge)
- Navigate to: http://localhost:5000
You should see the home page with "User Activity Management System" heading and navigation bar.
When you're done:
- Go to the terminal where the server is running
- Press:
Ctrl + C - (Optional) Deactivate virtual environment:
deactivate
The application is configured to connect to an AWS PostgreSQL database by default.
To modify database credentials, edit app.py and update the DB_CONFIG dictionary:
DB_CONFIG = {
'host': 'YOUR_DATABASE_HOST',
'port': 5432,
'database': 'YOUR_DATABASE_NAME',
'user': 'YOUR_DATABASE_USERNAME',
'password': 'YOUR_DATABASE_PASSWORD',
'sslmode': 'require'
}Important:
- Replace the placeholder values with your actual database credentials
- Keep the
sslmodeconfiguration for AWS RDS connections - Do NOT commit your credentials to version control
- Consider using environment variables for production
If the database connection fails, the application automatically falls back to mock data mode. This allows you to explore all features without a database connection.
The mock data includes:
- 5 sample users
- 7 sample groups
- Multiple activities of all 6 types
Mock data is defined in mock_data.py and can be customized as needed.
Your PostgreSQL database should have the following tables:
users- User profilesgroups- Group informationgroup_members- Group membership recordsgroup_applications- Application recordsgroup_invite_codes- Invite codes createdgroup_invite_redemptions- Invite redemption recordsexpressions- User expressionsuser_post- User posts
The application has three main pages accessible from the top navigation bar:
- 🏠 Home - Landing page with overview
- 👥 All Users - Browse and search users
- 📅 User Timeline - View user activity timelines
Access: http://localhost:5000 or http://localhost:5000/home
What you'll see:
- Welcome message
- System overview
- Feature list
- Database connection status
- Quick action buttons
Try:
- Click "View All Users" button to see user list
- Click "View User Timelines" button to search timelines
Access: Click "All Users" in navigation or go to http://localhost:5000/users
Features:
- When page loads, all users are displayed as cards
- Each card shows:
- Username
- First Name
- User Focus
- Interests
- Connection Type
- Age Preference
- Summary
By Email:
- Enter email (or part of it) in the "Email" field
- Click "Search"
- Results filter to show matching users
Example: Type gmail.com to find all users with Gmail addresses
By Username:
- Enter username (or part of it) in the "Username" field
- Click "Search"
- Results filter to show matching users
Example: Type sarah to find user "sarahsmith"
By First Name:
- Enter first name (or part of it) in the "First Name" field
- Click "Search"
- Results filter to show matching users
Example: Type John to find all users named John
Show All Users:
- Click "Show All Users" button to reset and display all users
- Click the "View Timeline" button on any user card
- You'll be taken to that user's complete activity timeline
Access: Click "User Timeline" in navigation or go to http://localhost:5000/timeline
Features:
- Enter search criteria in any of the fields:
- Email (e.g.,
gaoyangyijun@gmail.com) - Username (e.g.,
johndoe) - First Name (e.g.,
John)
- Email (e.g.,
- Click "Search Timeline"
- User info appears at top
- Timeline displays below with all activities
- Click "View Timeline" on any user card in the All Users page
- Timeline loads automatically
Activity Types and Colors:
👥 Joined Group (Green)
- When: User joins a group
- Shows: Group name, location, time, join date
📝 Applied to Group (Blue)
- When: User applies to join a group
- Shows: Group name, application status (pending/approved/rejected), decision date
✉️ Created Invite (Orange)
- When: User creates an invite code for a group
- Shows: Invite code, expiration date, number of times used
🎟️ Redeemed Invite (Purple)
- When: User redeems someone else's invite code
- Shows: Invite ID, redemption ID, group joined
💭 Expression (Cyan)
- When: User answers questions or shares thoughts
- Shows: Topic, AI question, user's answer, context
- Note: Can exist without being tied to a group
📄 User Post (Pink)
- When: User creates a post in a group
- Shows: Post content, group name, timestamps
Timeline Features:
- Activities are sorted chronologically (newest first)
- Each activity shows the exact timestamp
- Hover over activity cards for highlighting effect
- Scroll to see all activities
- Go to "All Users" page
- Search by email:
gaoyangyijun@gmail.com - Click "View Timeline" on John Doe's card
- See all his activities:
- Groups he joined
- Invites he created
- Posts he made
- His expressions
- Go to "User Timeline" page
- Enter username:
johndoe - Click "Search Timeline"
- View his complete activity history
- Go to "All Users" page
- Scroll through user cards
- Compare different users' profiles
- View timelines of multiple users
User-Interface-for-Group-Activity-Python/
├── app.py # Main Flask application (backend)
├── mock_data.py # Mock data for testing
├── requirements.txt # Python dependencies
├── README.md # This file
├── .gitignore # Git ignore rules
├── setup.sh / setup.bat # Setup scripts
├── run.sh / run.bat # Run scripts
├── templates/ # HTML templates (frontend)
│ ├── base.html # Base template with navigation
│ ├── home.html # Home page
│ ├── users.html # All users page
│ └── timeline.html # Timeline page
└── static/ # Static files
└── css/
└── style.css # Global styles
The Flask backend provides the following RESTful API endpoints:
| Method | Endpoint | Description | Query Parameters |
|---|---|---|---|
| GET | /api/users |
Get all users | None |
| GET | /api/users/search |
Search users | query (search term), type (email/username/first_name) |
| GET | /api/users/<userId>/timeline |
Get timeline for specific user | None |
| GET | /api/users/timeline/search |
Search user timeline | email, username, first_name (at least one required) |
Get all users:
curl http://localhost:5000/api/usersSearch users by email:
curl "http://localhost:5000/api/users/search?query=example@email.com&type=email"Get user timeline:
curl http://localhost:5000/api/users/1/timelineSearch timeline by email:
curl "http://localhost:5000/api/users/timeline/search?email=gaoyangyijun@gmail.com"Error: Address already in use
Solution:
On macOS/Linux:
lsof -ti:5000 | xargs kill -9
python3 app.pyOn Windows:
netstat -ano | findstr :5000
taskkill /PID <PID> /F
python app.pyReplace <PID> with the actual process ID shown.
Solution: Try using python instead:
python --version
python -m venv venv
python app.pyError: ModuleNotFoundError: No module named 'flask'
Solution:
# Make sure virtual environment is activated
source venv/bin/activate # macOS/Linux
# venv\Scripts\activate # Windows
# Reinstall dependencies
pip install -r requirements.txtSolution: Delete and recreate it:
On macOS/Linux:
rm -rf venv
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txtOn Windows:
rmdir /s venv
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txtError: Database connection failed
This is OK! The application automatically switches to mock data mode.
Why it happens:
- Database server might be down
- Your IP might not be whitelisted in AWS Security Groups
- Network issues
- Incorrect credentials
To fix (optional):
- Verify your database host is accessible
- Check database credentials in
app.py - Ensure your IP address is whitelisted in AWS Security Groups
- Test connection using a PostgreSQL client (e.g., DBeaver)
To use mock data: No action needed - it's automatic!
Error: "Site can't be reached"
Check:
- Is the server running? Look for "Running on http://0.0.0.0:5000" in terminal
- Is the URL correct? Should be
http://localhost:5000 - Try
http://127.0.0.1:5000instead - Check if port 5000 is blocked by firewall
Solution: Make scripts executable:
chmod +x setup.sh run.sh
./setup.shSolutions:
- Refresh the page
- Check browser console for errors (F12)
- Check terminal for error messages
- Verify server is running
- Try clicking "Show All Users" button
The application runs in debug mode by default:
app.run(debug=True, host='0.0.0.0', port=5000)This enables:
- Auto-reload on code changes
- Detailed error messages
- Interactive debugger
For production, set debug=False
Edit mock_data.py to add more test users, groups, or activities:
mock_users = [
{
'user_id': '6',
'username': 'newuser',
'email': 'newuser@example.com',
'first_name': 'New',
# ... other fields
}
]Edit app.py and change the port number:
app.run(debug=True, host='0.0.0.0', port=5001) # Changed from 5000 to 5001Then access at: http://localhost:5001
For production deployment, use environment variables for sensitive data:
import os
DB_CONFIG = {
'host': os.environ.get('DB_HOST'),
'port': int(os.environ.get('DB_PORT', 5432)),
'database': os.environ.get('DB_NAME'),
'user': os.environ.get('DB_USER'),
'password': os.environ.get('DB_PASSWORD'),
'sslmode': 'require'
}For production use:
- Use a production WSGI server:
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app-
Set debug to False in
app.py -
Use environment variables for credentials
-
Set up reverse proxy (nginx or Apache)
-
Enable HTTPS
Tested and working on:
- ✅ Chrome (recommended)
- ✅ Firefox
- ✅ Safari
- ✅ Edge
Minimum:
- Python 3.8 or higher
- 100 MB free disk space
- 512 MB RAM
- Any modern web browser
Recommended:
- Python 3.10 or higher
- 500 MB free disk space
- 1 GB RAM
- Chrome or Firefox browser
Operating Systems:
- ✅ macOS 10.14 or higher
- ✅ Windows 10 or higher
- ✅ Linux (Ubuntu 18.04+, Debian 10+, CentOS 7+, etc.)
After installation, verify these work:
- Server starts without errors
- Home page loads at http://localhost:5000
- Navigation bar is visible with 3 links
- "All Users" page shows user cards
- Email search works
- Username search works
- First name search works
- "View Timeline" button works
- Timeline displays colored activities
- All 6 activity types are visible
- Timeline search works
- Server stops cleanly with Ctrl+C
Start Application:
# Automated
./run.sh # macOS/Linux
run.bat # Windows
# Manual
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
python app.pyStop Application:
Press Ctrl + C
Reinstall Everything:
# Delete virtual environment
rm -rf venv # macOS/Linux
rmdir /s venv # Windows
# Run setup again
./setup.sh # macOS/Linux
setup.bat # WindowsAccess Application:
http://localhost:5000
If you encounter issues not covered in this guide:
- Check the terminal output - Error messages usually explain the problem
- Review the Troubleshooting section above
- Verify your Python version - Must be 3.8 or higher
- Try the manual installation - Sometimes automated scripts have issues
- Check port availability - Port 5000 must be free
This application is a complete Python/Flask port of the original TypeScript/Angular version. All features have been preserved:
What changed:
- Backend: Node.js/Express → Python/Flask
- Frontend: Angular → HTML/CSS/JavaScript (Vanilla)
- Port: 3000 → 5000
What stayed the same:
- ✅ All features and functionality
- ✅ User interface and design
- ✅ API endpoints (same structure)
- ✅ Database queries (identical SQL)
- ✅ 6 activity types with same colors
This project was created for educational purposes.
If you can:
- ✅ Start the server
- ✅ Open http://localhost:5000 in your browser
- ✅ See the home page
- ✅ Navigate between pages
- ✅ Search for users
- ✅ View timelines with colored activities
Congratulations! Your installation is complete and working! 🎉
Enjoy using the User Activity Management System!