A simple leave-management application with frontend built using React and backend built with Flask, Flask-SQLAlchemy, and SQLite.
-While applying for leave as a user, please apply in the format DD-MM-YYYY as start date and similarly for end date. -Please wait for 1-2 minutes after the application starts as the backend goes to sleep after some time of inactivity due to deployment on Render. Will be fixed in upcoming updates
- User management (create & list users)
- Apply for leave, list all leave requests
- Check leave balance
- Admin: approve/reject requests and adjust balances
- Admin: cancel all leave requests for a user
- Minimal HTML tester page to exercise the API without Postman
- Backend: Python, Flask, Flask-SQLAlchemy, Flask-CORS
- Database: SQLite (file-based; can swap to PostgreSQL for production)
- Tester UI: Plain HTML + Fetch API
- WSGI/Proxy (prod): Gunicorn + Nginx/Caddy (or Render/Heroku)
config.py # App & database configuration (Flask, SQLAlchemy, CORS)
main.py # Route definitions (REST API)
models.py # SQLAlchemy models & serializers
mydatabase.db # SQLite database file (auto-created on first run)
index.html # Minimal API tester UI
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
pip install -U pip
pip install -r requirements.txtpython main.py
# Server: http://127.0.0.1:5000Tables are auto-created on first run.
cp .env.example .env
# Edit .env if needed, then:
docker compose up --build- API:
http://127.0.0.1:5000 - Adminer:
http://127.0.0.1:8080(PostgreSQL, serverdb, user/pass in.env)
Open index.html and set:
const API = "http://127.0.0.1:5000";Then click the buttons to hit endpoints.
Base URL (local): http://127.0.0.1:5000
- List users:
GET /users - Create user:
POST /create_users(form-data:username, email, department, joining_date, [role], [leave_balance]) - Apply leave:
POST /apply_leave(form-data:username, start_date, end_date, reason) - List leave requests:
GET /show_leaves - Get leave balance:
GET /get_leave_bal?username={username} - Approve/Reject leave (Admin):
POST /update_leave_balance(form-data:leave_id, status) - Cancel all leaves for a user (Admin):
POST /cancel_all_leave(form-data:username)
- Validates joining date, overlapping leaves, leave balance, and user existence.
- Plan to add:
- Marshmallow or Pydantic schemas
- AuthN/AuthZ (JWT)
- Global error handling
- Rate limiting and request size limits
- DB: Migrate to PostgreSQL + Alembic migrations
- Runtime: Gunicorn workers behind Nginx/Caddy; connection pooling
- Caching: Redis
- Background jobs: Celery/RQ for notifications/reports
- Observability: Logging, Prometheus/Grafana, Sentry
- Documentation: OpenAPI (flasgger or Flask-Smorest)
Procfile:web: gunicorn main:app- Set
DATABASE_URLenv var if using PostgreSQL; fallback is SQLite.
MIT (add LICENSE file)
Flask>=2.3
Flask-SQLAlchemy>=3.1
Flask-Cors>=4.0
gunicorn>=22.0
python-dotenv>=1.0
psycopg2-binary>=2.9