A full-stack blog application built with .NET 8 Web API backend and React TypeScript frontend, featuring JWT authentication, blog post management, and Docker containerization.
- CRUD Operations: Create, read, update, and delete blog posts via REST API
- Categories: Support for "book-recommendations" and "art-of-living" content types
- Admin Authentication: JWT-based authentication for content management
- Public Access: Unauthenticated users can view published posts with filtering
- Rich Content: Support for featured images, summaries, and view tracking
POST /api/auth/login- Admin login with JWT token responseGET /api/posts- List posts (public, with category and pagination filtering)POST /api/posts- Create post (admin only)GET /api/posts/{id}- Get single postPUT /api/posts/{id}- Update post (admin only)DELETE /api/posts/{id}- Delete post (admin only)
- Secure login with JWT authentication
- Post creation and editing forms
- Post management dashboard
- Category filtering and organization
- Homepage with post listings
- Category-based filtering
- Individual post view pages
- Responsive design with Material-UI
- Blog.Api: Main API project with endpoints and startup configuration
- Blog.Core: Business logic and services layer
- Blog.Models: Data models and entities
- Blog.Migrations: Entity Framework migrations
- Blog.ServiceTests: Integration/service tests
- Built with Vite for fast development and building
- Material-UI for consistent component design
- React Router for client-side routing
- ESLint for code quality enforcement
- PostgreSQL for production reliability
- Entity Framework Core for data access
- Automatic migrations and health checks
- Docker Compose orchestration
- Multi-stage builds for optimized images
- Health checks for all services
- Persistent data volumes
- Docker and Docker Compose installed
- Git (to clone the repository)
-
Clone the repository
git clone <repository-url> cd BLOG
-
Start all services
cd Blog docker compose up --build -
Access the application
- Frontend: http://localhost:8080
- Backend API: http://localhost:5001
- Database: localhost:5432
The Docker environment includes:
| Service | Port | Description |
|---|---|---|
| Frontend | 8080 | React application served by Nginx |
| API | 5001 | .NET Web API backend |
| Database | 5432 | PostgreSQL database |
- Admin Username:
admin - Admin Password:
admin123 - Database:
blogdb/postgres/postgres123
The application uses the following key environment variables (configured in compose.yaml):
# API Configuration
ASPNETCORE_ENVIRONMENT: Development
ConnectionStrings__DefaultConnection: Server=db;Port=5432;Database=blogdb;User Id=postgres;Password=postgres123;
JwtSettings__Key: your-super-secret-jwt-key-that-is-at-least-32-characters-long
AdminCredentials__Username: admin
AdminCredentials__Password: admin123
# Frontend Configuration
VITE_API_URL: /api# Start all services in background
docker compose up -d --build
# View logs
docker compose logs -f
# Stop all services
docker compose down
# Remove volumes (reset database)
docker compose down -v
# Start individual services
docker compose up frontend
docker compose up api
docker compose up db
# Run tests (optional)
docker compose --profile testing up servicetestsDatabase Connection Issues
- Ensure PostgreSQL service is healthy:
docker compose ps - Check database logs:
docker compose logs db
API Not Starting
- Verify database is running and healthy
- Check API logs:
docker compose logs api - Ensure all environment variables are properly set
Frontend Not Loading
- Verify API is accessible at http://localhost:5001
- Check frontend logs:
docker compose logs frontend - Ensure VITE_API_URL is correctly configured
- Make code changes in your IDE
- Rebuild affected services:
docker compose up --build api # For backend changes docker compose up --build frontend # For frontend changes
- Test changes at http://localhost:8080
- View logs for debugging:
docker compose logs -f [service-name]
- Database data persists in the
postgres_dataDocker volume - To reset the database:
docker compose down -v && docker compose up --build
# From project root
dotnet restore
dotnet build
dotnet run --project src/Blog.Apicd frontend
npm install
npm run dev- Install PostgreSQL locally
- Update connection string in
appsettings.development.json - Run migrations:
dotnet ef database update --project src/Blog.Migrations --startup-project src/Blog.Api
# Run integration tests
dotnet test src/Blog.ServiceTests
# Run with Docker (includes database)
docker compose --profile testing up servicetests- .NET 8 Web API
- Entity Framework Core with PostgreSQL
- JWT Authentication
- Refit for HTTP clients
- React 19 with TypeScript
- Vite build tool
- Material-UI components
- React Router DOM
- Docker & Docker Compose
- Multi-stage builds
- Health checks
- Nginx reverse proxy