commit a35cb648ff851d4512a62b0c44d394fabd6a4f7c
Author: Vojtěch Bartička <aitakaitov@gmail.com>
Date:   Thu May 19 21:45:21 2022 +0200

    Added comments to backend

diff --git a/Backend/Backend/Authentication/AuthorizationAttribute.cs b/Backend/Backend/Authentication/AuthorizationAttribute.cs
index fa6626c..9a51074 100644
--- a/Backend/Backend/Authentication/AuthorizationAttribute.cs
+++ b/Backend/Backend/Authentication/AuthorizationAttribute.cs
@@ -6,6 +6,11 @@ using Microsoft.AspNetCore.Mvc.Filters;
 
 namespace RestAPI.Authentication;
 
+/// <summary>
+/// Authorization attribute for endpoints and controllers
+/// By default minimum role is ANNOTATOR
+/// Access is granted to any role with same or higher privilege than the specified one (or default, if none is specified)
+/// </summary>
 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
 public class AuthorizeAttribute : Attribute, IAuthorizationFilter
 {
diff --git a/Backend/Backend/Controllers/AnnotationController.cs b/Backend/Backend/Controllers/AnnotationController.cs
index aac777a..54384ae 100644
--- a/Backend/Backend/Controllers/AnnotationController.cs
+++ b/Backend/Backend/Controllers/AnnotationController.cs
@@ -10,7 +10,9 @@ using RestAPI.Exceptions;
 using Models.Tags;
 using Core.Services.TagService;
 
-
+/// <summary>
+/// /annotation* endpoint controller
+/// </summary>
 namespace RestAPI.Controllers
 {
     public class AnnotationController : CommonControllerBase
diff --git a/Backend/Backend/Controllers/AuthController.cs b/Backend/Backend/Controllers/AuthController.cs
index 0157a39..b344c74 100644
--- a/Backend/Backend/Controllers/AuthController.cs
+++ b/Backend/Backend/Controllers/AuthController.cs
@@ -10,6 +10,9 @@ using RestAPI.Utils;
 
 namespace RestAPI.Controllers;
 
+/// <summary>
+/// Authentication controller
+/// </summary>
 public class AuthController : CommonControllerBase
 {
     private readonly IAuthService authService;
@@ -48,6 +51,11 @@ public class AuthController : CommonControllerBase
         }
     }
 
+    /// <summary>
+    /// Test only
+    /// </summary>
+    /// <param name="clientInfo"></param>
+    /// <returns></returns>
     [HttpGet("/auth/test")]
     [ProducesResponseType((int) HttpStatusCode.OK, Type = typeof(ClientInfo))]
     [ProducesResponseType((int) HttpStatusCode.Forbidden)]
@@ -56,7 +64,11 @@ public class AuthController : CommonControllerBase
         return clientInfo;
     }
     
-    
+    /// <summary>
+    /// Test only
+    /// </summary>
+    /// <param name="clientInfo"></param>
+    /// <returns></returns>
     [AllowAnonymous]
     [HttpGet("/auth/test/aa")]
     [ProducesResponseType((int) HttpStatusCode.OK, Type = typeof(ClientInfo))]
diff --git a/Backend/Backend/Controllers/Common/CommonControllerBase.cs b/Backend/Backend/Controllers/Common/CommonControllerBase.cs
index 99237ed..26f97f3 100644
--- a/Backend/Backend/Controllers/Common/CommonControllerBase.cs
+++ b/Backend/Backend/Controllers/Common/CommonControllerBase.cs
@@ -4,6 +4,10 @@ using System.Net;
 
 namespace RestAPI.Controllers.Common;
 
+/// <summary>
+/// Base controller with universal headers
+/// Note that by default endpoints are [Authorize], so if an endpoint should not be logged-user-only, add [AllowAnonymous]
+/// </summary>
 [ApiController]
 [Authorize]
 [ProducesResponseType((int)HttpStatusCode.InternalServerError)]
diff --git a/Backend/Backend/Controllers/DocumentController.cs b/Backend/Backend/Controllers/DocumentController.cs
index c8fa0bc..baccecf 100644
--- a/Backend/Backend/Controllers/DocumentController.cs
+++ b/Backend/Backend/Controllers/DocumentController.cs
@@ -15,7 +15,9 @@ using System.Net.Mime;
 namespace RestAPI.Controllers;
 
 
-
+/// <summary>
+/// /document* endpoint controller
+/// </summary>
 public class DocumentController : Common.CommonControllerBase
 {
     private readonly IDocumentService documentService;
diff --git a/Backend/Backend/Controllers/TagController.cs b/Backend/Backend/Controllers/TagController.cs
index 33c7c38..7125b14 100644
--- a/Backend/Backend/Controllers/TagController.cs
+++ b/Backend/Backend/Controllers/TagController.cs
@@ -13,13 +13,14 @@ using Models.Tags;
 namespace RestAPI.Controllers;
 
 
-
+/// <summary>
+/// /tag* endpoint controller
+/// </summary>
 public class TagController : Common.CommonControllerBase
 {
     private readonly ITagService tagService;
     private readonly ILogger logger;
 
-
     public TagController(ITagService tagService, ILogger logger)
     {
         this.tagService = tagService;
diff --git a/Backend/Backend/Controllers/UserController.cs b/Backend/Backend/Controllers/UserController.cs
index d793890..ed358a0 100644
--- a/Backend/Backend/Controllers/UserController.cs
+++ b/Backend/Backend/Controllers/UserController.cs
@@ -11,6 +11,9 @@ using System.Net;
 
 namespace RestAPI.Controllers
 {
+    /// <summary>
+    /// /user* endpoint controller
+    /// </summary>
     public class UserController : CommonControllerBase
     {
         private readonly Serilog.ILogger logger;
diff --git a/Backend/Backend/Exceptions/BadRequestException.cs b/Backend/Backend/Exceptions/BadRequestException.cs
index 858c9fc..76c7cc3 100644
--- a/Backend/Backend/Exceptions/BadRequestException.cs
+++ b/Backend/Backend/Exceptions/BadRequestException.cs
@@ -6,6 +6,10 @@ using System.Threading.Tasks;
 
 namespace RestAPI.Exceptions
 {
+    /// <summary>
+    /// Exception raised when there is a problem with client's request
+    /// Catched by error handling middleware
+    /// </summary>
     public class BadRequestException : Exception
     {
         public BadRequestException() { }
diff --git a/Backend/Backend/Exceptions/InternalErrorException.cs b/Backend/Backend/Exceptions/InternalErrorException.cs
index f2560de..e21c986 100644
--- a/Backend/Backend/Exceptions/InternalErrorException.cs
+++ b/Backend/Backend/Exceptions/InternalErrorException.cs
@@ -6,6 +6,10 @@ using System.Threading.Tasks;
 
 namespace RestAPI.Exceptions
 {
+    /// <summary>
+    /// Exception raised when there is an internal server error
+    /// Catched by error handling middleware
+    /// </summary>
     public class InternalErrorException : Exception
     {
         public InternalErrorException() { }
diff --git a/Backend/Backend/Middleware/ErrorMiddleware.cs b/Backend/Backend/Middleware/ErrorMiddleware.cs
index fb43d7a..7353e05 100644
--- a/Backend/Backend/Middleware/ErrorMiddleware.cs
+++ b/Backend/Backend/Middleware/ErrorMiddleware.cs
@@ -4,6 +4,9 @@ using System.Text.Json;
 
 namespace RestAPI.Middleware
 {
+    /// <summary>
+    /// Middleware for global error handling
+    /// </summary>
     public class ErrorMiddleware
     {
         private readonly RequestDelegate _next;
diff --git a/Backend/Backend/Program.cs b/Backend/Backend/Program.cs
index f79effe..5ef951b 100644
--- a/Backend/Backend/Program.cs
+++ b/Backend/Backend/Program.cs
@@ -76,8 +76,6 @@ if (app.Environment.IsDevelopment())
     app.UseSwaggerUI();
 }
 
-//app.UseHttpsRedirection();
-
 // CORS
 app.UseCors(builder => builder
                 .AllowAnyHeader()
diff --git a/Backend/Backend/Utils/ClientInfo.cs b/Backend/Backend/Utils/ClientInfo.cs
index 7b02771..e921825 100644
--- a/Backend/Backend/Utils/ClientInfo.cs
+++ b/Backend/Backend/Utils/ClientInfo.cs
@@ -2,11 +2,12 @@ using Core.Entities;
 
 namespace RestAPI.Utils;
 
+/// <summary>
+/// Request client information
+/// </summary>
 public class ClientInfo
 {
     public bool IsLogged => LoggedUser != null;
-
     public User? LoggedUser { get; set; } = null;
-
     public string IP { get; set; } = "unknown";
 }
\ No newline at end of file
diff --git a/Backend/Backend/Utils/ContextUtils.cs b/Backend/Backend/Utils/ContextUtils.cs
index ee0ddca..8fe9401 100644
--- a/Backend/Backend/Utils/ContextUtils.cs
+++ b/Backend/Backend/Utils/ContextUtils.cs
@@ -18,6 +18,11 @@ public static class ContextUtils
         }
     }
 
+    /// <summary>
+    /// Exctracts client information given HttpContext
+    /// </summary>
+    /// <param name="context"></param>
+    /// <returns></returns>
     public static ClientInfo GetClientInfo(HttpContext? context)
     {
         var ci = new ClientInfo();
diff --git a/Backend/Core/Authentication/JwtUtils.cs b/Backend/Core/Authentication/JwtUtils.cs
index f12fbb6..ab54d2c 100644
--- a/Backend/Core/Authentication/JwtUtils.cs
+++ b/Backend/Core/Authentication/JwtUtils.cs
@@ -16,7 +16,7 @@ public interface IJwtUtils
 
 public class JwtUtils : IJwtUtils
 {
-    private const int EXPIRATION_SECONDS = 8 * 60 * 60; // 8 hod
+    private const int EXPIRATION_SECONDS = 8 * 60 * 60; // 8 hrs
 
     private readonly JwtConfig _jwtConfig;
     private readonly TokenValidationParameters _tokenValidationParameters;
diff --git a/Backend/Core/Constants/Constants.cs b/Backend/Core/Constants/Constants.cs
index fece77c..7d5064f 100644
--- a/Backend/Core/Constants/Constants.cs
+++ b/Backend/Core/Constants/Constants.cs
@@ -8,6 +8,9 @@ namespace Core.Constants
 {
     public class Constants
     {
+        /// <summary>
+        /// Key for RequiredAnnotation value in database
+        /// </summary>
         public static string RequiredAnnotationsKey { get; } = "RequiredAnnotations"; 
     }
 }
diff --git a/Backend/Core/Contexts/DatabaseContext.cs b/Backend/Core/Contexts/DatabaseContext.cs
index 0bb44f9..1ac4c63 100644
--- a/Backend/Core/Contexts/DatabaseContext.cs
+++ b/Backend/Core/Contexts/DatabaseContext.cs
@@ -35,11 +35,6 @@ namespace Core.Contexts
         protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
         {
             optionsBuilder.UseNpgsql(_configuration["ConnectionString"], b => b.MigrationsAssembly("RestAPI"));
-            //optionsBuilder.UseNpgsql("Host=localhost:5432;Database=dbo;Username=myuser;Password=password");
-        }
-
-        protected override void OnModelCreating(ModelBuilder modelBuilder)
-        {
         }
     }
 }
diff --git a/Backend/Core/Entities/Annotation.cs b/Backend/Core/Entities/Annotation.cs
index 5da30e4..eb08fd0 100644
--- a/Backend/Core/Entities/Annotation.cs
+++ b/Backend/Core/Entities/Annotation.cs
@@ -11,35 +11,69 @@ namespace Core.Entities
 {
     public class Annotation : BaseEntity
     {
-        /*[ForeignKey("Document")]
-        public int DocumentId { get; set; }*/
+        /// <summary>
+        /// Document that the annotation refers to
+        /// </summary>
         public Document Document { get; set; }
         
-        /*[ForeignKey("User")]
-        public int UserId { get; set; }*/
+        /// <summary>
+        /// User the annotation is assigned to
+        /// </summary>
         public User User { get; set; }
 
-        /*[ForeignKey("User")]
-        public int UserAssignedId { get; set; }*/
+        /// <summary>
+        /// The user that assigned the annotation
+        /// </summary>
         public User UserAssigned { get; set; }
 
+        /// <summary>
+        /// The date the annotation was assigned
+        /// </summary>
         public DateTime DateAssigned { get; set; }
+        
+        /// <summary>
+        /// The state of the annotation
+        /// </summary>
         public EState State { get; set; }
+
+        /// <summary>
+        /// The date the annotation was last modified
+        /// </summary>
         public DateTime DateLastChanged { get; set; }
+
+        /// <summary>
+        /// Annotation note
+        /// </summary>
         public string Note { get; set; } = "";
 
+        //Cached information START
         public string CachedDocumentHTML { get; set; } = "";
         public string CachedStartPositions { get; set; } = "";
         public string CachedLengths { get; set; } = "";
         public string CachedClosingPositions { get; set; } = "";
         public string CachedClosingLengths { get; set; } = "";
         public string CachedCSS { get; set; } = "";
+        //Cached information END 
 
+        /// <summary>
+        /// ID of the last modified tag
+        /// </summary>
         public Guid? LastModifiedTagId { get; set; }
+
+        /// <summary>
+        /// The modification that is done
+        /// </summary>
         public EModified ModifiedType { get; set; } = EModified.NONE;
 
+        /// <summary>
+        /// Unused
+        /// </summary>
         public ICollection<Class> Classes { get; set; } = new List<Class>();
 
+        /// <summary>
+        /// So that EF creates a join table as 1 final annotation to N annotations
+        /// </summary>
+
         public ICollection<FinalAnnotation> FinalAnnotations { get; set; } = new List<FinalAnnotation>();
     }
 }
diff --git a/Backend/Core/Entities/AnnotationTag.cs b/Backend/Core/Entities/AnnotationTag.cs
index 3064397..1582ae9 100644
--- a/Backend/Core/Entities/AnnotationTag.cs
+++ b/Backend/Core/Entities/AnnotationTag.cs
@@ -11,6 +11,9 @@ namespace Core.Entities
 {
     public class AnnotationTag : AnnotationTagGeneric
     {
+        /// <summary>
+        /// The annotation the annotation tag is linked to
+        /// </summary>
         public Annotation Annotation { get; set; }
     }
 }
diff --git a/Backend/Core/Entities/AnnotationTagGeneric.cs b/Backend/Core/Entities/AnnotationTagGeneric.cs
index 6bf96c6..1fe24d8 100644
--- a/Backend/Core/Entities/AnnotationTagGeneric.cs
+++ b/Backend/Core/Entities/AnnotationTagGeneric.cs
@@ -7,18 +7,41 @@ using System.Threading.Tasks;
 
 namespace Core.Entities
 {
+    /// <summary>
+    /// Base class for tag occurences in annotations
+    /// </summary>
     public class AnnotationTagGeneric : BaseEntity
     {
+        /// <summary>
+        /// Tag
+        /// </summary>
         public Tag Tag { get; set; }
 
-        /** Nullable for optional */
+        /// <summary>
+        /// Subtag, nulllable for optional
+        /// </summary>
         public SubTag? SubTag { get; set; }
 
+        /// <summary>
+        /// Id of the instance (shared by multipart tags)
+        /// </summary>
         public Guid Instance { get; set; }
+
+        /// <summary>
+        /// The tag note
+        /// </summary>
         public string Note { get; set; }
         public int Position { get; set; }
         public int Length { get; set; }
+
+        /// <summary>
+        /// Sentiment of the tag, nullable for optional
+        /// </summary>
         public ETagSentiment? Sentiment { get; set; }
+        
+        /// <summary>
+        /// The text that the tag is covering
+        /// </summary>
         public string SelectedText { get; set; }
     }
 }
diff --git a/Backend/Core/Entities/BaseEntity.cs b/Backend/Core/Entities/BaseEntity.cs
index 37e06e3..d6f0dc4 100644
--- a/Backend/Core/Entities/BaseEntity.cs
+++ b/Backend/Core/Entities/BaseEntity.cs
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
 
 namespace Core.Entities
 {
+    /// <summary>
+    /// Base entity, defines the ID
+    /// </summary>
     public class BaseEntity
     {
        [Key]
diff --git a/Backend/Core/Entities/Class.cs b/Backend/Core/Entities/Class.cs
index 198cbf2..6516e39 100644
--- a/Backend/Core/Entities/Class.cs
+++ b/Backend/Core/Entities/Class.cs
@@ -7,6 +7,9 @@ using System.Threading.Tasks;
 
 namespace Core.Entities
 {
+    /// <summary>
+    /// Unused
+    /// </summary>
     public class Class : BaseEntity
     {
         public string Name { get; set; }
diff --git a/Backend/Core/Entities/ConfigurationItem.cs b/Backend/Core/Entities/ConfigurationItem.cs
index e0f822f..b79328d 100644
--- a/Backend/Core/Entities/ConfigurationItem.cs
+++ b/Backend/Core/Entities/ConfigurationItem.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
 
 namespace Core.Entities
 {
+    /// <summary>
+    /// Configuration for the key-value database storage
+    /// </summary>
     public class ConfigurationItem : BaseEntity
     {
         public string Value { get; set; }
diff --git a/Backend/Core/Entities/Document.cs b/Backend/Core/Entities/Document.cs
index c714765..a39156f 100644
--- a/Backend/Core/Entities/Document.cs
+++ b/Backend/Core/Entities/Document.cs
@@ -11,15 +11,34 @@ namespace Core.Entities
 #nullable disable
     public class Document : BaseEntity
     {
+        /// <summary>
+        /// Document name
+        /// </summary>
         public string Name { get; set; }
+
+        /// <summary>
+        /// Length in characters
+        /// </summary>
         public int Length { get; set; }
 
+        /// <summary>
+        /// Actual content
+        /// </summary>
         public DocumentContent Content { get; set; }
 
+        /// <summary>
+        /// Date added
+        /// </summary>
         public DateTime DateAdded { get; set; }
 
+        /// <summary>
+        /// User who added it
+        /// </summary>
         public User UserAdded { get; set; }
 
+        /// <summary>
+        /// Number of required annotations
+        /// </summary>
         public int RequiredAnnotations { get; set; }
     }
 }
diff --git a/Backend/Core/Entities/DocumentContent.cs b/Backend/Core/Entities/DocumentContent.cs
index f5cf8e3..4ffef32 100644
--- a/Backend/Core/Entities/DocumentContent.cs
+++ b/Backend/Core/Entities/DocumentContent.cs
@@ -10,6 +10,9 @@ namespace Core.Entities
 {
     public class DocumentContent : BaseEntity
     {
+        /// <summary>
+        /// String with the document content
+        /// </summary>
         public string Content { get; set; }
     }
 }
diff --git a/Backend/Core/Entities/FinalAnnotation.cs b/Backend/Core/Entities/FinalAnnotation.cs
index 6eba8a9..491f715 100644
--- a/Backend/Core/Entities/FinalAnnotation.cs
+++ b/Backend/Core/Entities/FinalAnnotation.cs
@@ -9,6 +9,9 @@ namespace Core.Entities
 {
     public class FinalAnnotation : Annotation
     {
+        /// <summary>
+        /// List of annotations that were used to create the final annotation
+        /// </summary>
         public List<Annotation> Annotations { get; set; } = new();
     }
 }
diff --git a/Backend/Core/Entities/FinalAnnotationTag.cs b/Backend/Core/Entities/FinalAnnotationTag.cs
index dc3b38e..3f22a4d 100644
--- a/Backend/Core/Entities/FinalAnnotationTag.cs
+++ b/Backend/Core/Entities/FinalAnnotationTag.cs
@@ -8,8 +8,19 @@ namespace Core.Entities
 {
     public class FinalAnnotationTag : AnnotationTagGeneric
     {
+        /// <summary>
+        /// FinalAnnotation the tag is linked to
+        /// </summary>
         public FinalAnnotation Annotation { get; set; }
+
+        /// <summary>
+        /// Whether the tag is marked as final or not
+        /// </summary>
         public bool IsFinal { get; set; } = false;
+        
+        /// <summary>
+        /// List of users who have agreed on this tag
+        /// </summary>
         public ICollection<User> Users { get; set; } = new List<User>();
     }
 }
diff --git a/Backend/Core/Entities/SubTag.cs b/Backend/Core/Entities/SubTag.cs
index 15f7df8..f61e066 100644
--- a/Backend/Core/Entities/SubTag.cs
+++ b/Backend/Core/Entities/SubTag.cs
@@ -12,6 +12,10 @@ namespace Core.Entities
         public string Name { get; set; }
         public string Description { get; set; }
         public Tag Tag { get; set; }
+
+        /// <summary>
+        /// Whether or not this tag supports sentiment
+        /// </summary>
         public bool SentimentEnabled { get; set; } = false;
     }
 }
diff --git a/Backend/Core/Entities/Tag.cs b/Backend/Core/Entities/Tag.cs
index a2c2ea5..46985b5 100644
--- a/Backend/Core/Entities/Tag.cs
+++ b/Backend/Core/Entities/Tag.cs
@@ -14,6 +14,10 @@ namespace Core.Entities
         public string Name { get; set; }
         public string Description { get; set; }
         public string Color { get; set; }
+
+        /// <summary>
+        /// Whether or not this tag supports sentiment
+        /// </summary>
         public bool SentimentEnabled { get; set; } = false;
     }
 }
diff --git a/Backend/Core/Entities/TagCategory.cs b/Backend/Core/Entities/TagCategory.cs
index 3ff9a33..eac95b1 100644
--- a/Backend/Core/Entities/TagCategory.cs
+++ b/Backend/Core/Entities/TagCategory.cs
@@ -13,6 +13,10 @@ namespace Core.Entities
         public string Name { get; set; }
         public string Color { get; set; }
         public string Description { get; set; }
+
+        /// <summary>
+        /// Whether or not this category is only visible to admins
+        /// </summary>
         public bool DisabledForAnnotators { get; set; } = false;
     }
 }
diff --git a/Backend/Core/Entities/User.cs b/Backend/Core/Entities/User.cs
index 30db07b..543a4fb 100644
--- a/Backend/Core/Entities/User.cs
+++ b/Backend/Core/Entities/User.cs
@@ -21,6 +21,9 @@ namespace Core.Entities
 
         public ERole Role { get; set; }
 
+        /// <summary>
+        /// Force EF to create a join table
+        /// </summary>
         public ICollection<FinalAnnotationTag> FinalAnnotationTags { get; set; } = new List<FinalAnnotationTag>();
     }
 }
\ No newline at end of file
diff --git a/Backend/Core/GraphUtils/Intersections.cs b/Backend/Core/GraphUtils/Intersections.cs
index 5fac740..c3eb708 100644
--- a/Backend/Core/GraphUtils/Intersections.cs
+++ b/Backend/Core/GraphUtils/Intersections.cs
@@ -4,6 +4,11 @@ namespace Core.GraphUtils
 {
     public class Intersections
     {
+        /// <summary>
+        /// Finds intersections between 1D segments
+        /// </summary>
+        /// <param name="tags"></param>
+        /// <returns></returns>
         public static Dictionary<AnnotationTagGeneric, List<AnnotationTagGeneric>> FindIntersections(List<AnnotationTagGeneric> tags)
         {
             var intersections = new Dictionary<AnnotationTagGeneric, List<AnnotationTagGeneric>>();
@@ -27,6 +32,11 @@ namespace Core.GraphUtils
             return intersections;
         }
 
+        /// <summary>
+        /// Graph coloring
+        /// </summary>
+        /// <param name="source"></param>
+        /// <returns></returns>
         public static Dictionary<AnnotationTagGeneric, int> ColorGraph(Dictionary<AnnotationTagGeneric, List<AnnotationTagGeneric>> source)
         {
             var res = ConvertToMatrix(source);
diff --git a/Backend/Core/MapperProfiles/DocumentProfileEF.cs b/Backend/Core/MapperProfiles/DocumentProfileEF.cs
index bf95650..bfdb4cf 100644
--- a/Backend/Core/MapperProfiles/DocumentProfileEF.cs
+++ b/Backend/Core/MapperProfiles/DocumentProfileEF.cs
@@ -14,11 +14,6 @@ namespace Core.MapperProfiles
         public DocumentProfileEF()
         {
             CreateMap<Document, DocumentListInfo>();
-                /*.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
-                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
-                .ForMember(dest => dest.Length, opt => opt.MapFrom(src => src.Length))
-                .ForMember(dest => dest.RequiredAnnotations, opt => opt.MapFrom(src => src.RequiredAnnotations));*/
-
         }
     }
 }
diff --git a/Backend/Core/MapperProfiles/RegisterMappings.cs b/Backend/Core/MapperProfiles/RegisterMappings.cs
index 931f33f..9384a14 100644
--- a/Backend/Core/MapperProfiles/RegisterMappings.cs
+++ b/Backend/Core/MapperProfiles/RegisterMappings.cs
@@ -11,9 +11,13 @@ namespace Core.MapperProfiles
 {
     public class RegisterMappings
     {
+        /// <summary>
+        /// Registers mappings for AutoMapper in DI
+        /// </summary>
+        /// <param name="builder"></param>
         public static void Register(WebApplicationBuilder builder)
         {
-            builder.Services.AddAutoMapper(typeof(UserProfileEF), typeof(DocumentProfileEF));
+            builder.Services.AddAutoMapper(typeof(UserProfileEF), typeof(DocumentProfileEF), typeof(TagProfileEF));
         }
     }
 }
diff --git a/Backend/Core/Services/AnnotationService/IAnnotationService.cs b/Backend/Core/Services/AnnotationService/IAnnotationService.cs
index c6b6e68..c1218b8 100644
--- a/Backend/Core/Services/AnnotationService/IAnnotationService.cs
+++ b/Backend/Core/Services/AnnotationService/IAnnotationService.cs
@@ -11,16 +11,92 @@ namespace Core.Services.AnnotationService
 {
     public interface IAnnotationService
     {
+        /// <summary>
+        /// Assign users to documents
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="userId"></param>
         public void CreateDocumentAnnotations(AnnotationsAddRequest request, Guid userId);
+        /// <summary>
+        /// Given user, return their annotations
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <returns></returns>
         public AnnotationListResponse GetUserAnnotations(Guid userId);
+        /// <summary>
+        /// Return given annotation
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="userId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="isFinal">is it final annotation or standard annotation</param>
+        /// <returns></returns>
         public AnnotationInfo GetAnnotation(Guid annotationId, Guid userId, ERole userRole, bool isFinal);
+        /// <summary>
+        /// Adds a tag to an annotation
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="userId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="request"></param>
+        /// <param name="isFinal">is it final annotation or standard annotation</param>
         public void AddAnnotationInstance(Guid annotationId, Guid userId, ERole userRole, AnnotationInstanceAddRequest request, bool isFinal);
+        /// <summary>
+        /// Remove a tag from annotation
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="tagInstanceId"></param>
+        /// <param name="loggedUserId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="isFinal">is it final annotation or standard annotation</param>
         public void DeleteAnnotationInstance(Guid annotationId, Guid tagInstanceId, Guid loggedUserId, ERole userRole, bool isFinal);
+        /// <summary>
+        /// Add note to annotation
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="userId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="request"></param>
+        /// <param name="isFinal">is it final annotation or standard annotation</param>
         public void AddNoteToAnnotation(Guid annotationId, Guid userId, ERole userRole, AddNoteToAnnotationRequest request, bool isFinal);
+        /// <summary>
+        /// Set sentiment of a tag
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="instanceId"></param>
+        /// <param name="userId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="sentiment"></param>
+        /// <param name="isFinal">is it final annotation or standard annotation</param>
         public void SetTagInstanceSentiment(Guid annotationId, Guid instanceId, Guid userId, ERole userRole, ETagSentiment sentiment, bool isFinal);
+        /// <summary>
+        /// Set the annotation state to DONE or IN_PROGRESS
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="userId"></param>
+        /// <param name="userRole"></param>
+        /// <param name="done">is it DONE or not</param>
+        /// <param name="isFinal"is it final annotation or standard annotation></param>
         public void MarkAnnotationAsDone(Guid annotationId, Guid userId, ERole userRole, bool done, bool isFinal);
+        /// <summary>
+        /// Creates a final annotation
+        /// </summary>
+        /// <param name="documentId"></param>
+        /// <param name="userId"></param>
+        /// <returns>ID of the final annotation</returns>
         public Guid CreateFinalAnnotation(Guid documentId, Guid userId);
+        /// <summary>
+        /// Performs an export
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns>ZIP memory stream</returns>
         public MemoryStream Export(ExportRequest request);
+        /// <summary>
+        /// Marks tag as final 
+        /// </summary>
+        /// <param name="annotationId"></param>
+        /// <param name="occurenceId"></param>
+        /// <param name="isFinal">is the tag final or not</param>
         public void SetTagIsFinal(Guid annotationId, Guid occurenceId, bool isFinal);
     }
 }
diff --git a/Backend/Core/Services/AuthService/IAuthService.cs b/Backend/Core/Services/AuthService/IAuthService.cs
index 1469ec9..95f977c 100644
--- a/Backend/Core/Services/AuthService/IAuthService.cs
+++ b/Backend/Core/Services/AuthService/IAuthService.cs
@@ -5,5 +5,11 @@ namespace Core.Services;
 
 public interface IAuthService
 {
+    /// <summary>
+    /// Check username and password
+    /// </summary>
+    /// <param name="username"></param>
+    /// <param name="password"></param>
+    /// <returns></returns>
     public LoginResponse? Login(string username, string password);
 }
\ No newline at end of file
diff --git a/Backend/Core/Services/DocumentService/DocumentServiceEF.cs b/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
index 3977832..ccde4e3 100644
--- a/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
+++ b/Backend/Core/Services/DocumentService/DocumentServiceEF.cs
@@ -63,7 +63,7 @@ namespace Core.Services.DocumentService
         }
 
         /// <summary>
-        /// 
+        /// Process a zip file and returns a list of names and documents
         /// </summary>
         /// <param name="base64encoded"></param>
         /// <returns></returns>
@@ -91,6 +91,13 @@ namespace Core.Services.DocumentService
             return (names, contents);
         }
 
+        /// <summary>
+        /// Save a document in the database
+        /// </summary>
+        /// <param name="content"></param>
+        /// <param name="userAdded"></param>
+        /// <param name="documentName"></param>
+        /// <param name="requiredAnnotations"></param>
         private void SaveDocument(string content, User userAdded, string documentName, int requiredAnnotations)
         {
             DocumentContent documentContent = new DocumentContent()
@@ -140,8 +147,10 @@ namespace Core.Services.DocumentService
                 }
 
                 DocumentListInfo dli = mapper.Map<DocumentListInfo>(document);
+                // Add list of users taht annotate the document
                 dli.AnnotatingUsers = annotatingUsersDto;
 
+                // Add info about the finalized version
                 dli.FinalizedExists = databaseContext.FinalAnnotations.Any(fa => fa.Document == document);
                 if (dli.FinalizedExists)
                 {
@@ -154,6 +163,7 @@ namespace Core.Services.DocumentService
                     dli.FinalizedState = finalizedAnnotation.State;
                     dli.FinalAnnotations = new();
 
+                    // Add information about which annotations were used to create the finalized version
                     foreach (var annotation in finalizedAnnotation.Annotations)
                     {
                         dli.FinalAnnotations.Add(new()
diff --git a/Backend/Core/Services/DocumentService/IDocumentService.cs b/Backend/Core/Services/DocumentService/IDocumentService.cs
index 329f293..10eb9ea 100644
--- a/Backend/Core/Services/DocumentService/IDocumentService.cs
+++ b/Backend/Core/Services/DocumentService/IDocumentService.cs
@@ -11,13 +11,48 @@ namespace Core.Services.DocumentService
 {
     public interface IDocumentService
     {
+        /// <summary>
+        /// Add list of documents to a list of users
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="userId"></param>
         public void AddDocuments(DocumentAddRequest request, Guid userId);
+        /// <summary>
+        /// Returns all documents
+        /// </summary>
+        /// <returns></returns>
         public DocumentListResponse GetDocuments();
+        /// <summary>
+        /// Returns a preview of a document (HTML)
+        /// </summary>
+        /// <param name="documentId"></param>
+        /// <returns></returns>
         public DocumentPreviewResponse GetDocumentPreview(Guid documentId);
+        /// <summary>
+        /// Delete a list of documents
+        /// </summary>
+        /// <param name="request"></param>
         public void DeleteDocuments(DeleteDocumentsRequest request);
+        /// <summary>
+        /// Set required number of annotations for a list of documents
+        /// </summary>
+        /// <param name="request"></param>
         public void SetRequiredAnnotationsForDocuments(SetRequiredAnnotationsRequest request);
+        /// <summary>
+        /// Set default required number of annotations
+        /// </summary>
+        /// <param name="requiredAnnotations"></param>
         public void SetRequiredAnnotationsGlobal(int requiredAnnotations);
+        /// <summary>
+        /// Get default required number of annotations
+        /// </summary>
+        /// <returns></returns>
         public int GetRequiredAnnotationsGlobal();
+        /// <summary>
+        /// Remove an annotator from a document
+        /// </summary>
+        /// <param name="documentId"></param>
+        /// <param name="annotatorId"></param>
         public void RemoveAnnotatorFromDocument(Guid documentId, Guid annotatorId);
     }
 }
diff --git a/Backend/Core/Services/HTMLService/HTMLService.cs b/Backend/Core/Services/HTMLService/HTMLService.cs
index 7c2eb4b..64c25e0 100644
--- a/Backend/Core/Services/HTMLService/HTMLService.cs
+++ b/Backend/Core/Services/HTMLService/HTMLService.cs
@@ -13,18 +13,49 @@ namespace Core.Services
 {
     public class HTMLService : IHTMLService
     {
-
+        /// <summary>
+        /// Attribute name for uniquely identifying each tag in the HTML document on the frontend
+        /// </summary>
         private const string TAG_ID_ATTRIBUTE_NAME = "aswi-tag-id";
+
+        /// <summary>
+        /// Attribute name for tag instance so that each marked out tag can be given a style
+        /// </summary>
         private const string TAG_INSTANCE_ATTRIBUTE_NAME = "aswi-tag-instance";
+
+        /// <summary>
+        /// Attribute name for EF Tag IDs so that the frontend can reference them to the backend for deletion
+        /// </summary>
         private const string TAG_EF_ID_ATTRIBUTE_NAME = "aswi-tag-ef-id";
 
+        /// <summary>
+        /// Info that is cached in tha database
+        /// </summary>
         public class CachedInfo
         {
+            /// <summary>
+            /// Positions of opening tags in the original HTML document
+            /// </summary>
             public List<int> TagStartPositions = new();
+            /// <summary>
+            /// Lengths of opening tags in the original HTML document
+            /// </summary>
             public List<int> TagStartLengths = new();
+            /// <summary>
+            /// Positions of closing tags in the original HTML document
+            /// </summary>
             public List<int> TagClosingPositions = new();
+            /// <summary>
+            /// Lengths for closing tags in the original HTML document
+            /// </summary>
             public List<int> TagClosingLengths = new();
+            /// <summary>
+            /// Unused
+            /// </summary>
             public Dictionary<HtmlNode, HtmlNode> NodeDict = new();
+            /// <summary>
+            /// Cached CSS for each tag
+            /// </summary>
             public List<TagInstanceCSSInfo> TagInstanceCSS = new();
         }
 
@@ -35,6 +66,10 @@ namespace Core.Services
         private Dictionary<HtmlNode, HtmlNode> NodeDict = new();
         private List<TagInstanceCSSInfo> TagInstanceCSS = new();
 
+        /// <summary>
+        /// Unpack cached info into local (request-scoped) variables
+        /// </summary>
+        /// <param name="cachedInfo"></param>
         private void UnpackCachedInfo(CachedInfo cachedInfo)
         {
             TagStartPositions = cachedInfo.TagStartPositions;
@@ -62,9 +97,13 @@ namespace Core.Services
 
             int currentId = 0;
 
+            // Create mapping original-document-node -> to-edit-document-node
             FillNodeDict(descendantsOriginal, descendantsToEdit);
+
+            // Assign IDs to all original rtags
             AssignIdsToOriginalDocument(descendantsOriginal, ref currentId);
 
+            // Wrap all text that is not in a tag or where the parent node contains tags as children also in spans
             WrapTextInSpan(descendantsOriginal, docToEdit);
 
             descendantsToEdit = docToEdit.DocumentNode.DescendantsAndSelf().ToList();
@@ -156,6 +195,17 @@ namespace Core.Services
             });
         }
 
+        /// <summary>
+        /// Wrap text in span when the target text is the whole text of the target tag
+        /// </summary>
+        /// <param name="node">text node to wrap</param>
+        /// <param name="selectionStart">start of the selection in the edited document</param>
+        /// <param name="selectionEnd">end of the selection in the edited document</param>
+        /// <param name="start">start of the node</param>
+        /// <param name="end">end of the node</param>
+        /// <param name="docToEdit">document to edit</param>
+        /// <param name="tag">tag we are adding</param>
+        /// <returns></returns>
         private HtmlNode SolveFullFill(HtmlNode node, int selectionStart, int selectionEnd, int start, int end, HtmlDocument docToEdit, AnnotationTagGeneric tag)
         {
             // full fill
@@ -185,6 +235,17 @@ namespace Core.Services
             return spanSelected;
         }
 
+        /// <summary>
+        /// Wrap text in span when the target text starts at the start of the tag and leaves space on the right side
+        /// </summary>
+        /// <param name="node">text node to wrap</param>
+        /// <param name="selectionStart">start of the selection in the edited document</param>
+        /// <param name="selectionEnd">end of the selection in the edited document</param>
+        /// <param name="start">start of the node</param>
+        /// <param name="end">end of the node</param>
+        /// <param name="docToEdit">document to edit</param>
+        /// <param name="tag">tag we are adding</param>
+        /// <returns></returns>
         private List<HtmlNode> SolveRightGap(HtmlNode node, int selectionStart, int selectionEnd, int start, int end, HtmlDocument docToEdit,
                                              AnnotationTagGeneric tag)
         {
@@ -215,6 +276,17 @@ namespace Core.Services
             return new() { spanSelected, spanAfter };
         }
 
+        /// <summary>
+        /// Wrap text in span when the target text ends at the end of the tag but leaves space on the left
+        /// </summary>
+        /// <param name="node">text node to wrap</param>
+        /// <param name="selectionStart">start of the selection in the edited document</param>
+        /// <param name="selectionEnd">end of the selection in the edited document</param>
+        /// <param name="start">start of the node</param>
+        /// <param name="end">end of the node</param>
+        /// <param name="docToEdit">document to edit</param>
+        /// <param name="tag">tag we are adding</param>
+        /// <returns></returns>
         private List<HtmlNode> SolveLeftGap(HtmlNode node, int selectionStart, int selectionEnd, int start, int end, HtmlDocument docToEdit,
                                              AnnotationTagGeneric tag)
         {
@@ -245,6 +317,17 @@ namespace Core.Services
             return new() { spanSelected, spanBefore };
         }
 
+        /// <summary>
+        /// Wrap text in span when the target text is contained in the node but neither starts or ends match
+        /// </summary>
+        /// <param name="node">text node to wrap</param>
+        /// <param name="selectionStart">start of the selection in the edited document</param>
+        /// <param name="selectionEnd">end of the selection in the edited document</param>
+        /// <param name="start">start of the node</param>
+        /// <param name="end">end of the node</param>
+        /// <param name="docToEdit">document to edit</param>
+        /// <param name="tag">tag we are adding</param>
+        /// <returns></returns>
         private List<HtmlNode> SolveLeftRightGap(HtmlNode node, int selectionStart, int selectionEnd, int start, int end, HtmlDocument docToEdit,
                                                  AnnotationTagGeneric tag)
         {
@@ -274,6 +357,17 @@ namespace Core.Services
             return new() { spanSelected, spanBefore, spanAfter };
         }
 
+        /// <summary>
+        /// Create span utility method
+        /// </summary>
+        /// <param name="doc">document</param>
+        /// <param name="text">inner text of the span</param>
+        /// <param name="tagId">ID of the tag (TAG_ID_ATTRIBUTE_NAME)</param>
+        /// <param name="instanceId">ID of the instance (TAG_INSTANCE_ATTRIBUTE_NAME)</param>
+        /// <param name="entityId">Id of the EF entity (TAG_EF_ID_NAME)</param>
+        /// <param name="startPosition"></param>
+        /// <param name="position"></param>
+        /// <returns></returns>
         private HtmlNode CreateSpan(HtmlDocument doc, string text, int tagId, Guid? instanceId, Guid? entityId, int startPosition, EPosition position = EPosition.MARK_NONE)
         {
             HtmlNode span = doc.CreateElement("span");
@@ -312,6 +406,10 @@ namespace Core.Services
             MARK_NONE = 0
         }
 
+        /// <summary>
+        /// Redirect all links
+        /// </summary>
+        /// <param name="descendantsOriginal"></param>
         private void ModifyLinks(IEnumerable<HtmlNode> descendantsOriginal)
         {
             foreach (var descendant in descendantsOriginal)
@@ -327,6 +425,11 @@ namespace Core.Services
             }
         }
 
+        /// <summary>
+        /// Wrap all #text nodes in spans
+        /// </summary>
+        /// <param name="descendantsOriginal"></param>
+        /// <param name="docToEdit"></param>
         private void WrapTextInSpan(IEnumerable<HtmlNode> descendantsOriginal, HtmlDocument docToEdit)
         {
             // Special case for non-html documents
@@ -389,9 +492,11 @@ namespace Core.Services
                         foreach (var child in node.ChildNodes)
                         {
                             if (child.Name.Contains("#text"))
-                            {
+                            { 
                                 HtmlNode coveringSpan = docToEdit.CreateElement("span");
                                 coveringSpan.InnerHtml = child.InnerHtml;
+                                
+                                // Add length of 0 - in they were not in the original document
                                 TagStartPositions.Add(child.InnerStartIndex);
                                 TagStartLengths.Add(0);
                                 TagClosingPositions.Add(child.InnerStartIndex + child.InnerLength);
@@ -410,6 +515,10 @@ namespace Core.Services
             }
         }
 
+        /// <summary>
+        /// Generate CSS for all tag instances
+        /// </summary>
+        /// <param name="tags"></param>
         private void GenerateCSS(List<AnnotationTagGeneric> tags)
         {
             /*string inner = "span.annotation {border-bottom: 2px solid;}";
@@ -428,6 +537,11 @@ namespace Core.Services
             }
         }
 
+        /// <summary>
+        /// Add IDs to all tags in the original document
+        /// </summary>
+        /// <param name="descendantsOriginal"></param>
+        /// <param name="currentId"></param>
         private void AssignIdsToOriginalDocument(IEnumerable<HtmlNode> descendantsOriginal, ref int currentId)
         {
             foreach (var node in descendantsOriginal)
@@ -446,6 +560,7 @@ namespace Core.Services
                     currentId = TagStartPositions.Count - 1;
                     toEditNode.Attributes.Add(TAG_ID_ATTRIBUTE_NAME, currentId.ToString());
 
+                    // Cross-referencing of the original document to the edited document
                     TagClosingPositions.Add(originalNode.InnerStartIndex + originalNode.InnerLength);
                     TagClosingLengths.Add((originalNode.OuterStartIndex + originalNode.OuterLength) - (originalNode.InnerStartIndex + originalNode.InnerLength));
                 }
@@ -476,6 +591,15 @@ namespace Core.Services
          *      Partial HTML Preprocessing ----------------------------------------------------------------------------
          */
 
+        /// <summary>
+        /// Incrementally modifies the html to render and cached info by adding a new tag
+        /// </summary>
+        /// <param name="htmlToEdit"></param>
+        /// <param name="htmlOriginal"></param>
+        /// <param name="tagToAdd"></param>
+        /// <param name="tags"></param>
+        /// <param name="cachedInfo"></param>
+        /// <returns></returns>
         public (string, CachedInfo) PartialPreprocessHTMLAddTag(string htmlToEdit, string htmlOriginal, AnnotationTagGeneric tagToAdd, List<AnnotationTagGeneric> tags, CachedInfo cachedInfo)
         {
             UnpackCachedInfo(cachedInfo);
@@ -547,7 +671,15 @@ namespace Core.Services
             });
         }
 
-
+        /// <summary>
+        /// Removing tag effectively just cleans up the attributes and CSS thus has no effect
+        /// </summary>
+        /// <param name="htmlToEdit"></param>
+        /// <param name="htmlOriginal"></param>
+        /// <param name="tagToRemove"></param>
+        /// <param name="tags"></param>
+        /// <param name="cachedInfo"></param>
+        /// <returns></returns>
         public (string, CachedInfo) PartialPreprocessHTMLRemoveTag(string htmlToEdit, string htmlOriginal, AnnotationTagGeneric tagToRemove, List<AnnotationTagGeneric> tags, CachedInfo cachedInfo)
         {
             UnpackCachedInfo(cachedInfo);
diff --git a/Backend/Core/Services/HTMLService/IHTMLService.cs b/Backend/Core/Services/HTMLService/IHTMLService.cs
index 4c08c16..b77ac92 100644
--- a/Backend/Core/Services/HTMLService/IHTMLService.cs
+++ b/Backend/Core/Services/HTMLService/IHTMLService.cs
@@ -10,8 +10,32 @@ namespace Core.Services
 {
     public interface IHTMLService
     {
+        /// <summary>
+        /// Make a full preprocessing of an HTML document and incorporate any existing tags into it
+        /// </summary>
+        /// <param name="htmlSource"></param>
+        /// <param name="tags"></param>
+        /// <returns>tuple of (HTML document to render, info to cache in the database)</returns>
         public (string, CachedInfo) FullPreprocessHTML(string htmlSource, List<AnnotationTagGeneric> tags);
+        /// <summary>
+        /// Make a partial preprocessing of an HTML document by adding a new tag into it
+        /// </summary>
+        /// <param name="htmlToEdit">already preprocessed HTML document</param>
+        /// <param name="htmlOriginal">original HTML document</param>
+        /// <param name="tagToAdd">the tag to add</param>
+        /// <param name="tags">list of all tags related to the annotation</param>
+        /// <param name="cachedInfo">database-cached info</param>
+        /// <returns></returns>
         public (string, CachedInfo) PartialPreprocessHTMLAddTag(string htmlToEdit, string htmlOriginal, AnnotationTagGeneric tagToAdd, List<AnnotationTagGeneric> tags, CachedInfo cachedInfo);
+        /// <summary>
+        /// Make a partial preprocessing of an HTML document by remove an existing tag from it
+        /// </summary>
+        /// <param name="htmlToEdit">already preprocessed HTML document</param>
+        /// <param name="htmlOriginal">original HTML document</param>
+        /// <param name="tagToRemove">the tag to remove</param>
+        /// <param name="tags">list of all tags related to the annotation</param>
+        /// <param name="cachedInfo">database-cached info</param>
+        /// <returns></returns>
         public (string, CachedInfo) PartialPreprocessHTMLRemoveTag(string htmlToEdit, string htmlOriginal, AnnotationTagGeneric tagToRemove, List<AnnotationTagGeneric> tags, CachedInfo cachedInfo);
     }
 }
diff --git a/Backend/Core/Services/Registration.cs b/Backend/Core/Services/Registration.cs
index 39e3f5a..c725e77 100644
--- a/Backend/Core/Services/Registration.cs
+++ b/Backend/Core/Services/Registration.cs
@@ -7,8 +7,15 @@ using Microsoft.Extensions.DependencyInjection;
 
 namespace Core.Services
 {
+    /// <summary>
+    /// Add new services here
+    /// </summary>
     public class Registration
     {
+        /// <summary>
+        /// Registers services
+        /// </summary>
+        /// <param name="builder"></param>
         public static void RegisterServices(WebApplicationBuilder builder)
         {
             builder.Services.AddScoped<IUserService, UserServiceEF>();
diff --git a/Backend/Core/Services/TagService/ITagService.cs b/Backend/Core/Services/TagService/ITagService.cs
index 7b3b19a..a4ebaca 100644
--- a/Backend/Core/Services/TagService/ITagService.cs
+++ b/Backend/Core/Services/TagService/ITagService.cs
@@ -12,16 +12,68 @@ namespace Core.Services.TagService
 {
     public interface ITagService
     {
+        /// <summary>
+        /// Returns a tree-like structure with tag categories, tags, and subtags
+        /// </summary>
+        /// <param name="userRole">Role is used to discriminate categories available to admins only</param>
+        /// <returns></returns>
         public TagTreeResponse GetTagTree(ERole userRole);
+        /// <summary>
+        /// Creates a new category
+        /// </summary>
+        /// <param name="request"></param>
         public void CreateCategory(CreateCategoryRequest request);
+        /// <summary>
+        /// Deleted a category by Id
+        /// </summary>
+        /// <param name="categoryId"></param>
         public void DeleteCategory(Guid categoryId);
+        /// <summary>
+        /// Updates a category by Id
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="categoryId"></param>
         public void UpdateCategory(ModifyCategoryRequest request, Guid categoryId);
+        /// <summary>
+        /// Creates a new tag
+        /// </summary>
+        /// <param name="request"></param>
         public void CreateTag(CreateTagRequest request);
+        /// <summary>
+        /// Delete tag by Id
+        /// </summary>
+        /// <param name="tagId"></param>
         public void DeleteTag(Guid tagId);
+        /// <summary>
+        /// Update tag by Id
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="tagId"></param>
         public void UpdateTag(ModifyTagRequest request, Guid tagId);
+        /// <summary>
+        /// Create a subtag
+        /// </summary>
+        /// <param name="request"></param>
         public void CreateSubTag(CreateSubTagRequest request);
+        /// <summary>
+        /// Delete subtag by Id
+        /// </summary>
+        /// <param name="subtagId"></param>
         public void DeleteSubTag(Guid subtagId);
+        /// <summary>
+        /// Update subtag by Id
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="subtagId"></param>
         public void UpdateSubTag(ModifySubTagRequest request, Guid subtagId);
+        /// <summary>
+        /// Adds a note to tag's instance
+        /// </summary>
+        /// <param name="annotationId">Annotation</param>
+        /// <param name="occurrenceId">Id of the Tag</param>
+        /// <param name="user">User that's doing the adding</param>
+        /// <param name="request"></param>
+        /// <param name="isFinal">Whether the annotationId is for a FinalAnnotation or Annotation</param>
         public void AddNoteToTagInstance(Guid annotationId, Guid occurrenceId, User user, AddNoteToTagOccurenceRequest request, bool isFinal);
     }
 }
diff --git a/Backend/Core/Services/TagService/TagServiceEF.cs b/Backend/Core/Services/TagService/TagServiceEF.cs
index e036d7b..451a079 100644
--- a/Backend/Core/Services/TagService/TagServiceEF.cs
+++ b/Backend/Core/Services/TagService/TagServiceEF.cs
@@ -274,6 +274,7 @@ namespace Core.Services.TagService
 
         public void AddNoteToTagInstance(Guid annotationId, Guid occurrenceId, User user, AddNoteToTagOccurenceRequest request, bool isFinal)
         {
+            // We need to differentiate whether or not the annotation is final
             Annotation annotation = null;
             try
             {
diff --git a/Backend/Core/Services/UserService/IUserService.cs b/Backend/Core/Services/UserService/IUserService.cs
index 9db2805..3edad02 100644
--- a/Backend/Core/Services/UserService/IUserService.cs
+++ b/Backend/Core/Services/UserService/IUserService.cs
@@ -11,15 +11,80 @@ namespace Core.Services
 {
     public interface IUserService
     {
+        /// <summary>
+        /// Creates a new user
+        /// </summary>
+        /// <param name="username"></param>
+        /// <param name="name"></param>
+        /// <param name="surname"></param>
+        /// <param name="password"></param>
+        /// <param name="role"></param>
+        /// <returns></returns>
         public User? CreateUser(string username, string name, string surname, string password, ERole role);
+        /// <summary>
+        /// Returns a user with the specified username or null if no such user exists
+        /// </summary>
+        /// <param name="username"></param>
+        /// <returns></returns>
         public User? GetUserByUsername(string username);
+        /// <summary>
+        /// Returns a user with the specified Id or null if no such user exists
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
         public User? GetUserById(Guid id);
+        /// <summary>
+        /// Updates information about the user
+        /// Pass null as a parameter if you dont want to update it
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="username"></param>
+        /// <param name="name"></param>
+        /// <param name="surname"></param>
+        /// <param name="role"></param>
+        /// <returns></returns>
         public User UpdateUser(User user, string? username = null, string? name = null, string? surname = null, ERole? role = null);
+        /// <summary>
+        /// Updates information about the user
+        /// Pass null as a parameter if you dont want to update it
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="username"></param>
+        /// <param name="name"></param>
+        /// <param name="surname"></param>
+        /// <param name="role"></param>
+        /// <returns></returns>
         public User? UpdateUser(Guid userId, string? username = null, string? name = null, string? surname = null, ERole? role = null);
+        /// <summary>
+        /// Sets a new password
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="newPassword"></param>
+        /// <returns></returns>
         public User ChangePassword(User user, string newPassword);
+        /// <summary>
+        /// Sets a new password
+        /// </summary>
+        /// <param name="user"></param>
+        /// <param name="newPassword"></param>
+        /// <returns></returns>
         public User? ChangePassword(Guid userId, string newPassword);
+        /// <summary>
+        /// Check if the user with this username has this password
+        /// </summary>
+        /// <param name="username"></param>
+        /// <param name="password"></param>
+        /// <returns></returns>
         public User? CheckUsernamePassword(string username, string password);
+        /// <summary>
+        /// Returns list of all users
+        /// </summary>
+        /// <returns></returns>
         public UserList GetUsers();
+        /// <summary>
+        /// Deletes a user
+        /// </summary>
+        /// <param name="userId"></param>
         public void DeleteUser(Guid userId);
     }
 }
diff --git a/Backend/Core/Services/UserService/UserServiceEF.cs b/Backend/Core/Services/UserService/UserServiceEF.cs
index 8e4f20f..b3bee9f 100644
--- a/Backend/Core/Services/UserService/UserServiceEF.cs
+++ b/Backend/Core/Services/UserService/UserServiceEF.cs
@@ -16,6 +16,8 @@ namespace Core.Services
 {
     public class UserServiceEF : IUserService
     {
+        // DI
+
         private readonly DatabaseContext _databaseContext;
         private readonly ILogger _logger;
         private readonly IMapper _mapper;
diff --git a/Backend/Core/ZipUtils/Export.cs b/Backend/Core/ZipUtils/Export.cs
index 6b9bc2b..bf8fc6a 100644
--- a/Backend/Core/ZipUtils/Export.cs
+++ b/Backend/Core/ZipUtils/Export.cs
@@ -10,12 +10,25 @@ using System.Threading.Tasks;
 
 namespace Core.ZipUtils
 {
+    /// <summary>
+    /// Static methods for database exporting
+    /// </summary>
     public class Export
     {
+        /// <summary>
+        /// Exports the specified annotations
+        /// </summary>
+        /// <param name="documents">list of documents to export</param>
+        /// <param name="documentAnnotations">document-annotations to export mapping</param>
+        /// <param name="documentFinalAnnotations">document-final annotations to export mapping</param>
+        /// <param name="annotationTags">annotation-annotation tags mapping</param>
+        /// <param name="finalAnnotationTags">final annotation-final annotation tags mapping</param>
+        /// <returns></returns>
         public static MemoryStream FullExport(List<Document> documents, Dictionary<Document, List<Annotation>> documentAnnotations, Dictionary<Document, FinalAnnotation> documentFinalAnnotations,
             Dictionary<Annotation, List<AnnotationTag>> annotationTags, Dictionary<FinalAnnotation, List<FinalAnnotationTag>> finalAnnotationTags)
         {
             MemoryStream ms = new MemoryStream();
+            // Set keepOpen to true so that Dispose() does not close the MemoryStream
             var archive = new ZipArchive(ms, ZipArchiveMode.Create, true);
 
             for (int docIndex = 0; docIndex < documents.Count; docIndex++)
@@ -37,6 +50,7 @@ namespace Core.ZipUtils
                     CreateFile(documentDir + $"/annotation_{annotationIndex:00000}.json", annotationInfoJson, archive);
                 }
 
+                // Deal with final annotation if it exists
                 var finalAnnotation = documentFinalAnnotations[document];
                 if (finalAnnotation == null)
                 {
@@ -48,11 +62,18 @@ namespace Core.ZipUtils
                 CreateFile(documentDir + "/final.json", finalAnnotationInfoJson, archive);
             }
 
+            // Dispose of archive to close the header
             archive.Dispose();
             ms.Position = 0;
             return ms;
         }
 
+        /// <summary>
+        /// Creates a file and writes to it
+        /// </summary>
+        /// <param name="path">path to file</param>
+        /// <param name="fileContent">string to write</param>
+        /// <param name="archive">archive to write it to</param>
         private static void CreateFile(string path, string fileContent, ZipArchive archive)
         {
             var entry = archive.CreateEntry(path);
@@ -61,6 +82,11 @@ namespace Core.ZipUtils
             entryStream.Close();
         }
 
+        /// <summary>
+        /// Dumps a Document into JSON-serialized ExportDocumentInfo
+        /// </summary>
+        /// <param name="document">Document to serialize</param>
+        /// <returns>JSON-serialized ExportDocumentInfo</returns>
         private static string DumpDocument(Document document)
         {
             ExportDocumentInfo documentInfo = new();
@@ -71,6 +97,13 @@ namespace Core.ZipUtils
             return JsonConvert.SerializeObject(documentInfo);
         }
 
+        /// <summary>
+        /// Dumps annotation into JSON-serialized ExportAnnotationInfo
+        /// </summary>
+        /// <param name="annotation">Annotation to dump</param>
+        /// <param name="tags">Tags related to the annotation</param>
+        /// <param name="documentId">Id of the document the annotation is related to</param>
+        /// <returns>JSON-serialized ExportAnnotationInfo</returns>
         private static string DumpAnnotation(Annotation annotation, List<AnnotationTagGeneric> tags, Guid documentId)
         {
             ExportAnnotationInfo annotationInfo = new();
@@ -108,26 +141,65 @@ namespace Core.ZipUtils
 
     public class ExportDocumentInfo
     {
+        /// <summary>
+        /// Document name
+        /// </summary>
         public string Name { get; set; }
+        /// <summary>
+        /// Original document content
+        /// </summary>
         public string Content { get; set; }
+        /// <summary>
+        /// Id of the document
+        /// </summary>
         public Guid DocumentId { get; set; }
     }
 
     public class ExportAnnotationInfo
     {
+        /// <summary>
+        /// Annotator Id
+        /// </summary>
         public Guid AnnotatorId { get; set; }
+        /// <summary>
+        /// Document Id
+        /// </summary>
         public Guid DocumentId { get; set; }
+        /// <summary>
+        /// Tags 
+        /// </summary>
         public List<ExportTagInstanceInfo> Tags { get; set; } = new();
     }
 
     public class ExportTagInstanceInfo
     {
+        /// <summary>
+        /// Tag category
+        /// </summary>
         public string Category { get; set; }
+        /// <summary>
+        /// Name of the tag (the primary identifier)
+        /// </summary>
         public string TagName { get; set; }
+        /// <summary>
+        /// Name of the subtag (the primary identifier of a subtag)
+        /// </summary>
         public string? SubTagName { get; set; }
+        /// <summary>
+        /// Id of the instance (in case of multipart tags multiple tags share the same Id)
+        /// </summary>
         public Guid InstanceId { get; set; }
+        /// <summary>
+        /// Position in the original document
+        /// </summary>
         public int FirstCharPosition { get; set; }
+        /// <summary>
+        /// Length of the section in chars
+        /// </summary>
         public int Length { get; set; }
+        /// <summary>
+        /// Optional sentiment
+        /// </summary>
         public string? Sentiment { get; set; }
     }
 }
