How avansbitbybit/api works
Project type and purpose
• BitByBitTrashAPI is a .NET 8 (ASP.NET Core) Web API that exposes endpoints for managing trash pickups, handling user roles/authentication, and providing weather data for pickup locations.
• It uses Entity Framework Core for persistence (with migrations under Migrations/), ASP Net Identity for authentication, calls out to external geocoding & weather APIs, is containerized via Docker, and has CI/CD workflows in GitHub Actions.
File structure
• Top‐level folders:
• BitByBitTrashAPI/ – the main Web API project
– Controllers/ (AdminController.cs, LitterController.cs, DummyTrashController.cs, WeatherController.cs)
– DBContext/ (ApplicationDbContext.cs for Identity, LitterDbContext.cs for trash/weather data)
– Migrations/ (EF Core schema migrations)
– Models/ (DTOs and entity definitions: TrashPickup.cs, WeatherModel.cs, AddRoleRequest.cs)
– Service/ (service abstractions & implementations: IAuthenticationService, AspNetIdentityAuthenticationService, IGeocodingService, GeocodingService, IWeatherApiService, WeatherApiService, etc.)
– Program.cs (host setup, DI registration, seeding)
– appsettings.json & appsettings.Development.json
– Dockerfile
– BitByBitTrashAPI.http (sample API calls)
• BitByBitTrashAPI.Tests/ – unit tests for controllers, services, and DbContext
• .github/workflows/ – CI/CD pipelines for auto‐deploy
README
• Minimal content (“# BitByBitTrashAPI”), so we rely on file/folder names to infer architecture: layered Web API, EF Core, external HTTP services, Docker, GitHub Actions.
a. Main components:
1. Clients (Web UI, Mobile App, Postman/CLI)
2. BitByBitTrashAPI (runs in Docker)
– Controllers layer
– Services layer (authentication, geocoding, weather, seeding)
– Data layer (EF Core DbContexts)
3. Database (SQL Server / Azure SQL)
4. External HTTP services (Geocoding API, Weather API)
5. CI/CD Pipeline (GitHub Actions → Docker registry → Hosting platform)
b. Relationships & interactions:
– Client → HTTP → Controllers
– Controllers → Services (via injected interfaces)
– Services → DbContext → Database
– Services → External APIs (geocoding, historical and forecast weather)
– Program.cs at startup runs migrations & SeedRoles to initialize Identity roles
– GitHub Actions watches master, builds Docker image, pushes to registry, and deploys container to hosting
c. Architectural patterns & principles:
– Layered architecture: Presentation (Controllers), Business (Services), Data (DbContexts).
– Dependency Injection (IAuthenticationService, IGeocodingService, etc.).
– Code-first migrations with EF Core.
– Single‐responsibility controllers and services.
– Containerization for environment consistency.
– Automated CI/CD.
d. Key technologies/frameworks:
– ASP .NET Core Web API
– Entity Framework Core (+ Migrations)
– ASP NET Identity
– Docker
– GitHub Actions
– External REST services (e.g., OpenWeatherMap, Google Geocoding)