|
1 | | -Template App for Angular 20 and .NET 9 Web Api |
2 | 1 |
|
3 | | -This application will showcase all of Angular's features, along with those of Angular Material. |
4 | | -The backend will handle JWT login along with social login ( Google, Facebook, etc ). Frontend config will be stored on the backend. |
| 2 | +# Angular 20 + .NET 9 Web API Template App |
5 | 3 |
|
6 | | -Current Features |
7 | | -* |
8 | | -* |
9 | | -* |
| 4 | +A starter template demonstrating a full-stack application using Angular 20 on the frontend and .NET 9 Web API on the backend. This project showcases modern Angular features combined with Angular Material components and secure backend JWT + social authentication. |
10 | 5 |
|
11 | | -Upcoming Features |
12 | | -* User Login and storage |
13 | | -* Theme selection |
14 | | -* |
| 6 | +--- |
15 | 7 |
|
| 8 | +## Table of Contents |
16 | 9 |
|
17 | | -Production Setup |
18 | | -Use a secret manager (e.g., Azure Key Vault) for enhanced security |
| 10 | +- [Features](#features) |
| 11 | +- [Architecture Overview](#architecture-overview) |
| 12 | +- [Getting Started](#getting-started) |
| 13 | +- [Environment Configuration](#environment-configuration) |
| 14 | +- [Running the Application](#running-the-application) |
| 15 | +- [Production Setup](#production-setup) |
| 16 | +- [Contributing](#contributing) |
| 17 | +- [License](#license) |
19 | 18 |
|
20 | | -Powershell |
| 19 | +--- |
21 | 20 |
|
| 21 | +## Features |
| 22 | + |
| 23 | +- JWT Authentication (login, logout, token refresh) |
| 24 | +- Social login support (Google, Facebook, etc.) |
| 25 | +- Backend-driven frontend configuration (e.g., theme, settings) |
| 26 | +- Angular Material UI components & responsive design |
| 27 | +- Secure API endpoints with role-based authorization |
| 28 | +- Environment-based configuration for development and production |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Architecture Overview |
| 33 | + |
| 34 | +### Frontend |
| 35 | + |
| 36 | +- **Angular 20**: Latest Angular framework leveraging Signals, standalone components, and modern best practices |
| 37 | +- **Angular Material**: UI component library for consistent and accessible design |
| 38 | +- **Auth Module**: Manages JWT and social login flows |
| 39 | +- **Configuration Module**: Loads and applies settings fetched from the backend at runtime |
| 40 | + |
| 41 | +### Backend |
| 42 | + |
| 43 | +- **.NET 9 Web API**: RESTful API with controllers, services, and EF Core for data access |
| 44 | +- **Authentication**: JWT-based with refresh tokens, social login integrations |
| 45 | +- **Configuration Service**: Serves frontend configuration (e.g., theme, API URLs) |
| 46 | +- **Security**: Environment-based secrets, role-based authorization, HTTPS enforced |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Getting Started |
| 51 | + |
| 52 | +### Prerequisites |
| 53 | + |
| 54 | +- [.NET 9 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) |
| 55 | +- [Node.js 18+](https://nodejs.org/en/download/) and npm |
| 56 | +- [Angular CLI 16+](https://angular.io/cli) |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### Backend Setup |
| 61 | + |
| 62 | +1. Clone the repository: |
| 63 | + |
| 64 | + ```bash |
| 65 | + git clone https://github.com/yourusername/your-repo.git |
| 66 | + cd your-repo/backend |
| 67 | + ``` |
| 68 | + |
| 69 | +2. Set environment variables (see [Environment Configuration](#environment-configuration)). |
| 70 | + |
| 71 | +3. Apply database migrations (if using EF Core): |
| 72 | + |
| 73 | + ```bash |
| 74 | + dotnet ef database update |
| 75 | + ``` |
| 76 | + |
| 77 | +4. Run the API: |
| 78 | + |
| 79 | + ```bash |
| 80 | + dotnet run |
| 81 | + ``` |
| 82 | + |
| 83 | + By default, API runs at `https://localhost:5001`. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +### Frontend Setup |
| 88 | + |
| 89 | +1. Navigate to the frontend folder: |
| 90 | + |
| 91 | + ```bash |
| 92 | + cd ../frontend |
| 93 | + ``` |
| 94 | + |
| 95 | +2. Install dependencies: |
| 96 | + |
| 97 | + ```bash |
| 98 | + npm install |
| 99 | + ``` |
| 100 | + |
| 101 | +3. Configure the API base URL: |
| 102 | + |
| 103 | + - Modify `src/environments/environment.ts` for development |
| 104 | + - Or use backend-driven config during runtime |
| 105 | + |
| 106 | +4. Run the Angular app: |
| 107 | + |
| 108 | + ```bash |
| 109 | + ng serve |
| 110 | + ``` |
| 111 | + |
| 112 | +5. Open your browser at [http://localhost:4200](http://localhost:4200). |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Environment Configuration |
| 117 | + |
| 118 | +### Recommended: Use a Secret Manager for Production |
| 119 | + |
| 120 | +Use Azure Key Vault, AWS Secrets Manager, or similar to securely store: |
| 121 | + |
| 122 | +- Database connection strings |
| 123 | +- JWT secret keys |
| 124 | +- OAuth client IDs and secrets |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +### Environment Variables |
| 129 | + |
| 130 | +**Windows PowerShell** |
| 131 | + |
| 132 | +```powershell |
22 | 133 | $env:ConnectionStrings__DefaultConnection="Server=your-server;Database=AuthDb;User Id=sa;Password=your-password;TrustServerCertificate=True" |
23 | 134 | $env:Jwt__Key="your-secure-key-here-32-chars-long" |
24 | 135 | $env:Jwt__Issuer="https://your-api-domain" |
25 | 136 | $env:Jwt__Audience="https://your-api-domain" |
26 | 137 | $env:Frontend__Url="https://your-frontend-domain" |
27 | 138 | $env:Api__BaseUrl="https://your-api-domain/api" |
| 139 | +``` |
28 | 140 |
|
29 | | -Linux/Mac (Bash): |
30 | | -Use double underscores (__) to denote nested configuration keys (e.g., Jwt__Key for Jwt:Key). |
| 141 | +**Linux / macOS (Bash)** |
31 | 142 |
|
| 143 | +```bash |
32 | 144 | export ConnectionStrings__DefaultConnection="Server=your-server;Database=AuthDb;User Id=sa;Password=your-password;TrustServerCertificate=True" |
33 | 145 | export Jwt__Key="your-secure-key-here-32-chars-long" |
34 | 146 | export Jwt__Issuer="https://your-api-domain" |
35 | 147 | export Jwt__Audience="https://your-api-domain" |
36 | 148 | export Frontend__Url="https://your-frontend-domain" |
37 | | -export Api__BaseUrl="https://your-api-domain/api" |
| 149 | +export Api__BaseUrl="https://your-api-domain/api" |
| 150 | +``` |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## Running the Application |
| 155 | + |
| 156 | +- Run backend API first |
| 157 | +- Start frontend Angular app |
| 158 | +- Access frontend and login with JWT or social accounts |
| 159 | +- Explore UI components and themes |
| 160 | +- Extend with your own features! |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## Contributing |
| 165 | + |
| 166 | +Contributions are welcome! Please: |
| 167 | + |
| 168 | +- Fork the repo |
| 169 | +- Create a feature branch |
| 170 | +- Write tests for new features |
| 171 | +- Follow existing code style and conventions |
| 172 | +- Submit a pull request with a clear description |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## License |
| 177 | + |
| 178 | +MIT License © [Your Name or Organization] |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +If you want, I can also help generate sample code snippets for authentication, social login integration, or Angular Material usage — just ask! |
0 commit comments