How ilyayushchuk/forestlike works
Project Type and Purpose
• ForestLike is a full-stack productivity application composed of:
• A client (ForestLike project) that runs timers, monitors activity, and displays UI.
• A server (Server project) that exposes storage and business endpoints.
• A serializer library (Serializer project) for converting domain entities to/from JSON or binary.
• The app’s core functions are timer management (solo and cooperative), activity observation, user authentication, rating/statistics, and local/remote persistence.
File Structure
• Top-level solution “ForestLike.sln” contains multiple projects:
• ForestLike (client/presentation + business logic)
• Server (API + data access)
• Serializer (shared serialization library)
• LR_3 (sample or legacy console project, can be ignored in microservice design)
• ForestLike/Services and ForestLike/ClientServerLogic hint at client-side API calls.
• Server/DBServices implements IStorageController with two adapters (local vs. remote).
• Serializer/Entities define DTOs: User, Record, CooperativeRecord.
README Insights
• Three layers are already defined: Presentation, Business-Logic, DataAccess.
• DataAccess uses a strategy pattern (IStorageController → DBController or LocalStorageController).
• Business-Logic manages User, Timer, CooperativeTimer, ActivityObserver, Statistic, Record entities.
Decompose into Microservices
a. API Gateway
• Single entry point for the client. Routes calls to downstream microservices.
• Handles SSL termination, authentication token validation, load balancing.
b. Auth Service
• Manages user registration, login, logout, password changes.
• Exposes endpoints: /auth/register, /auth/login, /auth/logout, /auth/me.
• Owns User data store and issues JWTs.
c. Timer Service
• Manages solo timers and cooperative timers.
• Exposes endpoints: /timers/start, /timers/stop, /timers/status.
• Publishes events (TimerStarted, TimerStopped, TimerFailed) to a message bus.
d. Cooperative Session Service
• Coordinates two-user sessions.
• Listens for Timer service events, enforces “both must succeed” rule.
• Exposes endpoints: /cooperative/join, /cooperative/leave.
e. Statistics Service
• Consumes events from message bus, aggregates stats (favorite themes, average time, leaderboards).
• Exposes endpoints: /stats/user/{id}, /stats/global.
f. Storage Service (DataStore)
• Central service (or multiple data stores) for persisting Users, Records, CooperativeRecords.
• Could be implemented as separate database microservices:
• User DB (SQL)
• Records DB (NoSQL or SQL)
• Alternatively, each microservice owns its own datastore.
g. Serializer Service (optional)
• Shared library rather than microservice—packaged as NuGet. Used by all services.
Relationships & Data Flow
• Client (ForestLike desktop/mobile app) → API Gateway → respective microservice.
• Auth Service returns JWT → Client attaches to Timer/Cooperative/Stats requests.
• Timer Service emits events to Message Bus (e.g., RabbitMQ, Kafka).
• Cooperative Service & Statistics Service subscribe to events.
• Each service reads/writes its own database.
• Serializer library is shared across services for consistent DTO formats.
Architectural Patterns & Technologies
• Patterns:
• API Gateway (routing, auth)
• Backend-for-Frontend (client-specific orchestration)
• Event-driven (Timer → Message Bus → Stats/Coop)
• Database per Service (bounded contexts)
• Technologies:
• .NET 8 / ASP.NET Core WebAPI for microservices
• JWT for authentication
• gRPC or HTTP REST (JSON) for inter-service calls
• RabbitMQ / Kafka for event bus
• SQL Server or SQLite (local fallback)
• Docker & Kubernetes for deployment
• Clear labels for each component (API Gateway, Auth Service, etc.).
• Notes on technology (e.g., .NET 8, RabbitMQ).