A robust, scalable, and maintainable ASP.NET Code Web API (C#) for the LMS Studi platform.
This repository contains the backend service responsible for business logic, data access, and external integrations required by Studi clients.
Status: Active development
studi-api is the backend API layer for the Studi ecosystem. It is designed to provide secure, versionable, and testable endpoints for LMS clients.
Typical responsibilities include:
- User and role management
- Authentication and authorization
- Domain/business operations
- Data persistence
- Validation and error handling
- Integrations with external systems
- Clean RESTful API monolith design
- N-Layer architecture (Web API Layer / Business Logic Layer / Data Access Layer)
- JWT-based authentication & authorization
- DTO mapping and request validation
- Centralized exception handling and structured logging
Studi is the backend service for an online learning platform. This repository contains the ASP.NET Core Web API (Studi.WebApi), the business logic layer (Studi.BLL), the data access layer (Studi.DAL), and unit/integration tests.
This README provides step-by-step, reproducible instructions for a developer starting from a clean Windows machine to get the service running locally and to run tests.
- Overview
- Purpose
- Requirements
- Quick start
- Configuration
- Database and migrations
- Running the API
- Tests
- Configuration summary (critical keys)
- Helpful commands
- Troubleshooting
- Security and secrets
- Contributing
- License
- Where to look in the code
- Windows 10/11
- .NET SDK 9.x — install from https://dotnet.microsoft.com/download/dotnet/9.0
- Git — https://git-scm.com/
- MS SQL Server (Developer/Express) or Docker (recommended) with SQL Server image
mcr.microsoft.com/mssql/server:2022-latest dotnet-efCLI tool for Entity Framework Core migrations:dotnet tool install --global dotnet-ef- FFmpeg (
ffprobe) — either in PATH or specify full path in configuration - (Optional) Visual Studio 2022/2023 or Visual Studio Code
- Clone repository
git clone https://github.com/Michael-Kolpakov/studi-api.git
cd studi-api- Verify .NET SDK and install
dotnet-efif necessary
dotnet --version
dotnet tool install --global dotnet-ef- Start SQL Server in Docker (recommended)
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=DevPass123!" -p 1433:1433 --name studi-mssql -d mcr.microsoft.com/mssql/server:2022-latest- Configure local settings
- Open
Studi.WebApi/appsettings.Local.jsonand set required values:ConnectionStrings:DefaultConnection— connection string to your SQL Server (example provided useslocalhostand passwordDevPass123!).Jwt:SigningKey— set a secure signing key for JWT tokens.Smtp— SMTP host/port/credentials if the application will send email.GoogleDriveStorage— fill only if Google Drive integration is needed.Ffprobe:ExecutablePath— set eitherffprobe(if in PATH) or full path toffprobe.exe.
- Restore packages and build
dotnet restore
dotnet build -c Debug- Apply EF Core migrations (creates database schema)
dotnet ef database update --project "Studi.DAL" --startup-project "Studi.WebApi"- Run the API
cd Studi.WebApi
dotnet runThe application will start and print listening URLs. By default, Swagger UI is available at /swagger (e.g. https://localhost:7xxx/swagger).
Open Studi.sln in Visual Studio 2022/2023 (with .NET 9 SDK installed) and set Studi.WebApi as the startup project, then run with the debugger.
Run all tests in the solution:
dotnet testRun a single test project (example):
dotnet test Studi.XUnitTests/Studi.XUnitTests.csprojConnectionStrings:DefaultConnection— database connection string used by EF Core.Jwt:SigningKey— secret used to sign JWT tokens; keep it secure.Smtp— SMTP configuration for sending emails.GoogleDriveStorage— OAuth/service account settings for Google Drive integration.Ffprobe:ExecutablePath— path or binary name forffprobeused by video processing.
All example values and defaults are present in Studi.WebApi/appsettings.Local.json.
- Restore and build:
dotnet restore && dotnet build - Apply migrations:
dotnet ef database update --project "Studi.DAL" --startup-project "Studi.WebApi" - Create migration:
dotnet ef migrations add MyMigration --project "Studi.DAL" --startup-project "Studi.WebApi" - Run SQL Server in Docker: use the
docker runcommand above. - Verify
ffprobe:ffprobe --version
- Configuration files:
- Root StyleCop settings:
stylecop.json(repository root). - Shared analyzer package and build flags:
Directory.Build.props(referencesStyleCop.Analyzers, enablesRunAnalyzersand treats analyzer diagnostics as errors). - Analyzer severities and overrides:
.editorconfig(repository root).
- Root StyleCop settings:
- Where to find full guidance:
STYLECOP.md(detailed team policy and commands). - How it is enforced:
- StyleCop runs as Roslyn analyzers during
dotnet buildfor all projects in the solution. - Build-time flags (
EnforceCodeStyleInBuild,RunAnalyzersDuringBuild,CodeAnalysisTreatWarningsAsErrors) promote analyzer diagnostics to errors — CI and local builds fail on violations. - A
check-code.ps1script (inscripts/) runs the full code quality gate (restore, build with analyzers, format check, tests).
- StyleCop runs as Roslyn analyzers during
- IDE integration and developer workflow:
- Visual Studio and VS Code (with C# extension) show StyleCop diagnostics inline — fix warnings/errors in the editor.
- To run analyzers locally:
dotnet build Studi.sln(or use thecheck-code.ps1script for the full gate). - To temporarily bypass analyzer failures for quick experiments, you may build with
-p:RunAnalyzers=false(not recommended for commits/PRs).
- Pre-commit and CI:
- The repository provides a Git hook (
.githooks/pre-commit) and setscore.hooksPath=.githooksto run the build and block commits with analyzer errors. - CI pipelines should run
dotnet build(with analyzers) anddotnet testas part of the quality gate.
- The repository provides a Git hook (
- Tuning rules:
- Change severity per rule using
.editorconfig(for example:dotnet_diagnostic.SA1600.severity = none). - Change behavioral rules (ordering, layout, documentation options) in
stylecop.json. - Use
Directory.Build.propsto update analyzer package version or global analyzer settings.
- Change severity per rule using
This section summarizes StyleCop usage in this repository; see STYLECOP.md for the full policy, examples, and script options.
- "Cannot connect to SQL Server": Ensure the SQL Server instance or Docker container is running, port 1433 is reachable, and
ConnectionStrings:DefaultConnectionis correct. - "dotnet-ef not found": Install the tool with
dotnet tool install --global dotnet-efand restart your terminal. - "ffprobe not found": Install FFmpeg and ensure
ffprobeis in PATH or setFfprobe:ExecutablePathto the executable path. - Migration errors: confirm
--startup-projectisStudi.WebApiand--projectisStudi.DALwhen running EF commands.
- Do not commit secrets. Use
appsettings.Local.jsonfor local development, environment variables, ordotnet user-secretsfor per-developer secrets. - In production, use a secrets manager (Azure Key Vault, AWS Secrets Manager, etc.).
Contributions are welcome. Please fork the repository, create a feature branch, and open a pull request. Follow conventional commits and keep PRs focused.
This repository is licensed under the MIT License. See the LICENSE file in the repository root.
- API and startup:
Studi.WebApi - Database context and migrations:
Studi.DAL/Persistence - Business logic:
Studi.BLL