SpotLights is a self-hosted open source publishing platform written in .NET Core 8.0 and Blazor WebAssembly with Clean Architecture. It can be used to quickly and easily set up a lightweight, but fully functional personal or community blog.
If you want to customize the SpotLights, or contribute:
- Download, fork, or clone the repository.
- Download .NET 8.0 SDK Choose to install the system version on your host.
- Nodejs 14 and above and install it on your host. Download
- Requires RDBMS whichever you prefer (Mssql Server, Postgres or Sqlite all are supported)
- Requires Redis for caching
- Set SpotLights.Application as start up project.
- Open the project with your favorite IDE (VS Code, Visual Studio, Atom, etc).
- Run the app with your IDE or these commands:
$ cd /your-local-path/SpotLights/src/SpotLights.Application
$ dotnet run
Then you can open localhost:5000
with your browser
Update provider and connection string in the appsettings.json
:
"SpotLights": {
"DbProvider": "Mssql",
"ConnString": "Data Source=mssql; User Id=sa; Password=Password; Initial Catalog=SpotLights;TrustServerCertificate=True",
...
}
In the latest version of sql server connection, SqlClient will perform a secure connection by default, and you need to add a server certificate to the system.
"SpotLights": {
"DbProvider": "Sqlite",
"ConnString": "Data Source=App_Data/SpotLights.db",
...
}
It is recommended to put the database file under the App_Data folder. The logs and local pictures in the project will be stored in this path for persistence.
"SpotLights": {
"DbProvider": "Postgres",
"ConnString": "Host=postgres;Username=postgres;Password=password;Database=SpotLights;",
...
}
In the above example, ConnString requires you to fill in the correct database host address username and password to connect normally
Currently redis is configured and required for running the application
"SpotLights": {
"Redis": "127.0.0.1:6379,defaultDatabase=0",
...
}
The database migration is stored in the src/SpotLights.Data/Migrations directory.
Should run all the commands in root solution directory (Solution root -> Right Click -> Open In Terminal)
# Before proceed make sure you have dotnet-ef tools are installed in your system
dotnet tool install --global dotnet-ef
# Create New Migration
dotnet ef migrations add Migration_Name --project=src\SpotLights.Data\SpotLights.Data.csproj --startup-project=src\SpotLights\SpotLights.csproj --context ApplicationDbContext
# Update Database
dotnet ef database update --project=src\SpotLights.Data\SpotLights.Data.csproj --startup-project=src\SpotLights\SpotLights.csproj --context ApplicationDbContext
Solution
├── SpotLights.Admin(Contains Admin Dashboard related files)
│ ├── Webassembly dependencies
│ ├── Views, Components, Pages
│ └── Assests, wwwroot
│
├── SpotLights.Application (Startup Web Project)
│ ├── Api Controller
│ ├── View Controller
│ └── Views
│
├── SpotLights.Core
│ ├── Services
│ └── Views
│
├── SpotLights.Infrastructure
│ ├── Repositories
│ ├── Identity
│ ├── Caches
│ ├── Managers
│ └── Providers
│
├── SpotLights.Data
│ ├── DbContext
│ ├── Entity Configurations
│ └── Migrations
│
├── SpotLights.Domain
│ ├── Entity Model
│ ├── Dao
│ └── Dto
│
└── SpotLights.Shared
├── Constants
├── Enums
├── Dto
├── Extensions
├── Viewmodels
├── Resources
└── Helpers
On the first login, user gets redirected to the admin/register
page to register a new account.
Once account created, registration page is disabled and this user becomes a blog owner.
The blog posts, including blog themes, are all run as public, server-side rendered MVC site.
Anything under admin
is Blazor Web Assembly application and is guarded by custom authentication provider (BlogAuthenticationStateProvider
).
User password is one-way hashed and saved in the Authors
table on the back-end.
The salt used to hash password pulled from appsettings.json
configuration file and should be updated before creating user account.
"SpotLights": {
...
"Salt": "SECRET-CHANGE-ME!"
}
Logging done using Serilog Sink File package.
All logs saved to the /Logs
folder as configured in the application startup:
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File("Logs/log-.txt", rollingInterval: RollingInterval.Day)
.CreateLogger();
Log.Warning("Test log");
Do not add or delete database migration at will. After the application generates data, random migration may cause data loss. This project will automatically apply the migration when it starts.