Skip to content

BeloIV/drink-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Drink Counter πŸΊβ˜•

Modern web application for tracking beverage consumption and managing debts in households or shared spaces. Built with Django REST Framework backend and React frontend, orchestrated with Docker Compose.

✨ Features

  • πŸ“Š Consumption Tracking - Track beers, coffees, and other beverages
  • πŸ‘₯ Person Management - Home members and guests
  • πŸ’° Automatic Debt Calculation - Per-item or per-gram pricing
  • πŸ“± Responsive Design - Optimized for mobile and desktop
  • πŸ”„ Multi-select Mode - Add transactions for multiple people at once
  • 🎨 Modern UI - Bootstrap 5 with custom CSS enhancements
  • πŸ” Admin Panel - Manage items, persons, and transactions

πŸš€ Technologies

Backend

  • Django 5.1.4
  • Django REST Framework
  • PostgreSQL 16
  • Python 3.12

Frontend

  • React 18
  • Vite
  • React Router
  • Bootstrap 5
  • React Icons

DevOps

  • Docker & Docker Compose
  • Multi-stage builds
  • Hot reload in dev mode

πŸ“¦ Installation & Setup

Prerequisites

  • Docker
  • Docker Compose
  • Git

Steps

  1. Clone the repository
git clone https://github.com/BeloIV/drink-counter.git
cd drink-counter
  1. Start the application
docker compose up --build
  1. Access the application
  1. Create a superuser (for admin panel)
docker compose exec backend python manage.py createsuperuser

πŸ“ Project Structure

drink-counter/
β”œβ”€β”€ backend/              # Django REST API
β”‚   β”œβ”€β”€ backend/         # Project settings
β”‚   β”œβ”€β”€ core/           # Main app (models, views, serializers)
β”‚   β”œβ”€β”€ manage.py
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/            # React application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ pages/      # Pages (admin)
β”‚   β”‚   β”œβ”€β”€ assets/     # Images, avatars
β”‚   β”‚   β”œβ”€β”€ App.jsx     # Main component
β”‚   β”‚   └── api.js      # API client
β”‚   β”œβ”€β”€ public/
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yaml  # Service orchestration
└── README.md

🎯 Usage

Adding a transaction (single mode)

  1. Select a person from home members or guests
  2. Choose category (Beer/Coffee)
  3. Select specific beverage
  4. For coffee, enter gram amount
  5. Debt is automatically added

Adding a transaction (multi mode)

  1. Activate "Multiple people" button
  2. Select multiple persons
  3. Click "Continue"
  4. Choose category and beverage
  5. For coffee, grams are evenly distributed

Admin panel

  • Add/edit items
  • Manage persons
  • View all transactions
  • Close/open sessions
  • Pay-by-square QR codes

πŸ› οΈ Development

Backend development

# Access backend container
docker compose exec backend bash

# Create migrations
python manage.py makemigrations

# Apply migrations
python manage.py migrate

# Run tests
python manage.py test

Frontend development

# Access frontend container
docker compose exec frontend sh

# Install new dependencies
npm install <package>

Hot reload

Both containers have hot reload configured - changes are reflected automatically.

πŸ“ API Endpoints

  • GET /api/persons/ - List persons
  • POST /api/persons/ - Create person
  • GET /api/items/ - List items
  • POST /api/transactions/ - Add transaction
  • GET /api/session/active/ - Active session with summary
  • POST /api/session/close/ - Close session

πŸ”§ Configuration

Backend (.env or docker-compose.yaml)

POSTGRES_DB=drinkdb
POSTGRES_USER=drinkuser
POSTGRES_PASSWORD=drinkpass
POSTGRES_HOST=db
POSTGRES_PORT=5432

Frontend (src/config.js)

export const API_BASE = 'http://localhost:8000/api'

πŸ“Š Database Models

  • Person - Home members and guests
  • Category - Beverage categories (Beer, Coffee)
  • Item - Specific beverages (price, pricing mode)
  • Session - Tracking periods
  • Transaction - Individual consumption records

🎨 UI Features

  • Person avatars with overlay effect
  • Fixed button when scrolling
  • Visual checkmarks for multi-person selection
  • Progress stepper
  • Notice notifications
  • Responsive grid layout

πŸ› Troubleshooting

Port already in use:

# Change port in docker-compose.yaml
ports:
  - "5174:5173"  # frontend
  - "8001:8000"  # backend

Database won't start:

docker compose down -v  # Delete volumes
docker compose up --build

Changes not reflected:

docker compose up --build --force-recreate

πŸ“„ License

MIT

πŸ‘¨β€πŸ’» Author

Created by: BeloIV


⭐ If you like this project, give it a star on GitHub!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors