Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

Responsive API

A modern, scalable ASP.NET Core Web API project demonstrating clean architecture principles and best practices for building production-grade REST APIs.

Overview

Responsive API is a comprehensive project management system built with ASP.NET Core 8.0, featuring a well-organized architecture with clear separation of concerns.

Project Structure

ResponsiveAPI/
├── Controllers/ # API endpoint controllers
│ ├── UsersController
│ ├── ProjectsController
│ └── TasksController
├── Models/ # Data models and DTOs
│ ├── User.cs
│ ├── Project.cs
│ ├── Task.cs
│ └── DTOs/
├── Services/ # Business logic layer
│ ├── UserService
│ ├── ProjectService
│ └── TaskService
├── Repositories/ # Data access layer
│ ├── UserRepository
│ ├── ProjectRepository
│ └── TaskRepository
├── Interfaces/ # Interface definitions
│ ├── IUserService
│ ├── IProjectService
│ ├── IUserRepository
│ └── More...
├── Data/ # Database context
│ └── ApplicationDbContext
├── Middleware/ # Custom middleware
│ ├── ErrorHandlingMiddleware
│ └── LoggingMiddleware
├── Configurations/ # AutoMapper profiles
├── Extensions/ # Service extensions
├── Utils/ # Utility helpers
└── Program.cs # Application entry point

Features

  • RESTful API Endpoints for Users, Projects, and Tasks
  • Entity Framework Core for data access with SQL Server
  • Dependency Injection for loose coupling
  • AutoMapper for object mapping
  • Swagger/OpenAPI documentation
  • Error Handling Middleware for consistent error responses
  • Logging Middleware for request/response tracking
  • Repository Pattern for clean data access
  • Service Layer for business logic
  • CORS support for cross-origin requests

API Endpoints

Users

  • GET /api/users - Get all users
  • GET /api/users/{id} - Get user by ID
  • POST /api/users - Create new user
  • PUT /api/users/{id} - Update user
  • DELETE /api/users/{id} - Delete user

Projects

  • GET /api/projects - Get all projects
  • GET /api/projects/{id} - Get project by ID
  • GET /api/projects/user/{userId} - Get projects by user
  • POST /api/projects - Create new project
  • PUT /api/projects/{id} - Update project
  • DELETE /api/projects/{id} - Delete project

Tasks

  • GET /api/tasks - Get all tasks
  • GET /api/tasks/{id} - Get task by ID
  • GET /api/tasks/project/{projectId} - Get tasks by project
  • GET /api/tasks/user/{userId} - Get tasks by user
  • POST /api/tasks - Create new task
  • PUT /api/tasks/{id} - Update task
  • DELETE /api/tasks/{id} - Delete task

Technologies

  • .NET 8.0
  • ASP.NET Core Web API
  • Entity Framework Core
  • AutoMapper
  • Swagger/OpenAPI
  • SQL Server

Getting Started

Prerequisites

  • .NET 8.0 SDK or later
  • SQL Server or SQL Server Express
  • Visual Studio or VS Code

Installation

  1. Clone the repository
  2. Update connection string in appsettings.json
  3. Run migrations: dotnet ef database update
  4. Run the application: dotnet run

Database

The project uses Entity Framework Core with SQL Server. The default connection string is:

Server=.;Database=ResponsiveAPI;Trusted_Connection=true;TrustServerCertificate=true;

Architecture

This project follows clean architecture principles:

  • Controllers: Handle HTTP requests and responses
  • Services: Implement business logic
  • Repositories: Manage data access
  • Models: Define domain entities and DTOs
  • Interfaces: Define contracts for services and repositories

Configuration

appsettings.json

Contains configuration for:

  • Database connection strings
  • Logging levels
  • API settings

appsettings.Development.json

Development-specific settings with detailed error logging.

Usage Examples

Create a User

POST /api/users
Content-Type: application/json
{
 "firstName": "John",
 "lastName": "Doe",
 "email": "john@example.com",
 "phoneNumber": "+1234567890"
}

Create a Project

POST /api/projects?userId=1
Content-Type: application/json
{
 "title": "My Project",
 "description": "Project description",
 "startDate": "2024年03月27日",
 "endDate": "2024年12月31日"
}

Development

Building the Project

dotnet build

Running Tests

dotnet test

Running the Application

dotnet run

The API will be available at https://localhost:5001 and Swagger UI at https://localhost:5001/ (in Development mode).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Author

Responsive API Team

Support

For support, please open an issue in the repository.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /