This guide will walk you through setting up both the frontend and backend for the Longhorn Studies application.
- Python 3.8 or higher
- pip (Python package manager)
- Virtual environment support
- Node.js 14.x or higher
- npm (comes with Node.js)
- Expo CLI (will be installed automatically)
- Git (for cloning and version control)
- A code editor (VS Code, PyCharm, etc.)
cd backendpython -m venv venvOn macOS/Linux:
source venv/bin/activateOn Windows:
venv\Scripts\activatepip install -r requirements.txtcp .env.example .env
# Edit .env file if neededpython app.pyThe backend will be available at: http://localhost:8000
Verify it's working:
curl http://localhost:8000/api/healthYou should see:
{
"status": "healthy",
"message": "Longhorn Studies API is running",
"timestamp": "..."
}cd frontendnpm installThis will install all required packages including React, React Native, Expo, and Axios.
npm startThis will start the Expo development server and show you a QR code.
Once the Expo server starts, you can:
Web (Easiest to test):
- Press
win the terminal - Your default browser will open with the app
Mobile Device (iOS/Android):
- Install "Expo Go" from App Store (iOS) or Play Store (Android)
- Scan the QR code shown in the terminal
- The app will load on your device
iOS Simulator (macOS only):
- Press
iin the terminal - Requires Xcode to be installed
Android Emulator:
- Press
ain the terminal - Requires Android Studio to be installed
Run the integration test script:
# Make sure backend is running first
cd backend
python app.py
# In another terminal:
bash test_integration.sh-
Start the backend:
cd backend source venv/bin/activate # or venv\Scripts\activate on Windows python app.py
-
Start the frontend:
cd frontend npm start # Press 'w' for web
-
Test the flow:
- The frontend will load and automatically try to fetch items
- Try adding a new item using the input field
- Click "Add" to create an item
- Click "Delete" to remove an item
- Click "Refresh Items" to reload the list
You can test the API directly:
# Health check
curl http://localhost:8000/api/health
# Get all items
curl http://localhost:8000/api/items
# Create an item
curl -X POST http://localhost:8000/api/items \
-H "Content-Type: application/json" \
-d '{"name": "Test Item", "description": "Test description"}'
# Get specific item
curl http://localhost:8000/api/items/1
# Update an item
curl -X PUT http://localhost:8000/api/items/1 \
-H "Content-Type: application/json" \
-d '{"name": "Updated Item"}'
# Delete an item
curl -X DELETE http://localhost:8000/api/items/1Problem: Port 8000 is already in use
# Find and kill the process
lsof -ti:8000 | xargs kill -9
# Or change the port in backend/app.pyProblem: Module not found
# Make sure virtual environment is activated
source venv/bin/activate # or venv\Scripts\activate
pip install -r requirements.txtProblem: Database error
# Delete the database and let it recreate
rm instance/longhorn_studies.db
python app.pyProblem: Network request failed
- Make sure the backend is running on port 8000
- Check the
API_BASE_URLinfrontend/App.js - If testing on a physical device, use your computer's IP address instead of localhost
Problem: npm install fails
# Clear npm cache
npm cache clean --force
rm -rf node_modules package-lock.json
npm installProblem: Expo won't start
# Clear Expo cache
npx expo start -cProblem: Can't connect from mobile device
- Make sure your computer and phone are on the same WiFi network
- Update
API_BASE_URLinApp.jsto use your computer's IP:const API_BASE_URL = 'http://YOUR_COMPUTER_IP:8000/api';
Problem: Need to reset the database
cd backend
rm instance/longhorn_studies.db
python app.py # Will recreate the databaseProblem: Want to use PostgreSQL instead of SQLite
- Install PostgreSQL and create a database
- Update
.envfile:DATABASE_URL=postgresql://username:password@localhost:5432/database_name - Install psycopg2:
pip install psycopg2-binary
-
Start backend:
cd backend source venv/bin/activate python app.py
-
Start frontend (in new terminal):
cd frontend npm start -
Make changes:
- Backend changes: Server will auto-reload
- Frontend changes: Expo will hot-reload automatically
-
Test changes:
- Use the web interface or mobile app
- Check backend logs in terminal
- Use browser developer tools for frontend debugging
VS Code Extensions:
- Python
- Pylance
- React Native Tools
- ESLint
- Prettier
PyCharm/IntelliJ:
- Python support (built-in)
- React Native console plugin
After getting everything running, consider:
-
Add authentication:
- Implement JWT tokens
- Add login/signup pages
- Protect API routes
-
Improve the UI:
- Add more styling
- Implement navigation
- Add loading indicators
-
Expand the API:
- Add more models
- Implement relationships
- Add pagination
-
Deploy:
- Deploy backend to Heroku/AWS/DigitalOcean
- Deploy frontend to Expo
- Set up continuous deployment
- Flask Documentation
- SQLAlchemy Documentation
- React Native Documentation
- Expo Documentation
- Axios Documentation
If you encounter issues:
- Check the troubleshooting section above
- Review the logs in both terminals
- Check that all dependencies are installed correctly
- Ensure both frontend and backend are running