Skip to content

Nightlurker/MonkeyManager.API

Repository files navigation

MonkeyManager API

A .NET Web API for managing primates in a zoo environment, including animal records, feeding schedules, and health records.

Features

  • 🦍 Animal Management (CRUD operations)
  • 🍌 Feeding Schedule Management
  • 🏥 Health Records Management
  • 🔐 Azure AD B2C Authentication
  • 👥 Role-Based Access Control (RBAC)
  • 📚 API Versioning
  • 📝 Swagger Documentation

Prerequisites

Getting Started

  1. Clone the repository:
git clone https://github.com/Nightlurker/MonkeyManager.API.git
cd MonkeyManager.API
  1. Update the configuration in appsettings.json and appsettings.Development.json:

    • For development, SQLite is used by default
    • For production, configure the SQL Server connection string
    • Configure Azure AD B2C settings
  2. Apply database migrations:

dotnet ef database update
  1. Run the application:
dotnet run

The API will be available at:

Authentication

The API uses Azure AD B2C for authentication. Users must be assigned one of the following roles:

  • Admin: Full access to all endpoints
  • Zookeeper: Access to animal and feeding schedule management
  • Veterinarian: Access to animal and health record management
  • Guest: Read-only access to animal information

API Endpoints

Animals

  • GET /api/v1/animals - List all animals (supports pagination)
  • GET /api/v1/animals/{id} - Get a specific animal
  • POST /api/v1/animals - Create a new animal
  • PUT /api/v1/animals/{id} - Update an animal
  • DELETE /api/v1/animals/{id} - Archive an animal (soft delete)

Feeding Schedules

  • GET /api/v1/feedingschedules - List all feeding schedules
  • GET /api/v1/feedingschedules/{id} - Get a specific schedule
  • POST /api/v1/feedingschedules - Create a new schedule
  • PUT /api/v1/feedingschedules/{id} - Update a schedule
  • DELETE /api/v1/feedingschedules/{id} - Delete a schedule

Health Records

  • GET /api/v1/healthrecords - List all health records
  • GET /api/v1/healthrecords/{id} - Get a specific record
  • POST /api/v1/healthrecords - Create a new record
  • PUT /api/v1/healthrecords/{id} - Update a record
  • DELETE /api/v1/healthrecords/{id} - Delete a record

Development

The solution uses:

  • Entity Framework Core for data access
  • SQLite for development database
  • SQL Server for production database
  • Global error handling middleware
  • Role-based authorization
  • Azure AD B2C integration

Database Schema

  • Animals: Basic information about primates
  • FeedingSchedules: Feeding times and food items
  • HealthRecords: Medical history and examinations

Test Data

In development mode, the database is automatically seeded with test data:

  • 6 animals (5 active, 1 archived)
  • 5 feeding schedules
  • 12 health records

Production Deployment

  1. Update the SQL Server connection string in appsettings.json
  2. Configure Azure AD B2C settings
  3. Apply migrations to production database:
dotnet ef database update --connection "your-production-connection-string"
  1. Deploy using your preferred hosting method (Azure App Service recommended)

Error Handling

The API includes global error handling that returns consistent error responses:

  • Validation errors (400 Bad Request)
  • Not found errors (404 Not Found)
  • Authorization errors (401 Unauthorized)
  • Permission errors (403 Forbidden)
  • Server errors (500 Internal Server Error)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages