Project: Book Tracking System
Stack:
-
Database: PostgreSQL
-
Backend: ASP.NET Core (C#) with Entity Framework Core
-
Frontend: Angular (TypeScript)
The system follows a 3-tier containerized architecture:
The application is deployed using Docker Compose with three separate containers:
-
Frontend Container (Nginx + Angular)
- Multi-stage Docker build
- Stage 1: Node.js for building Angular app
- Stage 2: Nginx alpine for serving static files
- Port: 80
-
Backend Container (ASP.NET Core)
- Multi-stage Docker build
- Stage 1: .NET SDK for building the application
- Stage 2: .NET Runtime for running the application
- Auto-applies database migrations on startup with retry logic
- Port: 5000 (mapped from internal 8080)
-
Database Container (PostgreSQL)
- Official PostgreSQL 15 alpine image
- Persistent volume for data storage
- Port: 5432
-
Presentation Layer (Frontend – Angular)
-
Components: Book management, session logging, reading progress, notes, heatmap calendar.
-
Services: HTTP services for API calls.
-
Responsibilities: Display data, handle user interactions, input validation, and send requests to backend APIs.
-
-
Business Logic Layer (Backend – ASP.NET Core)
-
Controllers: Expose REST APIs for books, authors, tags, reading sessions, targets, progress, notes, and heatmap.
-
Services: Handle business logic, calculation of reading progress, validation rules, target assignments.
-
Repository: Interfaces for database access using EF Core.
-
-
Data Layer (PostgreSQL)
-
Tables: authors, books, book_tags, book_tag_assignments, reading_sessions, target_levels, reading_targets, reading_progress, notes, settings.
-
Relationships: Fully normalized with proper constraints and indexes.
-
Indexes:
(book_id, date)on reading_sessions for fast retrieval and heatmap aggregation.
-
-
Authors: Manage author info. Linked to books.
-
Books: Stores book details, linked to authors and tags.
-
Book Tags: Many-to-many relationship with books via
book_tag_assignments. -
Reading Sessions: Daily logs per book; unique per book per day.
-
Target Levels: Standard target types (low, medium, high).
-
Reading Targets: Book-specific targets, linked to target levels.
-
Reading Progress: Tracks percentage completion, start and finish dates, per target.
-
Notes: Can link to books or reading sessions.
-
Settings: Global stats (total pages read, average pages/day).
Indexes & Constraints:
-
Unique session per book per day.
-
Unique target per book per level.
-
Notes must link to at least a book or session.
-
GET /api/books– List all books -
GET /api/books/{id}– Get book details -
POST /api/books– Add new book -
PUT /api/books/{id}– Update book -
DELETE /api/books/{id}– Delete book
-
GET /api/authors– List authors -
POST /api/authors– Add author -
PUT /api/authors/{id}– Update author -
DELETE /api/authors/{id}– Delete author
-
GET /api/tags– List tags -
POST /api/tags– Add tag -
PUT /api/tags/{id}– Update tag -
DELETE /api/tags/{id}– Delete tag -
POST /api/books/{id}/tags– Assign tags to book
-
GET /api/sessions?bookId=&start=&end=– List sessions -
POST /api/sessions– Add session -
PUT /api/sessions/{id}– Update session -
DELETE /api/sessions/{id}– Delete session
-
GET /api/targets?bookId=– List reading targets -
POST /api/targets– Add target -
PUT /api/progress/{id}– Update progress
GET /api/heatmap?year=&bookId=&tagId=&targetId=– Return daily pages for calendar visualization
-
Controllers: Separate controllers for books, authors, tags, sessions, targets, progress, notes.
-
Services:
-
ReadingService: Calculate progress, average pages/day.
-
HeatmapService: Aggregate sessions to generate yearly calendar data.
-
-
Repository Layer: Handles EF Core queries, joins, and aggregation.
-
Validation Rules:
-
Session pages must be positive
-
Book total pages ≥ sum of session pages
-
Unique session per book per day
-
Components:
-
Book List / Detail Component – CRUD books, assign tags
-
Author List Component – Manage authors
-
Tag Management Component – Add, edit, assign tags
-
Reading Session Component – Daily session log, edit, delete
-
Progress Component – Show reading progress per book and target
-
Notes Component – Add notes to book or session
-
Heatmap Component – Yearly calendar visualization
-
Global Stats Component – Total pages, average pages/day
Services:
BookService,AuthorService,TagService,SessionService,ProgressService,HeatmapService
UI/UX Considerations:
-
Responsive layout for desktop and mobile
-
Tooltip on heatmap squares for pages read
-
Filter heatmap by book, tag, target
-
User Action → Angular Component → HTTP Request → Backend Controller → Service → Repository → PostgreSQL
-
Data returned → Service → Controller → Angular Component → Display to user
-
Calculate percentage completion:
(sum of pages read / total pages for target) * 100 -
Compute average pages per day:
total pages read / total days with sessions -
Aggregate heatmap data per day for visualization
-
Update global stats dynamically or via scheduled background task
-
Authentication: JWT tokens for user sessions (future multi-user support)
-
Authorization: Admin vs regular user roles (optional)
-
Input validation: Backend and frontend validation for all forms
The application is fully containerized using Docker for easy deployment and consistency across environments.
Architecture:
- 3 Docker Containers:
- Frontend Container: Nginx serving the Angular production build
- Backend Container: ASP.NET Core 10 runtime with automatic migrations
- Database Container: PostgreSQL 15
Deployment Steps:
# Clone the repository
git clone <repository-url>
cd Book-Tracking-System
# Start all services
docker compose up -d
# Access the application
# Frontend: http://localhost
# Backend API: http://localhost:5000
# Swagger: http://localhost:5000Docker Compose Configuration:
- Frontend exposed on port 80
- Backend exposed on port 5000
- Database exposed on port 5432
- Persistent volume for database data
- Automatic database migrations on backend startup
- Health checks and restart policies
Environment Variables:
DB_CONNECTION_STRING: PostgreSQL connection stringASPNETCORE_URLS: Backend listening URL- Database credentials configured in
docker-compose.yml
Backend:
- ASP.NET Core backend: Hosted on IIS, Docker, or Kestrel
- Requires .NET 10 SDK/Runtime
- Environment variables for connection strings and configuration
Frontend:
- Angular frontend: Compiled and served via Nginx, IIS, or any static file server
- Production build:
npm run build --configuration production - Outputs to
dist/frontend/browser
Database:
- PostgreSQL 15+: Production and staging databases
- Connection managed via Entity Framework Core
- Migrations applied automatically in Docker or manually via
dotnet ef database update
Configuration Files:
backend/.env: Backend environment variablesfrontend/src/environments/: Angular environment configurationdocker-compose.yml: Container orchestrationbackend/Dockerfile: Backend image definitionfrontend/Dockerfile: Frontend multi-stage buildfrontend/nginx.conf: Nginx server configuration