How rami-shalhoub/thesis-backend works
Project Type and Purpose
• This is a backend-only ASP.NET Core 8 application serving as the API layer for a thesis application.
• It exposes user authentication and AI‐driven chat endpoints, persists data in PostgreSQL (with pgvector extension), and integrates with external AI services (Deepseek, OpenAI).
• Future components (not yet implemented) include IPFS and a Hyperledger Fabric gateway for blockchain storage.
High-Level Layered Architecture
• Presentation/API Layer
• Controllers (AuthController, ChatController)
• HTTP endpoints defined in Backend.http for testing
• Business Logic Layer
• Services (AuthService, JwtService, ChatService, DeepseekService, SourceService)
• IAuthService, IJwtService, IChatService, IDeepseekService, ISourceService interfaces
• Automapper profiles for mapping between Models and DTOs (ChatProfile, UserProfile)
• Data Access Layer
• Repositories (AuthRepository, SessionRepository, MessageRepository, ContextSummaryRepository)
• EF Core DbContext (ThesisDappDBContext) and Migrations
• Domain models (User, Session, Message, ContextSummary, Document, RevokedToken, AccessLog)
• External Services
• Deepseek API (DeepseekService)
• OpenAI embeddings (via DeepseekService’s OpenAIApiKey)
• Future: IPFS node, Hyperledger Fabric gateway
• Database
• PostgreSQL instance with pgvector extension
• Tables generated via EF Core migrations
Interactions and Data Flow
• Client → AuthController: register/login → AuthService → JwtService → returns JWT tokens
• Client (with JWT) → ChatController: create session, send messages → ChatService
• ChatService calls DeepseekService (calls Deepseek API → possibly OpenAI)
• ChatService records inputs/responses via SessionRepository, MessageRepository, ContextSummaryRepository
• All repositories interact with ThesisDappDBContext to CRUD PostgreSQL
Architectural Patterns and Principles
• Layered Architecture (Presentation, Service, Repository, Database)
• Dependency Injection of interfaces for loose coupling and testability
• Repository Pattern for data persistence abstraction
• DTOs for transport models, AutoMapper for mapping
• Configuration via appsettings.json (ConnectionStrings, JWT settings, Deepseek settings)