How fisiu/kosync-dotnet works
Project Overview
• The project is a backend web API service built on .NET. It implements a sync server for KOReader that allows users to register, manage, and synchronize reading progress across devices.
• It is designed for containerized deployment (using Docker) and uses a LiteDB database file to persist user and document progress information.
• The README also describes management API endpoints for listing users, creating users, toggling active status, and updating passwords.
File Structure and Architectural Components
• Controllers (Controllers/ManagementController.cs, Controllers/SyncController.cs): These files indicate two primary API controllers that expose endpoints for admin management and synchronization operations.
• Services (e.g., Services/UserService.cs): This layer encapsulates business logic such as handling user operations. Controllers are expected to call these services.
• Models (e.g., Models/DocumentRequest.cs and others): These represent the data transfer objects (DTOs) used in communication between the controllers and the services.
• Database (Database/KosyncDb.cs, Database/Entities/*.cs): Contains database context and entity definitions modeled for LiteDB.
• GlobalUsings.cs and Program.cs: Point to modern .NET .NET Core implementation structure with startup configuration.
• Configuration files (appsettings.json, appsettings.Development.json) and Dockerfile: Provide important configuration for running the application, including environment-specific options and containerization support.
• Additional files (.github workflows, .gitignore, and Dockerfile) show the CI/CD integration and deployment configuration.
Key Components
a. API Layer:
• Controllers (ManagementController and SyncController) that expose HTTP endpoints for synchronization and management.
• A note that clients (KOReader’s syncing plugin, Postman for management interactions) interact with these endpoints.
b. Service Layer:
• A Services component (with UserService & possibly others) that encapsulates the core business logic.
c. Data Access Layer:
• Database component that includes:
• Entities (Document, User, etc.) as models.
• The KosyncDb abstracting the database interactions using LiteDB.
d. Configuration / External Integration:
• Configuration settings (appsettings.json/environment variables) that affect logging, connection details, and runtime behavior.
• How Docker (via the Dockerfile and provided CI/CD workflow files) is used to create a containerized version of the API server.
e. External Clients / Reverse Proxy:
• External clients: KOReader devices that use the inbuilt “Progress sync” plugin, and admins using Postman or similar tools to manage the API.
• That a reverse proxy (such as Nginx Proxy Manager) is recommended to route traffic from the internet to the container’s port 80.
Architectural Patterns and Design Principles
• The project clearly follows an MVC-like separation tailored for API design:
• Controllers: handling HTTP requests.
• Service layer: encapsulating business logic.
• Data access layer: interfacing with the LiteDB database.
• Separation of concerns, where each layer has its distinct responsibility.
• The usage of Docker indicates a containerized micro-deployment even if the project is a single monolith.