Skip to content

Enterprise Pet Shop System with Django 5.2, DRF & Celery. Features Clean Architecture, 94% test coverage, and AWS deployment.

License

Notifications You must be signed in to change notification settings

CFBruna/petcare_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

160 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐾 PetCare - Pet Shop Management System

Django CI Coverage Python 3.12 Django 5.2 License: Proprietary

Production-grade pet shop management system (Django + DRF + Celery) with a real cloud migration case study (AWS β†’ Azure), HTTPS automation, DNS cutover, and managed PostgreSQL.

πŸš€ Live Demo: https://petcare.brunadev.com | πŸ“Š Dashboard: https://petcare.brunadev.com/dashboard | πŸ“š API Docs: Swagger UI


πŸ“Έ Screenshots

Landing Page

Landing Page

Modern landing page with demo credentials and clean UX/UI design.


Analytics Dashboard (TypeScript)

Analytics Dashboard

Real-time analytics dashboard built with React + TypeScript showing revenue metrics, appointment trends, and top products.


API Documentation (Swagger UI)

Swagger

RESTful API with multiple endpoints across accounts, pets, health, schedule, store, and analytics modules, documented following OpenAPI 3.0 specification.


🎯 Quick Start

Test the live application deployed on Azure production infrastructure (migrated from AWS):

πŸ” Demo Credentials

Email: recrutador@petcare.com Password: avaliar123

Access Points:


🏭️ Production Architecture (Current – Azure)

Note: The diagram below represents the original AWS architecture before migration (Dec 2025). Current production runs on Azure with equivalent services.

This project runs on a modern, scalable cloud infrastructure:

Infrastructure Components:

  • Compute: Azure Linux VM running containerized application (Docker)
  • Database: Azure Database for PostgreSQL (managed service)
  • Cache & Queue: Redis (containerized) for Celery task queue and caching
  • Web Server: Nginx as reverse proxy and static file server
  • DNS: HostGator DNS
  • Containerization: Docker & Docker Compose for environment consistency
graph TD
    User((User))
    DNS[Route 53]

    subgraph AWS Cloud
        LB[Nginx Reverse Proxy]

        subgraph Docker Container
            App[Django Gunicorn]
            Worker[Celery Worker]
            Beat[Celery Beat]
        end

        DB[(RDS PostgreSQL)]
        Cache[(ElastiCache Redis)]
    end

    User -->|HTTPS| DNS
    DNS --> LB
    LB -->|Proxy_pass| App
    App -->|Read/Write| DB
    App -->|Cache/Broker| Cache
    Worker -->|Consume Tasks| Cache
    Beat -->|Schedule Tasks| Cache
    Worker -->|Update Data| DB
Loading

πŸ”„ Cloud Migration: AWS β†’ Azure (Real Production Case)

This project includes a real-world cloud migration, executed end-to-end in production.

Migration Scope

  • Compute: AWS EC2 β†’ Azure Linux VM
  • Database: AWS RDS PostgreSQL β†’ Azure Database for PostgreSQL
  • Cache/Queue: AWS ElastiCache β†’ Containerized Redis
  • DNS: Route 53 β†’ HostGator DNS
  • SSL: Re-issued with Let's Encrypt (Certbot)
  • Static files: Rebuilt and collected post-migration

Key Migration Steps

  1. Provisioned Azure VM and PostgreSQL
  2. Migrated database using pg_dump / pg_restore
  3. Rebuilt Docker production stack
  4. Reconfigured DNS with low TTL for safe cutover
  5. Reissued SSL certificates and automated renewal
  6. Decommissioned all AWS resources to eliminate costs

Result

  • βœ… Minimized downtime
  • βœ… No data loss
  • βœ… HTTPS preserved
  • βœ… Emails (Zoho) unaffected

✨ Key Features

🧠 Smart Scheduling System

  • Automatic Availability Calculation: Time slots calculated based on service duration and operating hours (8 AM - 8 PM)
  • Status Workflow: Track appointments through lifecycle: Pending β†’ Confirmed β†’ Completed/Canceled
  • Service Management: Configure specific durations and pricing for each service type
  • Conflict Prevention: Real-time validation prevents double-booking

πŸ“¦ Advanced Store & Inventory Management

  • Batch Tracking: Products managed by Lots (ProductLot) with individual expiration dates and quantities
  • Dynamic Pricing Engine:
    • Manual Promotions: Date-range based discounts on specific product lots
    • Automatic Expiration Discounts: Background tasks apply progressive discounts (30% < 7 days, 20% < 15 days, 10% < 30 days) to reduce waste
    • Best Price Logic: POS automatically applies lowest price between manual promotion vs. auto-discount
  • Sales Processing: Point-of-sale interface with real-time inventory updates

🩺 Health & Pet Registry

  • Multi-Species Support: Detailed profiles for Dogs, Cats, Birds, and more
  • Health Records: Track vaccines, surgeries, consultations with "Next Due Date" reminders
  • Complete History: Comprehensive medical timeline for each pet

πŸ“Š Dashboard & Analytics

  • Real-Time Metrics: Daily revenue, confirmed appointments, and 7-day billing charts
  • Automated Reports: Daily email summaries for sales, appointments, and promotions (Celery)
  • Data Visualization: Interactive charts for revenue trends

πŸ€– AI Intelligence (Google Gemini Integration)

Production-ready AI system powered by Google Gemini 2.5 Flash with 3 specialized intelligent agents:

πŸ—“οΈ AI Scheduling Agent

Natural language appointment booking with Gemini Function Calling:

Core Capabilities:

  • Natural Language Understanding: Interprets colloquial Portuguese requests ("preciso de banho pro meu golden na sexta de manhΓ£")
  • Intelligent Pet Search: Finds pets by breed, species, age, or name
  • Smart Availability Checking: Returns free time slots by day/period (morning/afternoon/evening)
  • Automatic Price Calculation: Computes service costs with size-based adjustments (small/medium/large)
  • Conversational Responses: Professional, friendly tone in Portuguese
  • Execution Transparency: Tracks and reports all tool calls made

Function Calling Architecture:

The agent uses Gemini's native function calling to execute 3 core tools:

  1. search_customer_pets - Semantic pet search

    • Supports breed matching ("golden retriever", "siamΓͺs")
    • Age filtering (min/max range)
    • Species filtering (dog, cat, bird, etc.)
    • Returns pet details with owner information
  2. check_availability - Time slot lookup

    • Day-of-week support (PT/EN: "sΓ‘bado", "saturday")
    • Period filtering (morning: 8-12h, afternoon: 12-17h, evening: 17-20h)
    • ISO date support ("2024-12-20")
    • Returns available slots with dates and times
  3. calculate_price - Service pricing

    • Dynamic pricing by service type (grooming, consultation, vaccination)
    • Pet size adjustments (large breeds +20%)
    • Returns formatted price and estimated duration

API Integration:

curl -X POST https://petcare.brunadev.com/api/v1/ai/schedule-intent/ \
  -H "Content-Type: application/json" \
  -d '{
    "user_input": "Preciso de banho pro meu Golden de 5 anos, sΓ‘bado de manhΓ£",
    "customer_id": 1
  }'

Response Structure:

{
  "message": "Encontrei o Thor! πŸ• Temos 3 horΓ‘rios disponΓ­veis sΓ‘bado de manhΓ£: 09:00, 10:30 e 11:00. Banho e tosa para porte grande custa R$ 120,00 e leva cerca de 90 minutos. Qual horΓ‘rio prefere?",
  "tools_executed": [
    {
      "tool_name": "search_customer_pets",
      "arguments": {"species": "dog", "breed": "golden retriever", "age_min": 5, "age_max": 5},
      "result": [{"id": 1, "name": "Thor", "breed": "Golden Retriever", "age": 5}]
    },
    {
      "tool_name": "check_availability",
      "arguments": {"day": "saturday", "period": "morning"},
      "result": {"available_slots": [{"time": "09:00", "date": "12/20/2024"}]}
    },
    {
      "tool_name": "calculate_price",
      "arguments": {"service_name": "grooming", "pet_size": "large"},
      "result": {"formatted_price": "R$ 120,00", "duration_minutes": 90}
    }
  ],
  "intent_detected": "book_appointment",
  "confidence_score": 0.95
}

Supported Input Patterns:

  • Breed mentions: "meu golden", "minha siamesa"
  • Date references: "sΓ‘bado", "amanhΓ£", "prΓ³xima terΓ§a", "2024-12-25"
  • Time periods: "manhΓ£", "tarde", "noite", "morning", "afternoon"
  • Service keywords: "banho", "consulta", "vacina", "grooming"

πŸ“ Product Intelligence Agent

AI-powered product description generation with RAG (Retrieval Augmented Generation):

Dual Generation Modes:

  • Technical Mode:

    • Generates detailed, spec-focused descriptions for informed buyers
    • Uses RAG to find similar products via semantic search
    • Leverages ChromaDB vector database for embeddings similarity
    • Provides product recommendations based on vector proximity
    • Example: "15kg premium dog food with omega-3, grain-free, suitable for adult breeds 25-40kg"
  • Creative Mode:

    • Creates engaging, marketing-focused copy
    • Highlights benefits and emotional appeal
    • Optimized for conversion and customer engagement
    • Example: "DΓͺ ao seu melhor amigo a nutriΓ§Γ£o que ele merece! 🐾"
  • SEO Optimization:

    • Auto-generates meta descriptions and keywords
    • Suggests product categorization
    • Improves search engine visibility

Features:

  • Real-time generation from Django admin (AJAX integration)
  • Bulk actions for multiple products simultaneously
  • Confidence scoring for AI-generated content (0-1 scale)
  • Automatic embedding indexing with Gemini Embeddings API
  • Custom admin templates with visual feedback and loading states
  • Vector store persistence for fast retrieval

RAG Architecture:

  1. Product data β†’ Gemini Embeddings API β†’ 768-dim vectors
  2. Vectors stored in ChromaDB (persistent local storage)
  3. Query embedding β†’ Similarity search β†’ Top-K similar products
  4. Similar products + context β†’ Gemini LLM β†’ Generated description

🩺 Health Analysis Agent

Advanced pet health monitoring with Google Search Grounding:

Pattern Detection:

  • Analyzes 6-month health history for trends and anomalies
  • Identifies potential health issues early (seasonality, recurrence)
  • Uses Google Search Grounding to verify medical information against web sources
  • Cites external veterinary sources for fact-checking
  • Example: Detects "vaccine overdue by 45 days" or "3 ear infections in 4 months"

Smart Alerts:

  • Vaccine expiration warnings (30/15/7 days before due)
  • Overdue checkup notifications (annual wellness exams)
  • Medication schedule tracking (antibiotic courses, chronic meds)
  • Weight changes (sudden gain/loss flags)

Health Scoring Algorithm (0-100):

  • Recent checkups: +20 points (within 6 months)
  • Vaccines up-to-date: +30 points
  • No active alerts: +20 points
  • Normal weight trend: +15 points
  • No recurring issues: +15 points
  • Visual dashboard integration with color coding (green/yellow/red)

AI-Powered Recommendations:

  • Context-aware veterinary advice based on breed, age, history
  • Breed-specific health tips (e.g., hip dysplasia for large breeds)
  • Grounded in real-time web search via Gemini Search Grounding
  • Cited sources from veterinary websites and medical databases

Technical Implementation:

  • REST API integration with Gemini (bypasses SDK limitations for advanced features)
  • Google Search Grounding for medical fact-checking
  • Retry logic with exponential backoff (2s β†’ 4s β†’ 8s)
  • Structured JSON parsing from LLM responses
  • Real-time results displayed in Django admin
  • Admin bulk actions for analyzing multiple pets

πŸ”§ AI Technical Architecture

AI Stack:

  • LLM: Google Gemini 2.5 Flash (gemini-2.5-flash)
  • Embeddings: Google Gemini Embeddings API (text-embedding-004, 768 dimensions)
  • Vector DB: ChromaDB 1.3+ (local, persistent, no separate server)
  • Orchestration: LangChain 1.1+ (agent framework)
  • Function Calling: Native Gemini tool use (for scheduling and search grounding)

Key Design Patterns:

  • Service Layer architecture - No logic in admin/views, all AI logic in services.py
  • DTO pattern - Clean API contracts with dataclasses (SchedulingIntentRequest/Response)
  • Retry mechanisms - Exponential backoff for API rate limits and transient errors
  • RAG (Retrieval Augmented Generation) - For product intelligence with ChromaDB
  • Streaming-ready infrastructure - Designed for future real-time response streaming

Performance Optimizations:

  • Embedding caching - Redis cache for frequently requested embeddings
  • Vector store persistence - ChromaDB data persists across restarts (chroma_db/ directory)
  • Batch processing - Admin bulk actions process multiple items efficiently
  • Removed heavy dependencies - Switched from sentence-transformers (2GB models) β†’ Gemini API (cloud-based)
  • Docker build time: 9min β†’ 1min (8x faster) after dependency optimization

Cost Efficiency:

  • Free tier: 1,500 requests/day with billing enabled
  • Gemini Embeddings: Free tier for production use
  • Zero local model downloads - All processing cloud-based
  • Automatic quota management - Graceful degradation on quota exceeded

Observability:

  • Structured logging with structlog (JSON format)
  • Tool execution tracking - Full trace of function calls and results
  • Confidence scoring - Transparency in AI certainty levels
  • Response time metrics - Logged for performance monitoring

πŸ“… Interactive Admin Calendar (React Big Calendar)

  • Visual Scheduling: Drag-and-drop appointment management directly in Django admin
  • Multiple Views: Month, week, and day calendar perspectives
  • Real-Time Sync: Integrated with Django backend for live updates
  • Separate Build: Independent Vite configuration (vite.admin.config.ts) for admin assets
  • Modern UI: React-powered calendar with date-fns for date manipulation

Build Admin Calendar:

cd frontend
npx vite build --config vite.admin.config.ts
# Output: src/static/admin_calendar/

πŸ›‘οΈ Technical Highlights

  • 94% Test Coverage with pytest + factory-boy
  • CI/CD Pipeline with GitHub Actions (lint, type-check, security scan, test)
  • Service Layer Architecture for clean separation of concerns
  • Production-Ready Factories for data seeding, testing, and Celery tasks
  • Structured Logging with structlog for JSON-formatted production observability
  • OpenAPI Documentation with drf-spectacular (Swagger/ReDoc)
  • Asynchronous Tasks with Celery + Redis + django-celery-beat
  • Type Safety with MyPy type checking
  • Code Quality enforced by Ruff + pre-commit hooks
  • Modern Dependency Management with uv (10-100x faster than pip)

πŸ› οΈ Tech Stack

Backend

  • Python 3.12
  • Django 5.2
  • Django REST Framework 3.16
  • Celery 5.4 (task queue)
  • Gunicorn (WSGI server)

Database & Cache

  • PostgreSQL 16
  • Redis 7 (Celery broker + cache)

AI/ML Stack

  • Google Gemini 2.5 Flash (LLM)
  • Google Gemini Embeddings API (text-embedding-004)
  • LangChain 1.1+ (orchestration)
  • LangChain Google GenAI 4.0+ (Gemini integration)
  • ChromaDB 1.3+ (vector database)

Infrastructure

  • Azure Linux VM (Ubuntu 24.04)
  • Azure Database for PostgreSQL
  • Docker + Docker Compose (multi-stage builds)
  • Nginx (reverse proxy + HTTPS termination)
  • Infra-Gateway: Multi-domain Nginx architecture
  • Let's Encrypt (Certbot with auto-renewal)
  • HostGator DNS

Frontend (Dashboard)

  • React 18 + TypeScript 5
  • Vite 5 (build tool)
  • Recharts (data visualization)
  • Tailwind CSS
  • Axios (HTTP client)

Frontend (Admin Calendar)

  • React Big Calendar 1.19.4
  • date-fns 4.1.0 (date utilities)
  • Separate Vite build configuration

Frontend (Client - Next.js)

  • Next.js 15 + React 19
  • TypeScript 5
  • Tailwind CSS
  • Zustand (state management)
  • TanStack Query (data fetching)
  • Framer Motion (animations)
  • Separate repository: petcare-web

Deployment & Monitoring

  • Blue-Green Deployment Strategy
  • Automated Backup/Rollback (keeps last 5)
  • Health Check Monitoring
  • Shell Scripting (deploy.sh - 266 lines)

Code Quality & Testing

  • pytest + pytest-django
  • factory-boy (test fixtures - production-ready)
  • Ruff (linting)
  • MyPy (type checking)
  • Bandit (security scanning)
  • Safety (dependency vulnerability checks)
  • pre-commit hooks

API Documentation

  • drf-spectacular (OpenAPI 3.0)

Dependency Management

  • uv (Astral's blazing-fast Python package manager)

πŸš€ Local Development Setup

Prerequisites

Installation Steps

  1. Clone the repository
git clone https://github.com/CFBruna/petcare_project.git
cd petcare_project
  1. Set up environment variables
cp .env.example .env

πŸ’‘ Tip: The default values in .env.example work out-of-the-box for local Docker development. Only edit if you need custom configuration.

  1. Build and start containers
docker compose up --build -d
  1. Run database migrations
docker compose exec web python manage.py migrate
  1. Create superuser
docker compose exec web python manage.py createsuperuser
  1. Load sample data (optional)
docker compose exec web python manage.py seed_db
  1. Access the application
  • Admin Panel: http://127.0.0.1:8000/admin/
  • API Docs: http://127.0.0.1:8000/api/v1/schema/swagger-ui/

πŸ“Š Running the Analytics Dashboard (Frontend)

The analytics dashboard is a separate TypeScript frontend that consumes the Django API.

# Install Node.js dependencies
cd frontend
npm install

# Run development server (with hot reload)
npm run dev

# Access dashboard
# http://localhost:5173

The Vite dev server automatically proxies API requests to Django backend (localhost:8000).

For Production Build:

# Build frontend to Django static
./scripts/build-frontend.sh

# Output: src/static/dashboard/

πŸ§ͺ Running Tests

Execute the complete test suite with coverage report:

docker compose exec web pytest --cov

With detailed output:

docker compose exec web pytest --cov --cov-report=html -v

Run specific test file:

docker compose exec web pytest src/apps/pets/tests/test_models.py -v

Coverage Report: The project maintains 94% test coverage across all modules.


πŸ“š API Documentation

The API follows OpenAPI 3.0 specification and provides interactive documentation:

Local Development:

  • Swagger UI: http://127.0.0.1:8000/api/v1/schema/swagger-ui/
  • ReDoc: http://127.0.0.1:8000/api/v1/schema/redoc/

Production:

  • Swagger UI: https://petcare.brunadev.com/api/v1/schema/swagger-ui/
  • ReDoc: https://petcare.brunadev.com/api/v1/schema/redoc/

API Endpoints Overview

Resource Endpoint Methods Description
Customers /api/v1/customers/ GET, POST, PUT, DELETE Manage pet owners
Pets /api/v1/pets/ GET, POST, PUT, DELETE Manage registered pets
Appointments /api/v1/appointments/ GET, POST, PUT, DELETE Schedule services
Products /api/v1/products/ GET, POST, PUT, DELETE Manage inventory
Sales /api/v1/sales/ GET, POST Process transactions


βš™οΈ Background Tasks (Celery)

The system uses Celery Beat for automated scheduled tasks. All tasks are configured with America/Sao_Paulo timezone:

Task Schedule Description
simulate_daily_activity 02:00 AM BRT Generates realistic demo data (customers, sales, appointments) to keep the demo environment active
generate_daily_sales_report 01:05 AM BRT Emails daily sales summary to admin with revenue metrics
generate_daily_promotions_report 01:10 AM BRT Reports active promotions and promotional stock levels
apply_expiration_discounts 01:30 AM BRT **Business Rule:- Scheduled Discounts: Expired products don't sitβ€”they auto-discount:
β€’ 30 days before expiration: 10%
β€’ 15 days before: 20%
β€’ 7 days before: 30%

πŸ“Š Analytics Dashboard (TypeScript)

  • Interactive Dashboard: Real-time business metrics visualization
  • TypeScript + React: Modern frontend with strict type safety
  • Recharts Integration: Professional charts for revenue and appointments trends
  • Responsive Design: Tailwind CSS with mobile-first approach
  • API Integration: Type-safe Axios service consuming Django REST endpoints
  • Period Filtering: Dynamic data for 7/30/90 days
  • Portuguese UI: Localized interface for Brazilian market

Manual Task Execution

Trigger the data simulation manually for testing:

docker compose exec web python manage.py shell -c "
from src.apps.store.tasks import simulate_daily_activity
result = simulate_daily_activity()
print(result)
"

Expected Output:

2025-12-07T05:00:00.502290Z [info] simulate_daily_activity_started
Time slots (Mon-Fri, 08h-20h) ensured.
Created 5 new customers.
Created product 'RaΓ§Γ£o Premium para CΓ£es Adultos 15kg' with 2 lots.
Created product 'Shampoo Antipulgas e Carrapatos 500ml' with 2 lots.
Created product 'Petisco Natural de Frango Desidratado 200g' with 2 lots.
Created 5 sales for yesterday.
Created 7 appointments.
Created 4 health records.
Created 2 manual promotions.
Triggered automatic expiration discounts task.

πŸ”„ CI/CD Pipeline

Every push or pull request to main triggers an automated pipeline:

  1. πŸ“¦ Install Dependencies (uv)
  2. πŸ” Type Check (MyPy)
  3. ✨ Lint Code (Ruff)
  4. πŸ›‘οΈ Security Scan (Bandit + Safety)
  5. πŸ§ͺ Run Tests (pytest) + Coverage Report
  6. βœ… Quality Gate: 90%+ coverage required

View workflow: .github/workflows/ci.yml


πŸš€ Production Deployment

Blue-Green Deployment Strategy

The project includes a production-grade deployment script (deploy.sh) with zero-downtime deployment:

Features:

  • βœ… Automated Backup: Full system backup before each deployment (keeps last 5)
  • βœ… Zero-Downtime: Blue-green strategy with rolling container updates
  • βœ… Automatic Rollback: Reverts to previous version on failure
  • βœ… Health Checks: API and dashboard verification post-deployment
  • βœ… Dual Deployment: Deploys both Django app + TypeScript dashboard
  • βœ… Safety First: 10-step process with logging and error handling

Deploy to Production:

./deploy.sh

Deployment Steps:

  1. Pre-flight checks (branch validation, git pull)
  2. Create full system backup
  3. Build TypeScript dashboard and admin calendar
  4. Build Docker images (no deployment yet)
  5. Test new build in staging
  6. Deploy with zero downtime (rolling updates)
  7. Run database migrations
  8. Deploy dashboard assets
  9. Health checks (API + Dashboard)
  10. Cleanup old backups

Rollback if Needed:

./rollback.sh backups/deployment-YYYYMMDD-HHMMSS

Multi-Domain Architecture (Infra-Gateway)

The application integrates with infra-gateway for centralized Nginx management:

  • Main Site: brunadev.com (static portfolio)
  • PetCare App: petcare.brunadev.com (Django application)
  • Shared SSL: Let's Encrypt certificates managed centrally
  • Reverse Proxy: Nginx routes traffic to appropriate services
  • Benefits: Simplified SSL management, centralized routing, easy multi-service deployment

Health Monitoring

Production deployment includes automated health checks:

  • API Health: /api/v1/status/ endpoint verification (15 retries, 2s interval)
  • Dashboard Health: Frontend availability check
  • Post-Deployment: Automatic validation after updates
  • Failure Handling: Automatic rollback if health checks fail

πŸ“ Project Structure

petcare_project/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ apps/
β”‚   β”‚   β”œβ”€β”€ accounts/
β”‚   β”‚   β”‚   β”œβ”€β”€ factories.py         # ✨ Production-ready factories
β”‚   β”‚   β”‚   β”œβ”€β”€ models.py
β”‚   β”‚   β”‚   β”œβ”€β”€ services.py
β”‚   β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── tests/
β”‚   β”‚   β”œβ”€β”€ analytics/           # Dashboard metrics & business intelligence
β”‚   β”‚   β”‚   β”œβ”€β”€ serializers.py   # API response schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ services.py      # Optimized analytics queries (5 queries)
β”‚   β”‚   β”‚   β”œβ”€β”€ views.py         # Dashboard endpoint with OpenAPI docs
β”‚   β”‚   β”‚   └── tests/
β”‚   β”‚   β”‚       β”œβ”€β”€ test_api.py       # API endpoint tests
β”‚   β”‚   β”‚       └── test_services.py  # Service layer tests
β”‚   β”‚   β”œβ”€β”€ pets/                    # Pet registration
β”‚   β”‚   β”‚   β”œβ”€β”€ factories.py         # ✨ Production factories
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ health/                  # Health records
β”‚   β”‚   β”‚   β”œβ”€β”€ factories.py         # ✨ Production factories
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ schedule/                # Appointment system
β”‚   β”‚   β”‚   β”œβ”€β”€ factories.py         # ✨ Production factories
β”‚   β”‚   β”‚   β”œβ”€β”€ services.py
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ store/                   # Products, sales, promotions
β”‚   β”‚   β”‚   β”œβ”€β”€ factories.py         # ✨ Production factories
β”‚   β”‚   β”‚   β”œβ”€β”€ tasks.py             # ✨ Celery tasks with logging
β”‚   β”‚   β”‚   β”œβ”€β”€ services.py
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   └── core/                    # Shared utilities
β”‚   β”‚       └── management/commands/
β”‚   β”‚           └── seed_db.py       # Database seeding
β”‚   β”œβ”€β”€ petcare/
β”‚   β”‚   β”œβ”€β”€ settings.py              # Django settings
β”‚   β”‚   β”œβ”€β”€ urls.py                  # Main URL configuration
β”‚   β”‚   └── celery.py                # Celery config
β”‚   └── conftest.py                  # Pytest fixtures
β”œβ”€β”€ frontend/                         # Analytics Dashboard (TypeScript)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/              # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ MetricsCard.tsx      # KPI display cards
β”‚   β”‚   β”‚   β”œβ”€β”€ RevenueChart.tsx     # Recharts line chart
β”‚   β”‚   β”‚   └── TopProductsTable.tsx # Product ranking table
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.ts               # Type-safe Axios client
β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”‚   └── dashboard.ts         # TypeScript interfaces
β”‚   β”‚   β”œβ”€β”€ App.tsx                  # Main dashboard component
β”‚   β”‚   └── main.tsx                 # React entry point
β”‚   β”œβ”€β”€ vite.config.ts               # Vite build config (/dashboard/ base)
β”‚   β”œβ”€β”€ tailwind.config.js           # Tailwind CSS config
β”‚   └── package.json                 # Frontend dependencies
β”œβ”€β”€ .github/workflows/               # CI/CD pipelines
β”‚   └── ci.yml
β”œβ”€β”€ docker-compose.yml               # Local development
β”œβ”€β”€ docker-compose.prod.yml          # Production config
β”œβ”€β”€ Dockerfile                       # Container definition
β”œβ”€β”€ pyproject.toml                   # uv dependencies
β”œβ”€β”€ uv.lock                          # Locked dependencies
└── pytest.ini                       # Test configuration

Key Architecture Decisions:

  • ✨ Factories in Production: Factory classes live outside tests/ directories, enabling use in management commands, Celery tasks, and seeding scripts
  • πŸ—οΈ Service Layer: All business logic isolated in services.py, keeping models thin and views clean
  • πŸ“Š Structured Logging: All Celery tasks use structlog for JSON-formatted logs with full observability

🌟 Key Learnings & Highlights

This project demonstrates proficiency in:

  • βœ… Clean Architecture: Service Layer + Repository Pattern for maintainable code
  • βœ… Cloud Migration: Real-world AWS β†’ Azure migration with zero downtime
  • βœ… Production Deployment: Blue-green strategy with automated backup/rollback
  • βœ… DevOps Practices: Docker, CI/CD, automated testing, security scanning, health monitoring
  • βœ… Multi-Domain Architecture: Infra-gateway integration for centralized Nginx management
  • βœ… Test-Driven Development: 94% coverage with unit and integration tests
  • βœ… Production-Ready Patterns: Factories as first-class citizens, structured logging
  • βœ… API Design: RESTful endpoints with comprehensive OpenAPI documentation
  • βœ… Asynchronous Processing: Celery for background tasks with robust error handling
  • βœ… Type Safety: MyPy type checking for better code reliability
  • βœ… Modern Frontend: React + TypeScript dashboard with Recharts visualization
  • βœ… Admin Enhancement: Interactive calendar with React Big Calendar integration
  • βœ… Modern Tooling: uv for dependency management, Ruff for linting

πŸ”§ Development Tools

Dependency Management (uv)

This project uses uv for fast, reliable dependency management:

# Install dependencies
uv sync

# Add a new dependency
uv add django-extensions

# Add a dev dependency
uv add --dev pytest-xdist

# Update dependencies
uv sync --upgrade

Code Quality

# Lint code
docker compose exec web ruff check .

# Format code
docker compose exec web ruff format .

# Type check
docker compose exec web mypy .

# Security scan
docker compose exec web bandit -r src/

πŸ“„ License

This project is licensed under a Proprietary License. All rights reserved. See the LICENSE file for details.

For licensing inquiries or permission requests, please contact brunaads.ti@gmail.com.


πŸ‘€ Author

Bruna Menezes


⭐ If you find this project helpful, please give it a star!

About

Enterprise Pet Shop System with Django 5.2, DRF & Celery. Features Clean Architecture, 94% test coverage, and AWS deployment.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published