Skip to content

Bottle API is a .NET microservice for user authentication, product management, and order processing with JWT-based auth. It supports MySQL and follows a structured approach (Models, Controllers, Repositories, Services). Orders generate dynamic endpoints for status updates. Bottle.Tests ensures unit test coverage.

Notifications You must be signed in to change notification settings

obengkofijames/Bottle

Repository files navigation

Bottle - .NET Web API

Overview

Bottle is a structured .NET Web API project built using ASP.NET Core 9, designed for user authentication, product management, and order processing. This project follows a clean architecture with a well-defined structure for Controllers, Services, Repositories, and Models to ensure maintainability and scalability.

Features

  • User Management: Register, login, logout, and delete users.
  • Product Management: Add, update, and check product availability.
  • Order Management: Create, cancel, and update orders with a structured workflow.
  • Authentication: Uses JWT tokens for securing endpoints.
  • Database Support: Uses MySQL for persistent data storage.
  • Unit Testing: Includes xUnit tests for core functionalities.

Folder Structure

Bottle/
│-- Bottle.Api/              # Main API project
│   ├── Controllers/         # API Controllers
│   ├── Models/              # Entity Models
│   ├── Services/            # Business logic layer
│   ├── Repositories/        # Data access layer
│   ├── Middleware/          # Custom middlewares
│   ├── appsettings.json     # Application configuration
│   ├── Program.cs           # Application entry point

│
│-- Bottle.Tests/            # Unit test project
│   ├── Tests/               # Test cases for various modules
│   ├── DatabaseTests.cs     # Database connection tests
│
│-- env.example              # Example environment file (should be copied as .env)
│-- README.md                # Project documentation
│-- .gitignore               # Git ignore file
│-- Bottle.sln               # Solution file

Setup Instructions

Prerequisites

Ensure you have the following installed on your machine:

  • .NET 9 SDK
  • MySQL (for database management)
  • TablePlus or DBeaver (for database GUI management, optional)
  • Postman (for testing API endpoints, optional)

Installation

1. Clone the Repository

git [email protected]:obengkofijames/Bottle.git
cd Bottle

2. Configure Environment Variables

A sample .env.example file is provided in the root directory. Copy it and rename it as .env:

cp env.example .env

Then, open .env and configure the necessary values, such as:

DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=yourpassword
DB_NAME=bottle_db
JWT_SECRET=your-secret-key

3. Run Database Migrations

Navigate to the API project directory and apply migrations:

cd Bottle.Api
dotnet ef database update

4. Run the API

dotnet run --project Bottle.Api

5. Run Unit Tests

dotnet test

Usage

  • API runs at http://localhost:5000 (by default)
  • Use Postman or cURL to interact with API endpoints.
  • Example request for user login:
    curl -X POST "http://localhost:5000/api/auth/login" -H "Content-Type: application/json" -d '{"email": "[email protected]", "password": "password123"}'

Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m 'Added new feature').
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

License

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

About

Bottle API is a .NET microservice for user authentication, product management, and order processing with JWT-based auth. It supports MySQL and follows a structured approach (Models, Controllers, Repositories, Services). Orders generate dynamic endpoints for status updates. Bottle.Tests ensures unit test coverage.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages