SpanishByExample is a RESTful Web API that allows Spanish learners to collaboratively create and share example sentences which are meaningful to them.
Author: David Pasch
Date: 2026/03
This repository contains a sample Web API developed as part of my personal portfolio. Its purpose is to demonstrate API design, backend architecture, and best practices in C# and ASP.NET Core.
- C#
- .NET10
- ASP.NET Core 10 Web API
- SQL Server
- JWT Authentication
- xUnit, Moq, FluentAssertions
- GitHub Actions (CI)
You need the following tools for running the project:
- Visual Studio 2026
- SQL Server
- Postman (for API testing)
- User registration and authentication (JWT)
- Create vocabulary entries with examples
- Retrieve vocabulary with usage examples
- Input validation and error handling
- Layered architecture (API, Business, Data Access)
The following steps are necessary for setting up the project:
-
First, you need to create an empty database on the SQL Server, e.g.
spanish_ex -
Next, you need to configure the Web API through the
appsettings.jsonfile:- Set the database connection string.
- Set a private key for signing the token during JWT user authentication.
-
Finally, you setup the database.
For this to work ensure that:
- The connection string is set in
appsettings.json. - You're in the Api project's root directory.
- The Api project is both the Default project and Startup project.
Then run the following command from the Package Manager Console:
- The connection string is set in
Update-Database
That's it!
You're ready to try out the Web API.
Once you have setup the project and have a running Web API, you can do the following:
- Register a new user and login through the public endpoints
/api/Auth/registerand/api/Auth/login. - Create a new vocabulary entry with usage examples through the protected endpoint
/api/Vocabulary.- NOTE: You must provide at least one usage example.
- Retrieve a vocabulary entry with its usage examples through the public endpoint
/api/Examples.
NOTE: The Web API currently only supports Spanish verbs in infinitive form for vocabulary entries.
You can find example requests in the Postman collection (see below).
The project repository contains the following files:
/database
/seed # scripts to populate the database with sample data
/tests # scripts to test the database
/postman # Postman files for API Testing
/src # source code
/tests # unit tests
The Web API is realized as a three layered architecture. It consists of the following projects:
SpanishByExample.sln
│
├─ SpanishByExample.Core
│ ├─ Services
│ ├─ Commands
│ ├─ Entities
│ └─ Errors
├─ SpanishByExample.Api
│ ├─ Authentication
│ ├─ Controllers
│ └─ Dtos
├─ SpanishByExample.Business
├─ SpanishByExample.DataAccess
└─ SpanishByExample.Tests
The projects implement the following layers:
- The top layer is the
Apilayer which implements the interface to the user application. - The middle layer is the
Businesslayer which implements the business logic and shields the Api layer from the database communication. - And finally, the bottom layer is the
DataAccesslayer which handles the communication with the database.
The SpanishByExample.Api project contains:
Authentication: classes needed for implementing the user authentication.Controllers: controllers implementing the endpoints of the Web API.Dtos: DTOs used by the controllers to pass data from and to the clients.
The design of the layers is based on the Facade design pattern. The communication of information between the layers, i.e. data and errors, are conveyed in types specific to the layer in order to insulate the upper layers from the lower ones.
The SpanishByExample.Core project contains the interfaces and classes that are shared among all the other projects.
It contains:
Services: interfaces of the dependency-injected services.Commands: commands to specify the tasks theBusinesslayer has to do.Entities: classes representing domain entities.Errors: custom exceptions for communicating errors from lower layers.
The SpanishByExample.Tests project implements the Unit tests that are executed as part of the CI pipeline, typically on Pull Requests.
This section describes the testing activities that were performed in order to ensure the quality of the product.
Business logic and controllers tested with Regression tests at Component level.
Tools used:
- xUnit
- Moq
- FluentAssertions
Manual end-to-end tests using Postman:
- User registration
- User authentication
- Vocabulary search
- Creation of vocabulary entries
- Error handling
The Test Environment consists of:
- ASP.NET Core Web API
- JWT authentication
- SQL Server
- Deployment using dotnet publish
A Postman environment and collection are included in the postman/ directory.
Steps:
- Start the API
- Import Environment into Postman and fill out missing values
- Import the Collection into Postman
- Run the "Register" and "Login" requests to create and authenticate a user
- Store the JWT Token in the Environment
- Run the "POST" request of the Vocabulary folder to create an entry in the database
- Run the "GET" request of the Examples folder to read the entry from the database
- Integrate an external 3rd party dictionary service
- Implement additional use cases like example management for authorized users
- Add integration tests
- Dockerize the application