https://github.com/ozzy-zy/templozz
A Clean, Layered WebApi Template for .net
https://github.com/ozzy-zy/templozz
backend dotnet template-project webapi
Last synced: 12 months ago
JSON representation
A Clean, Layered WebApi Template for .net
- Host: GitHub
- URL: https://github.com/ozzy-zy/templozz
- Owner: Ozzy-ZY
- License: mit
- Created: 2025-02-08T14:06:56.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-01T01:08:27.000Z (about 1 year ago)
- Last Synced: 2025-04-19T18:37:52.783Z (about 1 year ago)
- Topics: backend, dotnet, template-project, webapi
- Language: C#
- Homepage:
- Size: 77.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# π API TEMPLATE (BUT CHAOTIC) π
YO. THIS IS A FREAKINβ **ASP.NET Core Web API Template**. Itβs got layers. Itβs got JWT auth. Itβs got **file handling**. Basically, itβs BUILT DIFFERENT. π
---
## ποΈ ARCHITECTURE (BECAUSE ORGANIZATION MATTERS, OK?)
- **API Layer** β HTTP requests go brrrr π¨
- **Application Layer** β Business logic happens here, nerd
- **Domain Layer** β The pure, untouchable core entities
- **Infrastructure Layer** β Where the database magic lives
---
## β¨ FEATURES (A.K.A. WHY THIS SLAPS)
- **π₯ Authentication & Authorization π₯**
- JWTs with refresh token sorcery πͺ
- Role-based nonsense (Admin vs Peasant)
- Registration & login because DUH
- Change password so you can regret your choices
- Google Authentication for the cool kids π
- **π File Management**
- Upload stuff π€
- Image storage πΈ
- Configurable like your coffee β
- **π’οΈ Data Access**
- Entity Framework Core (EF Core) because raw SQL is pain
- Repositories for that clean, crisp data handling β¨
- Unit of Work because transactions exist
- Migrations because "Works on my machine" isn't good enough
- **π οΈ API Configuration**
- DI setup because manual dependency management is suffering
- OpenAPI/Swagger docs so people actually use this
- Environment-specific configs (yes, PROD and DEV are different)
---
## π GETTING STARTED (NOOB GUIDE)
### Prerequisites:
- .NET 6.0+ (stay up to date, kids)
- SQL Server (or something compatible, we donβt judge)
- Visual Studio 2022 or VS Code (pick your poison)
### Installation (FOLLOW THE STEPS OR SUFFER):
1. **Clone it.**
```sh
git clone https://github.com/Ozzy-ZY/api-template.git
```
2. **Enter the void.**
```sh
cd api-template
```
3. **Configure your secrets (aka database connection).**
```json
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=YOUR_DB;Trusted_Connection=True;MultipleActiveResultSets=true"
}
```
4. **Summon the database.**
```sh
dotnet ef database update
```
5. **Summon the API overlords.**
```sh
dotnet run --project API
```
6. **Swagger lives here β** `https://localhost:7282/Scalar/v1`
---
## π PROJECT STRUCTURE (A.K.A. THE BLUEPRINTS)
```
API_Template/
βββ API/
β βββ Controllers/ (Here be endpoints π)
β β βββ AuthController.cs (Login, Register, etc.)
β β βββ TestController.cs (Just vibes π€·ββοΈ)
β β βββ UserController.cs (User stuff π€)
β βββ wwwroot/
β β βββ uploads/ (Where your cursed files go)
β βββ appsettings.json (Configs, donβt touch if scared)
β βββ Program.cs (API bootup magic ποΈ)
β
βββ Application/
β βββ DTOs/ (Data but with β¨ structure β¨)
β βββ Services/ (The real work happens here)
β βββ Validators/ (STOP BAD INPUTS π«)
β
βββ Domain/
β βββ Models/ (Entities, aka the data lords)
β βββ ModelsConfig/ (Mapping rules because EF Core needs them)
β
βββ Infrastructure/
βββ DataAccess/
βββ Repositories/ (Data handlers π¦)
βββ Migrations/ (DB evolution, survival of the fittest)
```
---
## π AUTH FLOW (FOR THOSE WHO LIKE SECURITY)
1. **Register** β Sign up (yay, new user!)
```http
POST /api/auth/RegisterUser
```
2. **Login** β Get a token, prove you're cool
```http
POST /api/auth/loginUser
```
3. **Google Login** β Let the big G vouch for you π
```http
GET /api/googleauth/login
```
4. **Refresh Token** β Because tokens expire like milk π₯
```http
POST /api/auth/RefreshToken
```
5. **Change Password** β When you forget your dog's birthday
```http
POST /api/auth/Logout
```
---
## π οΈ CUSTOMIZATION (BECOME A CODE WIZARD)
### Adding a Controller:
1. Make a new `.cs` file in `API/Controllers`
2. Inherit `ControllerBase`
3. Add `[Route]`, `[HttpGet]`, etc.
4. Deploy. Dominate. π
### Adding a Model:
1. Create it in `Domain/Models/`
2. Config it in `Domain/ModelsConfig/`
3. Add it to `AppDbContext`
4. Migrate (`dotnet ef migrations add SomethingCool`)
---
## π LICENSE (IT'S MIT, DO WHATEVER, JUST DONβT SUE ME)
## π€ CONTRIBUTING (WE WANT YOUR CODE)
1. **Fork it.** π
2. **Make a branch.** πΏ
```sh
git checkout -b feature/amazing-feature
```
3. **Commit your masterpiece.** π¨
```sh
git commit -m "Add some amazing feature"
```
4. **Push it real good.** π
```sh
git push origin feature/amazing-feature
```
5. **Open a Pull Request.** π οΈ
---
π₯ **Made with caffeine, sleepless nights, and questionable decisions.** π₯