DEV Community

Sugumar
Sugumar

Posted on

day 1 project stucture

🧱 Step 1 β€” Create Main Folder and Open Terminal

πŸ‘‰ Open a terminal (PowerShell / VS Code terminal) and type these commands one by one:

mkdir AccountingSuite
cd AccountingSuite
mkdir src tests
Enter fullscreen mode Exit fullscreen mode

βœ… Check: After this you must have:

AccountingSuite/
 β”œβ”€β”€ src/
 └── tests/
Enter fullscreen mode Exit fullscreen mode

🧱 Step 2 β€” Create Projects

Now go inside src and create the projects:

cd src
dotnet new webapi -n Accounting.API
dotnet new blazorwasm -n Accounting.UI
dotnet new classlib -n Accounting.Domain
dotnet new classlib -n Accounting.Infrastructure
dotnet new classlib -n Accounting.Shared
Enter fullscreen mode Exit fullscreen mode

βœ… After this, inside src you’ll see 5 folders.
If you get an error like β€œtemplate not found”, install the correct .NET SDK or re-open terminal.


🧱 Step 3 β€” Create the Solution File and Add All Projects

cd ..
dotnet new sln -n AccountingSuite
dotnet sln AccountingSuite.sln add src/Accounting.API/Accounting.API.csproj
dotnet sln AccountingSuite.sln add src/Accounting.UI/Accounting.UI.csproj
dotnet sln AccountingSuite.sln add src/Accounting.Domain/Accounting.Domain.csproj
dotnet sln AccountingSuite.sln add src/Accounting.Infrastructure/Accounting.Infrastructure.csproj
dotnet sln AccountingSuite.sln add src/Accounting.Shared/Accounting.Shared.csproj
Enter fullscreen mode Exit fullscreen mode

βœ… You’ll now have AccountingSuite.sln in the root folder.
Test build:

dotnet build
Enter fullscreen mode Exit fullscreen mode

Expect β€œBuild succeeded.”


🧱 Step 4 β€” Add Project References

Inside src:

cd src
dotnet add Accounting.API reference Accounting.Domain
dotnet add Accounting.API reference Accounting.Infrastructure
dotnet add Accounting.API reference Accounting.Shared

dotnet add Accounting.Infrastructure reference Accounting.Domain
dotnet add Accounting.Infrastructure reference Accounting.Shared

dotnet add Accounting.UI reference Accounting.Shared
Enter fullscreen mode Exit fullscreen mode

βœ… Output should show β€œReference added.” for each line.


🧱 Step 5 β€” Add Base Folders

Use VS Code or File Explorer.
Create these folders:

Accounting.Domain

Entities/
Enums/
Interfaces/
Enter fullscreen mode Exit fullscreen mode

Accounting.Infrastructure

Data/
Repositories/
Migrations/
Enter fullscreen mode Exit fullscreen mode

Accounting.API

Controllers/
Services/
Helpers/
Middlewares/
Enter fullscreen mode Exit fullscreen mode

Accounting.Shared

DTOs/
Responses/
Constants/
Enter fullscreen mode Exit fullscreen mode

βœ… Don’t add any code yet β€” only folders.


🧱 Step 6 β€” Add Swagger + CORS and Test API

Open src/Accounting.API/Program.cs.
Replace all code with this ready-to-run version πŸ‘‡

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);

// Add services
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
    options.AddPolicy("AllowAll", p =>
        p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
});

var app = builder.Build();

// Middleware
app.UseCors("AllowAll");
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthorization();
app.MapControllers();

app.Run();
Enter fullscreen mode Exit fullscreen mode

βœ… Save and run:

cd src/Accounting.API
dotnet run
Enter fullscreen mode Exit fullscreen mode

Open browser β†’ https://localhost:5001/swagger (or port shown).
You’ll see Swagger page with β€œWeatherForecast” example.


🧱 Step 7 β€” Create a Health Check Controller

Create file:
src/Accounting.API/Controllers/HealthController.cs

Paste this:

using Microsoft.AspNetCore.Mvc;

namespace Accounting.API.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class HealthController : ControllerBase
    {
        [HttpGet]
        public IActionResult Get() => Ok(new { status = "up" });
    }
}
Enter fullscreen mode Exit fullscreen mode

Save and run again:

dotnet run
Enter fullscreen mode Exit fullscreen mode

Open Swagger β†’ you’ll now see GET /api/health β†’ click Try it out β†’ Execute.
βœ… Expected result:

{
  "status": "up"
}
Enter fullscreen mode Exit fullscreen mode

Congratulations πŸŽ‰
Your Clean Architecture API is alive!


🧱 Step 8 β€” Initialize Git + GitHub

From root folder (AccountingSuite/):

git init
git add .
git commit -m "Day1 - Initial Clean Architecture Setup"
Enter fullscreen mode Exit fullscreen mode

If you use GitHub CLI:

gh repo create AccountingSuite --public --source=. --remote=origin
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

βœ… Repo online with all 5 projects.


🧾 Step 9 β€” End of Day 1 Checklist

Task Done
Main folder + projects created βœ…
Solution file built successfully βœ…
Project references added βœ…
Base folders created βœ…
Swagger + CORS working βœ…
HealthController tested βœ…
Git repo initialized and pushed βœ…

πŸ’¬ Now ask your teammate:

β€œDay 1 setup done β€” can you review folder structure and confirm before I start Day 2 (Database + Entities design)?”


Do you want me to give you the Day 2 (Database & Entity design) step-by-step next, in the same beginner-friendly style?

Top comments (0)