How giriiri-g/toxicitydetection works
1. Overall shape
- This repo is a two-tier community moderation platform: an ASP.NET Core backend API plus an Angular frontend.
- The core product concern is toxicity detection and moderation, not just generic posting.
2. Runtime boundary: backend
- The backend lives in API/ and is the main application service.
- It exposes domain-specific controllers for auth, posts, reviewers, and admins.
- The API is the boundary between the browser UI and persisted moderation/content data.
3. Runtime boundary: frontend
- The active UI is in Frontend/, built with Angular/TypeScript.
- It contains routed pages for landing, sign-in/sign-up, feed, reviewer workflows, and admin dashboards.
- Angular services mirror backend capabilities: auth.service.ts, post.service.ts, and reviewer.service.ts.
4. Legacy / non-runtime UI code
- Old Frontend components/ appears to be an older Angular implementation kept in the repo for reference or migration.
- It is useful for understanding the product history, but the current architecture is centered on Frontend/.
5. Backend layering
- The API follows a classic layered structure:
- Controllers handle HTTP endpoints.
- Services implement business rules.
- Repositories wrap persistence access.
- Entities define the EF Core domain model.
- DTOs define request/response contracts.
- This separation is important for diagramming the control flow from UI → API → service → data store.
6. Domain model / data boundaries
- The main entities are User, Post, Likes, Ban, BanHistory, TagScore, ToxicityConfig, and Auth.
- These show the system tracks:
- user identities and authentication,
- submitted content,
- moderation outcomes,
- ban actions and history,
- toxicity scoring/configuration,
- user interactions such as likes.
- TagScore and ToxicityConfig are especially important because they connect content analysis to moderation decisions.
7. Toxicity detection and moderation flow
- ToxicityService is the key business component for content scoring/classification.
- ReviewerService and AdminService indicate a moderation pipeline with human oversight:
- content is ingested,
- scored for toxicity,
- reviewed/acted on by moderators,
- escalated to admin controls when needed.
- PostService likely coordinates post creation and the scoring/moderation lifecycle.
8. Role-based workflows
- The frontend has dedicated pages for admin, reviewer, and regular user experiences.
- Guard files (auth.guard.ts, role.guard.ts) show the UI enforces access by authentication and role.
- On the backend, the controller split implies separate operational boundaries for user-facing actions versus moderation/admin actions.
9. Persistence and schema evolution
- Data is persisted through Entity Framework Core using AppDbContext.
- API/Migrations/ shows the schema evolved over time: initial auth, posts/tag scores, toxicity config, threaded posts, bans, and likes.
- API/HRBC.db suggests the current repo includes a local SQLite database file for development or demo use, even though the README mentions MSSQL/MySQL as supported targets.
10. API contract layer
- DTOs such as CreatePostDto, LoginDto, RegisterDto, PostResponseDto, ReviewerDtos, AdminDtos, and UserStatsDto define the data exchanged with the UI.
- This keeps the frontend decoupled from the EF entities and prevents direct coupling to the persistence model.
11. Frontend structure
- The Angular app is organized by feature pages rather than a single monolith:
- feed for content browsing/detail,
- reviewer for moderation tasks,
- admin with subpages for toxicity control, user control, user stats, and thread ranking,
- signin, signup, and forgot-password for account access,
- landing and home for public entry points.
- assets/data/feed.json suggests there is also some local/demo content used by the UI.
12. Supporting artifacts
- DesignDoc/ contains design and sample website materials that document intended behavior and UI.
- CLAUDE.md, .slnx, and the various README/guideline files are supporting documentation, not runtime components.
- For an architecture diagram, the main live path is: Angular UI → ASP.NET Core API → EF Core/DB, with toxicity/moderation services as the central business core.
Main entry points: app Angular app · Controllers Controllers · AppDbContext.cs DbContext · Services Business services
Components 24
Frontend
Active Angular UI
- Angular app · Routes, guards, and feature composition for the active browser app
Frontend/src/app - Auth pages · Sign-in, sign-up, and password recovery flows
Frontend/src/app/signin - Feed pages · Landing feed and post detail experience
Frontend/src/app/pages/feed - Reviewer page · Reviewer workflow for human moderation tasks
Frontend/src/app/pages/reviewer - Admin pages · Admin dashboards for toxicity, users, stats, and ranking
Frontend/src/app/pages/admin - API services · Auth, post, and reviewer service wrappers for backend calls
Frontend/src/app/services - Route guards · Authentication and role-based route protection
Frontend/src/app/guards
API
ASP.NET Core backend
- Controllers · HTTP entry points for auth, posts, reviewer, and admin operations
API/Controllers - Auth controller · Login, registration, and account access endpoints
API/Controllers/AuthController.cs - Post controller · Post creation and content retrieval endpoints
API/Controllers/PostController.cs - Reviewer controller · Reviewer workflow endpoints for moderation actions
API/Controllers/ReviewerController.cs - Admin controller · Admin endpoints for toxicity control and user management
API/Controllers/AdminController.cs - Business services · Core moderation and account business logic
API/Services - Auth service · Authentication and registration rules
API/Services/AuthService.cs - Post service · Post lifecycle and moderation coordination
API/Services/PostService.cs - Reviewer service · Reviewer workflow and decisions
API/Services/ReviewerService.cs - Admin service · Administrative controls and oversight functions
API/Services/AdminService.cs - Toxicity service · Content scoring and toxicity classification
API/Services/ToxicityService.cs - Repositories · Persistence abstractions for posts and users
API/Data/Repositories
Legacy UI
Older frontend implementation
- Old frontend · Previous UI implementation kept for reference and migration
Old Frontend components
Data
Persistence and domain model
- DbContext · Entity Framework Core unit of work and model mapping
API/Data/AppDbContext.cs - Domain model · User, Post, Ban, Likes, TagScore, ToxicityConfig, and Auth entities
API/Entities - SQLite DB · Local development database file
API/HRBC.db
Docs
Design and supporting material
- Design docs · Requirements, architecture notes, and sample UI artifacts
DesignDoc
Connections 22
- Angular app → Auth pages: routes · Maps browser routes to account pages
- Angular app → Feed pages: routes · Maps browser routes to feed pages
- Angular app → Reviewer page: routes · Maps browser routes to reviewer workflows
- Angular app → Admin pages: routes · Maps browser routes to admin dashboards
- Angular app → API services: uses · Feature components call client services
- Angular app → Route guards: protects · Guards restrict authenticated and role-based routes
- API services → Controllers: HTTP API · Client services invoke backend endpoints
- Controllers → Auth controller: includes · Authentication endpoints
- Controllers → Post controller: includes · Post endpoints
- Controllers → Reviewer controller: includes · Reviewer endpoints
- Controllers → Admin controller: includes · Admin endpoints
- Auth controller → Auth service: calls · Delegates account logic to services
- Post controller → Post service: calls · Delegates post operations to services
- Reviewer controller → Reviewer service: calls · Delegates reviewer actions to services
- Admin controller → Admin service: calls · Delegates admin actions to services
- Business services → Toxicity service: uses · Moderation services depend on toxicity scoring
- Business services → Repositories: reads/writes · Business services persist through repositories
- Repositories → DbContext: uses · Repositories execute through EF Core context
- DbContext → Domain model: maps · DbContext maps the entity model
- DbContext → SQLite DB: persists · EF Core stores data in the local database
- Old frontend → Design docs: references · Legacy UI and design artifacts document the earlier product shape
- Design docs → Angular app: informs · Design materials mirror the current UI structure