Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jparra-amell/api_solsql/llms.txt

Use this file to discover all available pages before exploring further.

SolSQL API is a RESTful service built on ASP.NET Core 8 with a MySQL backend. Every database operation runs through MySQL stored procedures — controllers never issue raw EF queries directly against tables. This design centralizes business logic in the database layer and keeps controller code thin.

Technology stack

ComponentTechnology
RuntimeASP.NET Core 8 (.NET 8)
DatabaseMySQL (Pomelo EF Core provider)
ORMEntity Framework Core 8 (FromSqlInterpolated)
Password hashingBCrypt.Net
API docsSwagger / OpenAPI (Swashbuckle)
ContainerizationDocker

Key services configured in Program.cs

The following services are registered in Program.cs before builder.Build() is called:
ServiceRegistration methodPurpose
ControllersAddControllers()Registers all [ApiController] routes
Swagger / OpenAPIAddEndpointsApiExplorer() + AddSwaggerGen()Generates the interactive API explorer
MySQL / EF CoreAddDbContext<ContextDB>()Provides the ContextDB dependency to every controller
CORSAddCors() with "AllowAll" policyPermits cross-origin requests from any client
Response cachingAddResponseCaching()Enables HTTP response cache headers

Stored procedure pattern

Controllers call stored procedures through EF Core’s FromSqlInterpolated method rather than querying DbSet properties with LINQ. For example, the login endpoint executes:
var users = await _context.LoginRequests
    .FromSqlInterpolated($"CALL sp_login({request.Email}, {request.Role})")
    .ToListAsync();
This pattern applies across all controllers. Parameters are passed as interpolated variables, which EF Core converts to parameterized queries to prevent SQL injection.

CORS policy

The "AllowAll" CORS policy is registered and applied globally:
builder.Services.AddCors(options => {
    options.AddPolicy("AllowAll",
        policy => policy
            .AllowAnyOrigin()
            .AllowAnyMethod()
            .AllowAnyHeader());
});
app.UseCors("AllowAll");
This permits requests from any origin, using any HTTP method, with any request headers. You can tighten this policy for production deployments by replacing AllowAnyOrigin() with a specific origins list.
The AllowAnyOrigin() setting is permissive by design for development. Before exposing the API publicly, restrict allowed origins to your known client domains.

Response caching

Response caching middleware is registered and enabled:
builder.Services.AddResponseCaching();
// ...
app.UseResponseCaching();
Controllers can instruct the middleware to cache responses by adding [ResponseCache] attributes to actions. Caching reduces repeated database load for read-heavy endpoints.

Swagger UI

Swagger is available at /swagger in all environments. The endpoint is configured as:
app.UseSwagger();
app.UseSwaggerUI(c => {
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1");
    c.RoutePrefix = "swagger";
});
Visit http://<host>/swagger to browse all endpoints interactively and send test requests without a separate API client.
HTTPS redirection (UseHttpsRedirection) is commented out in Program.cs. If you deploy behind a TLS-terminating proxy (such as nginx or a cloud load balancer), the proxy handles HTTPS and the API can remain on HTTP internally.

Docker deployment

The project includes Docker support. You can build and run the API in a container, which bundles the .NET runtime and application together. Set the Connection_mysql connection string in your environment or Docker Compose configuration to point to your MySQL instance.
docker build -f api_solsql/Dockerfile -t solsql-api .
docker run -p 8080:8080 \
  -e ConnectionStrings__Connection_mysql="Server=db;Database=solsql;User=root;Password=secret;" \
  solsql-api
The API starts on the configured port and connects to MySQL using the Pomelo provider with auto-detected server version.

Build docs developers (and LLMs) love