A production-ready full-stack web application that helps small business owners automate daily operations using AI. Upload invoices, notes, contracts, and tasks β get instant summaries, extracted data, cost tracking, and actionable insights powered by OpenAI GPT-4o.
- Built a full-stack app with React 19 + TypeScript frontend and Flask REST API backend
- JWT authentication with access tokens (30 min) and refresh token rotation (7 days)
- OpenAI GPT-4o-mini integration for AI-powered document analysis with structured JSON output
- Production security: fail-fast secrets, Marshmallow validation, MIME checks, rate limiting, security headers
- 36 automated tests covering auth, records, analytics, soft delete, and token refresh
- Containerized with Docker Compose (Postgres + Redis + Backend + Frontend) and CI/CD via GitHub Actions
- Application Factory pattern with Blueprint-based routes and Marshmallow validation
- React 19 + TypeScript SPA with Vite dev server and Nginx production build
- SQLAlchemy ORM with PostgreSQL, connection pooling, and pre-ping health checks
- Redis-backed rate limiting that scales across multiple backend instances
- OpenAI integration for document analysis with explicit error propagation
- Docker Compose orchestrates all services (Postgres, Redis, Backend, Frontend)
- Nginx reverse proxy with security headers, static caching, and HTTPS-ready config
Add screenshots and demo GIFs under
docs/media/to make this project faster to evaluate for recruiters.
- Document summarization, date/cost/task extraction, category classification via OpenAI GPT-4o-mini
- AI-generated action items with priority levels, cost tracking, and due date detection
- Explicit error propagation (no silent mock fallback) with content truncation for token management
- JWT access tokens (30 min) + refresh tokens (7 days) with frontend auto-refresh and request queuing
- Fail-fast config β app refuses to start without required secrets; non-root Docker user
- Security headers (CSP, HSTS, X-Frame-Options, nosniff, XSS-Protection), generic error responses
- Redis-backed rate limiting: 60/min default, 5/min signup, 10/min login, 20/min record creation
- Upload PDF, TXT, MD, CSV with MIME type validation + extension allowlist (10 MB limit)
- Automatic text extraction (PyPDF for PDFs) with file cleanup after processing
- Soft delete with
deleted_attimestamp (GDPR-aware, recoverable) - Full-text search, category/status filtering, pagination (max 100 per page)
- Marshmallow schema validation + Bleach sanitization on all inputs
- Total records, expense tracking, category breakdown (pie charts), status distribution (bar charts)
- Pending action items aggregation, soft-deleted records excluded from all analytics
# Backend
cd backend
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Frontend
cd frontend && npm installcp .env.example .env
# Edit .env with your secrets and database URLcd backend
export SECRET_KEY="dev-secret" JWT_SECRET_KEY="dev-jwt" DATABASE_URL="sqlite:///dev.db"
python -c "from app import create_app, db; app=create_app(); app.app_context().push(); db.create_all()"# Backend (terminal 1)
python run.py # β http://localhost:5000
# Frontend (terminal 2)
cd frontend && VITE_API_URL=http://localhost:5000/api npm run dev # β http://localhost:5173This project includes 36 automated tests covering all 12 API endpoints:
cd backend
SECRET_KEY=test JWT_SECRET_KEY=test DATABASE_URL=sqlite:///:memory: python -m pytest tests/ -v
# 36 passed β- Auth (15 tests):
- Signup (success, duplicate, short password, missing fields, invalid email)
- Login (success, wrong password, nonexistent user)
- Get me (success, no token)
- Refresh token (success, access token rejected)
- Records (18 tests):
- Create (text, no content, empty content, unauthenticated)
- List (empty, with records, pagination, search, filter by status)
- Get (success, not found, other user blocked)
- Delete (success, not found, already deleted)
- Update status (success, invalid)
- Update fields (title, category, invalid category, empty title)
- Analytics (3 tests):
- Summary empty, summary with records, unauthenticated
- users β Email (unique), password hash, full name, role, timestamps
- records β Title, content, AI outputs, metadata,
deleted_at(soft delete)
- User β Records (One-to-Many)
users.email(unique)records.user_id,records.category,records.status,records.deleted_at
POST /api/auth/signupβ Create account (rate limited: 5/min)POST /api/auth/loginβ Login and get access + refresh tokensPOST /api/auth/refreshβ Get new access token using refresh tokenGET /api/auth/meβ Get current user profile (requires token)
POST /api/recordsβ Create record from text or file upload (AI analyzed)GET /api/recordsβ List with search, category, status filters + paginationGET /api/records/:idβ Get single recordPATCH /api/records/:idβ Update title/category (Marshmallow validated)PATCH /api/records/:id/statusβ Update status (processed, pending, archived)DELETE /api/records/:idβ Soft-delete record
GET /api/analytics/summaryβ Dashboard data (totals, categories, statuses, actions)GET /api/healthβ Health check with database connectivity verification
- React 19 β Frontend UI framework
- TypeScript 6.0 β Type-safe frontend development
- Vite 8 β Frontend build tool and dev server
- Recharts β Dashboard charts and visualizations
- Axios β HTTP client with interceptors for auth
- Flask 3.1 β Backend web framework
- Flask-SQLAlchemy 3.1 β ORM with connection pooling
- Flask-JWT-Extended 4.7 β JWT access + refresh tokens
- Flask-Limiter 3.12 β Redis-backed rate limiting
- Marshmallow 3.25 β Request validation and serialization
- Bleach 6.2 β HTML/input sanitization
- OpenAI 1.68 β GPT-4o-mini integration
- PyPDF 5.4 β PDF text extraction
- Gunicorn 23 β Production WSGI server
- PostgreSQL 16 β Production database
- Redis 7 β Rate limit storage
- Docker + Docker Compose β Containerization
- Nginx β Reverse proxy with security headers
- GitHub Actions β CI/CD pipeline
- Pytest 8.3 β Backend test framework
AI-Business-Assistant/
βββ .github/
β βββ workflows/
β βββ ci.yml # CI/CD: lint, test, build, deploy
βββ backend/
β βββ app/
β β βββ __init__.py # App factory, middleware, error handlers, health check
β β βββ config.py # Fail-fast config with required env vars
β β βββ models/ # User (password hashing) + Record (soft delete)
β β βββ routes/ # auth, records (CRUD + AI), analytics
β β βββ services/ai_service.py # OpenAI integration with error propagation
β β βββ utils/file_helpers.py # MIME validation + text extraction
β βββ tests/ # 36 tests: auth (15), records (18), analytics (3)
β βββ Dockerfile # Non-root user, gunicorn, worker recycling
β βββ requirements.txt
βββ frontend/
β βββ src/
β β βββ context/AuthContext.tsx # Auth state + refresh token management
β β βββ services/ # API client (auto-refresh), auth, records
β β βββ components/ # ErrorBoundary, Layout, ProtectedRoute
β β βββ pages/ # Dashboard, NewInput, History, Analytics, Login, Signup
β β βββ types/index.ts
β βββ nginx.conf # Security headers, caching, proxy, HTTPS-ready
β βββ Dockerfile # Multi-stage build (Node β Nginx)
βββ docker-compose.yml # Postgres + Redis + Backend + Frontend
βββ .env.example # All env vars documented
βββ README.md
- β JWT access + refresh tokens with auto-refresh and request queuing
- β Fail-fast secret validation (app won't start without env vars)
- β Security headers (CSP, HSTS, X-Frame-Options, etc.)
- β Redis-backed rate limiting with per-endpoint limits
- β CORS with explicit origin and credentials
- β Non-root Docker user
- β OpenAI GPT-4o-mini document analysis with structured JSON output
- β Explicit error propagation (no silent mock fallback)
- β Content truncation to manage token usage
- β MIME type validation + extension allowlist
- β Soft delete, full-text search, pagination
- β Marshmallow schema validation on all inputs
- β 36 automated tests (auth, records, analytics)
- β GitHub Actions CI/CD pipeline (lint, test, build, deploy)
- β Backend: Pyright + Pytest + pip-audit
- β Frontend: TypeScript check + ESLint + Vitest + npm audit
- β Docker Compose with Postgres, Redis, Backend, Frontend
- β Gunicorn production server with worker recycling
- β Nginx reverse proxy with caching and security headers
- β HTTPS-ready config, structured JSON logging, health check
This project is fully containerized and deployment-ready!
- Server: Any VPS with Docker installed (DigitalOcean, AWS EC2, etc.)
- Clone:
git clone <repo> && cd AI-Business-Assistant - Configure:
cp .env.example .env && nano .env(set real secrets) - Launch:
docker compose up -d --build - Done: App available at your server's IP/domain
- β Lint Job: Pyright (backend) + ESLint (frontend)
- β Test Job: Pytest 36 tests + Vitest frontend tests
- β Build Job: Docker images pushed to GitHub Container Registry
- β Deploy Job: Staging environment with smoke tests
- β Trigger: On push/PR to main branch
- Configuration Management: Fail-fast env var validation
- Database: PostgreSQL with connection pooling and pre-ping
- Rate Limiting: Redis-backed, scales across instances
- Logging: Structured JSON to stdout
- Health Check:
/api/healthverifies database connectivity - HTTPS: Nginx config ready β uncomment SSL block and provide certs
β οΈ Important: Sensitive data is managed via environment variables in production!
Secret Key Management:
- Development: Set in
.envfile (not committed to git) - Production: Set in server environment variables
- Generate secure key:
python -c "import secrets; print(secrets.token_urlsafe(32))"
Database Credentials:
- Never commit database passwords to version control
- Use
.envfor local development (in.gitignore) - Use server environment variables for production
Beyond typical project requirements, this project includes:
- Comprehensive error handling with global handlers (400/404/405/429/500)
- JWT error handlers (expired, invalid, missing tokens)
- Frontend error boundary with sanitized error display
- Automatic token refresh with failed request queuing
- Soft delete for data recovery compliance
- Database connection pooling for production performance
- Worker recycling in Gunicorn to prevent memory leaks
This is a portfolio project demonstrating full-stack development with production-ready practices.
MIT License
Yousaf Zeb β Full-Stack Software Engineer Project completed: April 2026 Stack: React, TypeScript, Flask, PostgreSQL, Redis, Docker, OpenAI