Skip to content

dharani7998/mobi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mobi Project

A Django REST Framework application for managing employee lunch credits and usage.

Table of Contents

Assumptions

  • Write and delete operations are made with row lock to maintain data consistency when writing/deleting lunch orders and when doing top up.

Prerequisites

For Docker Setup

For Local Setup

  • Python 3.13 or higher
  • pip (Python package manager)
  • Virtual environment tool (venv, included with Python)

Clone the Repository

git clone https://github.com/dharani7998/mobi.git
cd mobi

Setup using Docker

Build the Docker Image

docker build -t mobi-app .

Run the Container

docker run -p 8000:8000 -v $(pwd)/db.sqlite3:/app/db.sqlite3 mobi-app

This 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

Access the Application

Once the container is running, access the application at:

Local Development Setup

1. Create a Virtual Environment

# Create virtual environment
python3 -m venv env

# Activate virtual environment
# On macOS/Linux:
source env/bin/activate

# On Windows:
# env\Scripts\activate

2. Install Dependencies

pip install -r requirements.txt

3. Apply Database Migrations

python manage.py migrate

4. Create a Superuser (Optional)

python manage.py createsuperuser

Follow the prompts to create an admin user for accessing the Django admin panel.

Running the Development Server

Using Django Development Server (Recommended for Development)

# Make sure your virtual environment is activated
source env/bin/activate

# Run the development server
python manage.py runserver

The development server will start at http://127.0.0.1:8000/

Using Gunicorn (Production-like Environment)

# 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

Access the Application

Running Tests

Run All Tests

# Make sure your virtual environment is activated
source env/bin/activate

# Run all tests
python manage.py test

Project Structure

mobi/
├── 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors