A RESTful API for managing todo items built with ASP.NET Core, designed for beginners learning web API development.
TodoApi is a simple, lightweight API that allows you to create, read, update, and delete todo items. It's built using ASP.NET Core and follows RESTful principles. This project is intended as a learning resource for developers who are new to .NET Web APIs and want to understand layered architecture implementation.
This project is dedicated to developers who are willing to create .NET Web APIs and Applications. For beginners who want to follow layered architecture for their projects, this serves as an excellent starting point.
Unlike traditional approaches, Web APIs offer numerous advantages:
- Security: Better protection of your data and business logic
- Separation of Concerns: Clear distinction between frontend and backend
- Implementation Hiding: Users only interact with what they need to see
- Scalability: Easier to scale backend services independently
- Reusability: Same API can serve multiple client applications
The project demonstrates concepts like DTOs, repositories, and proper API design that you can implement in your own projects. For more advanced implementations of these concepts, check out my other projects.
- Create new todo items
- Retrieve a list of all todo items
- Retrieve a specific todo item by ID
- Update existing todo items
- Delete todo items
- Filter todos by completion status
- Search todos by name
- ASP.NET Core
- Entity Framework Core
- SQL Server (or your database of choice)
- Swagger/OpenAPI for documentation
- React (frontend)
- .NET 6.0 SDK or newer
- Visual Studio or VS Code
- Node.js and npm (for frontend)
- Database (SQL Server, SQLite, etc.)
-
Clone the repository:
git clone https://github.com/shevon2000/TodoApi.git cd TodoApi -
Restore dependencies:
dotnet restore
-
Update the connection string in
appsettings.jsonto point to your database. -
Apply database migrations:
dotnet ef database update
-
Run the API:
dotnet run
The API will be available at
https://localhost:5001orhttp://localhost:5000. -
In a separate terminal, run the frontend:
cd client npm install npm startThe React frontend will be available at
http://localhost:3000.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/todos | Get all todo items |
| GET | /api/todos/{id} | Get a specific todo item |
| POST | /api/todos | Create a new todo item |
| PUT | /api/todos/{id} | Update a todo item |
| DELETE | /api/todos/{id} | Delete a todo item |
| GET | /api/todos/completed | Get completed todo items |
| GET | /api/todos/incomplete | Get incomplete todo items |
The repository includes a Postman collection file (TodoAPI.postman_collection.json) that contains pre-configured API requests for testing all endpoints. To use it:
- Import the collection into Postman
- Ensure your API is running
- Execute the requests to test the functionality
This is a great way to practice understanding API request handling without needing to build a frontend right away.
The application can be configured in the appsettings.json file. Here you can set:
- Database connection string
- Logging options
- CORS policies
- Other application-specific settings
TodoApi/
├── Controllers/ # API controllers
├── Models/ # Data models
├── Data/ # Database context and migrations
├── Services/ # Business logic
├── Properties/ # Configuration properties
├── client/ # React frontend
├── appsettings.json # Application settings
└── Program.cs # Application entry point
After understanding this basic implementation, consider enhancing your knowledge by:
- Implementing a repository pattern
- Adding DTOs for better data encapsulation
- Implementing authentication and authorization
- Creating more complex data relationships
- Adding validation and error handling
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Shevon - GitHub Profile | LinkedIn
Project Link: https://github.com/shevon2000/TodoApi