A simple full-stack web application with a Python Flask backend and TypeScript frontend.
test/
├── backend/
│ ├── app.py # Flask application
│ └── requirements.txt # Python dependencies
├── frontend/
│ ├── index.html # Main HTML page
│ ├── style.css # Styling
│ ├── script.ts # TypeScript source
│ ├── script.js # Compiled JavaScript
│ └── tsconfig.json # TypeScript config
├── test/
│ ├── backend_api_test.py # Backend API tests
│ ├── frontend_ui_test.py # Frontend UI tests with AI vision
│ ├── requirements.txt # Test dependencies
│ ├── run_tests.sh # Linux/Mac test runner
│ ├── run_tests.bat # Windows test runner
│ ├── screenshots/ # Test screenshots (generated)
│ ├── README.md # Test documentation
│ └── TROUBLESHOOTING.md # Troubleshooting guide
├── TESTCASES.md # Test cases documentation
└── README.md # This file
- Python 3.8+
- Node.js 16+ (for TypeScript compilation)
- A web browser
cd backend
pip install -r requirements.txtnpm install -g typescriptcd frontend
tscThis compiles script.ts to script.js.
cd backend
python app.pyThe backend will start on http://localhost:5000. You should see:
Starting Flask server on http://localhost:5000
Endpoints:
POST /register - Register a new user
POST /login - Authenticate a user
POST /reset_users - Reset user database (testing only)
Simply open frontend/index.html in your web browser:
- Double-click the file in your file explorer, or
- Use
file:///URL in your browser, or - Serve it with a simple HTTP server:
python -m http.server 8000in the frontend directory
Registers a new user.
Request:
{
"username": "string",
"password": "string"
}Success Response (200 OK):
{
"success": true,
"message": "Registration successful"
}Error Responses:
- 409 Conflict - Username already exists:
{
"success": false,
"message": "Username already exists"
}- 400 Bad Request - Empty username or password:
{
"success": false,
"message": "Username and password are required"
}Authenticates a user.
Request:
{
"username": "string",
"password": "string"
}Success Response (200 OK):
{
"success": true,
"message": "Login successful",
"username": "string"
}Error Responses (401 Unauthorized):
{
"success": false,
"message": "User not found"
}or
{
"success": false,
"message": "Incorrect password"
}Resets the user database (for testing only).
Response (200 OK):
{
"success": true,
"message": "Users reset"
}Run all tests (both backend API and frontend UI) with a single command:
Windows:
test\run_tests.batLinux/Mac:
chmod +x test/run_tests.sh
./test/run_tests.shThe test suite will:
- Install all dependencies automatically
- Start backend and frontend servers
- Run backend API tests (pytest)
- Run frontend UI tests (Playwright with AI vision)
- Capture screenshots for visual verification
- Display detailed test results
The frontend tests use AI Vision (Qwen2.5-VL-72B-Instruct via https://llmapi.paratera.com) to analyze screenshots and verify:
- Error messages are displayed correctly (red text, error banners)
- Success states show proper UI (welcome message, green indicators)
- Page transitions work as expected
Configuration:
- API URL:
https://llmapi.paratera.com - Model:
Qwen2.5-VL-72B-Instruct - API Key: Built-in (no configuration needed)
You can override these with environment variables:
# Windows
set AI_API_KEY=your_key
set AI_API_URL=your_url
set AI_MODEL=your_model
# Linux/Mac
export AI_API_KEY=your_key
export AI_API_URL=your_url
export AI_MODEL=your_modelSee test/README.md for more details on automated testing.
- Ensure the backend is running (
python backend/app.py) - Open
frontend/index.htmlin your browser - Test the main scenarios:
- Try logging in with unregistered credentials
- Register a new user
- Log in with correct credentials
- Log in with incorrect password
- Try to register with empty fields
Make sure the backend is running, then execute:
# Scenario 1: Unregistered user login
curl -X POST http://localhost:5000/login -H "Content-Type: application/json" -d '{"username":"nonexistent","password":"anypass"}'
# Scenario 4: Register new user
curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{"username":"testuser","password":"testpass123"}'
# Scenario 2: Login with correct credentials
curl -X POST http://localhost:5000/login -H "Content-Type: application/json" -d '{"username":"testuser","password":"testpass123"}'
# Scenario 3: Login with incorrect password
curl -X POST http://localhost:5000/login -H "Content-Type: application/json" -d '{"username":"testuser","password":"wrongpass"}'
# Scenario 5: Register existing username
curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{"username":"testuser","password":"anotherpass"}'
# Scenario 6: Register with empty fields
curl -X POST http://localhost:5000/register -H "Content-Type: application/json" -d '{"username":"","password":""}'- Passwords are stored in plain text (no hashing)
- User data is stored in-memory (lost on server restart)
- No session management or JWT tokens
- No input sanitization beyond basic validation
In a production application, you would need:
- Password hashing (bcrypt, argon2)
- Persistent database (PostgreSQL, MongoDB)
- Session management or JWT authentication
- Input validation and sanitization
- Rate limiting and CSRF protection
All test cases from TESTCASES.md have been verified:
| Scenario | Status |
|---|---|
| Unregistered user login | ✅ Pass - Returns "User not found" |
| Login with correct credentials | ✅ Pass - Shows welcome message |
| Login with incorrect password | ✅ Pass - Returns "Incorrect password" |
| Register new user | ✅ Pass - Creates user successfully |
| Register existing username | ✅ Pass - Returns "Username already exists" |
| Register with empty fields | ✅ Pass - Returns "Username and password are required" |
Backend won't start:
- Ensure Python 3.8+ is installed
- Check that Flask is installed:
pip show flask - Check that port 5000 is not in use by another application
Frontend shows connection errors:
- Verify the backend is running on
http://localhost:5000 - Check browser console for CORS errors
- Ensure flask-cors is installed
TypeScript compilation issues:
- Ensure TypeScript is installed:
tsc --version - Check that
tsconfig.jsonexists in the frontend directory
Tests fail with AI API errors:
- Check that the AI API is accessible:
curl https://llmapi.paratera.com - Verify your network connection to the API server
Python 3.13 compatibility issues: See test/TROUBLESHOOTING.md for detailed solutions to common Python 3.13 issues.