Full-stack AI web application combining Flask, FastAPI, DeepFace, OCR, and real-time NSE stock analytics.
Features β’ Architecture β’ Demo β’ Installation
Full-stack AI web application combining Flask, FastAPI, DeepFace, OCR, and NSE stock analytics.
A comprehensive Flask web application with FastAPI integration, featuring user management, image gallery, stock market dashboard, and AI-powered image processing.
- User Authentication - Secure login system with session management
- User Management - Full CRUD operations via FastAPI REST API
- Image Gallery - Upload and manage images with OCR text extraction
- Stock Market Dashboard - Real-time Indian stock market data (NSE)
- AI Hair Style Processing - Gender detection and hair style variants using DeepFace
- FastAPI Integration - Modern REST API for user operations
- Responsive UI - Modern glassmorphism design with smooth animations
- Python 3.8 or higher
- MySQL Server
- Tesseract OCR
- Git
git clone https://github.com/herrytest/advance-python-learning.git
cd advance-python-learningpython3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install flask mysql-connector-python pandas yfinance nsepython deepface easyocr opencv-python pytesseract psutil scikit-learn fastapi uvicorn pydanticsudo apt-get update
sudo apt-get install tesseract-ocr mysql-serverbrew install tesseract mysql# Login to MySQL
mysql -u root -p
# Create database and user
CREATE DATABASE laravel;
CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON laravel.* TO 'laravel'@'localhost';
FLUSH PRIVILEGES;
EXIT;Edit db.py if you need to change database credentials:
DB_CONFIG = {
'user': 'laravel',
'password': 'password',
'host': '127.0.0.1',
'database': 'laravel',
'raise_on_warnings': False
}Before starting the application, run the migration script to create all necessary tables and seed initial data:
python3 apply_migration.pymkdir -p uploadspython app.pyThe Flask app will run on: http://localhost:5000
Open a new terminal and run:
source venv/bin/activate # Activate virtual environment
uvicorn fastapi_users:app --reload --port 8000Or use the startup script:
./start_fastapi.shThe FastAPI service will run on: http://localhost:8000
API Documentation: http://localhost:8000/docs
- Username:
admin - Password:
123456
POST /api/users- Create a new userGET /api/users- Get all usersGET /api/users/{id}- Get user by IDPUT /api/users/{id}- Update userDELETE /api/users/{id}- Delete user
GET /api/test/hello- Simple hello worldGET /api/test/echo/{text}- Echo text with transformationsPOST /api/test/calculate- Calculator APIGET /api/test/status- API and database status
/- Login page/dashboard- Stock market dashboard/users- User management/gallery- Image gallery/upload- Upload images
myproject/
βββ app.py # Main Flask application
βββ fastapi_users.py # FastAPI user management service
βββ db.py # Database functions (Django ORM)
βββ models.py # Django model definitions
βββ django_settings.py # Minimal Django configuration
βββ init_db.sql # Database migration script (SQL)
βββ apply_migration.py # Migration runner (Python)
βββ ml.py # Machine learning utilities
βββ templates/ # HTML templates
β βββ base.html
β βββ login.html
β βββ dashboard.html
β βββ users.html
β βββ gallery.html
β βββ upload.html
βββ static/ # Static assets
β βββ css/
β βββ hair_assets/
βββ uploads/ # Uploaded files
βββ start_fastapi.sh # FastAPI startup script
βββ README.md
Edit app.py:
USERNAME = "admin"
PASSWORD = "123456"Edit the fetch_stock_data() function in app.py to customize stock symbols.
# Test hello endpoint
curl http://localhost:8000/api/test/hello
# Test user list
curl http://localhost:8000/api/users
# Test calculator
curl -X POST "http://localhost:8000/api/test/calculate?num1=10&num2=5&operation=add"- Open browser and navigate to
http://localhost:5000 - Login with default credentials
- Test dashboard, gallery, and user management features
- Flask - Web framework
- FastAPI - Modern API framework
- Uvicorn - ASGI server
- Pydantic - Data validation
- MySQL Connector - Database connection
- Pandas - Data manipulation
- yfinance - Stock market data
- nsepython - NSE India stock data
- DeepFace - Face analysis and recognition
- EasyOCR - Optical character recognition
- OpenCV - Image processing
- Pytesseract - OCR engine
- Scikit-learn - Machine learning
Make sure MySQL is running:
sudo systemctl start mysql # Linux
brew services start mysql # macOSInstall Tesseract OCR and verify installation:
tesseract --versionChange the port in app.py or fastapi_users.py:
app.run(debug=True, port=5001) # Flask
uvicorn.run(app, port=8001) # FastAPIThe DeepFace library will show warnings if CUDA/MPS is not available. This is normal and the app will use CPU instead.
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is for educational purposes.
Hiren Kukadiya - GitHub
- Flask and FastAPI communities
- NSE Python library developers
- DeepFace and OpenCV contributors
