A Django REST Framework application for managing employee lunch credits and usage.
- Assumptions
- Prerequisites
- Docker Setup
- Local Development Setup
- Running the Development Server
- Running Tests
- Project Structure
- Write and delete operations are made with row lock to maintain data consistency when writing/deleting lunch orders and when doing top up.
- Docker installed on your machine (Install Docker)
- Python 3.13 or higher
- pip (Python package manager)
- Virtual environment tool (venv, included with Python)
git clone https://github.com/dharani7998/mobi.git
cd mobidocker build -t mobi-app .docker run -p 8000:8000 -v $(pwd)/db.sqlite3:/app/db.sqlite3 mobi-appThis command will:
- Map port 8000 from the container to your local machine
- Mount the SQLite database to persist data between container restarts
- Start the application using Gunicorn with 3 workers
Once the container is running, access the application at:
- Test Bench: http://localhost:8000/api/test_bench
- API: http://localhost:8000/
- Admin Panel: http://localhost:8000/admin/
# Create virtual environment
python3 -m venv env
# Activate virtual environment
# On macOS/Linux:
source env/bin/activate
# On Windows:
# env\Scripts\activatepip install -r requirements.txtpython manage.py migratepython manage.py createsuperuserFollow the prompts to create an admin user for accessing the Django admin panel.
# Make sure your virtual environment is activated
source env/bin/activate
# Run the development server
python manage.py runserverThe development server will start at http://127.0.0.1:8000/
# Make sure your virtual environment is activated
source env/bin/activate
# Run with Gunicorn
gunicorn mobi.wsgi:application --bind 0.0.0.0:8000 --workers 3- Test Bench: http://localhost:8000/api/test_bench
- API: http://localhost:8000/
- Admin Panel: http://localhost:8000/admin/
# Make sure your virtual environment is activated
source env/bin/activate
# Run all tests
python manage.py testmobi/
├── common/ # Common/shared app for reusable components
├── core/ # Core application logic
├── mobi/ # Project settings and configuration
│ ├── settings.py # Django settings
│ ├── urls.py # URL routing
│ └── wsgi.py # WSGI configuration
├── templates/ # HTML templates
├── env/ # Virtual environment (not in version control)
├── db.sqlite3 # SQLite database
├── manage.py # Django management script
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
└── ReadMe.md # This file