Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public async Task<ActionResult<ValidateUserResponseViewModel>> ValidateUser(Vali
return Ok(new ValidateUserResponseViewModel
{
IsAuthenticated = true,
Token = authenticateResponse.Token,
Token = authenticateResponse.Token?? string.Empty,
LoginTime = authenticateResponse.LoginTime,
UserName = authenticateResponse.UserName,
Bio = userDetails.User.Bio,
DisplayName = userDetails.User.DisplayName,
Bio = userDetails?.User.Bio ?? string.Empty,
DisplayName = userDetails?.User.DisplayName,
});
}
catch (Exception ex)
Expand Down
21 changes: 14 additions & 7 deletions server/nt.microservice/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,20 @@ services:
context: .
dockerfile: services/ReviewService/ReviewService.Presentation.Api/Dockerfile

nt-reviewservice-db:
image: couchbase:community
container_name: nt-reviewservice-db
nt.reviewservice.db:
image: mongo:latest
hostname : nt.reviewservice.db
container_name : nt.reviewservice.db
restart: always
environment:
- CB_USERNAME=Administrator
- CB_PASSWORD=password
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: mypass
networks:
nt.reviewservice.network:
ports:
- "8091:8091" # Couchbase Web UI (Dashboard)
- "8093:8093" # Query Service (N1QL)
- "27018:27017"
volumes:
- nt.movieservice.db.volume:/data/db

###############################################################################################################
# Infrastructure Services
Expand Down Expand Up @@ -426,6 +431,8 @@ networks:
driver: bridge
nt.movieservice.network:
driver: bridge
nt.reviewservice.network:
driver: bridge
nt.common.network:
driver: bridge

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
{
if (Environment.GetEnvironmentVariable("RUNNING_WITH")?.ToUpper() == "ASPIRE")
{
request.RequestUri = new Uri($"http://localhost:{request.RequestUri.Port}" + request.RequestUri.PathAndQuery); // Set the base URL for the request
request.RequestUri = new Uri($"http://localhost:{request?.RequestUri?.Port}" + request?.RequestUri?.PathAndQuery); // Set the base URL for the request
}

var response = await base.SendAsync(request, token);
var response = await base.SendAsync(request!, token);
// Do post-processing of the response...
return response;
}
Expand Down
21 changes: 21 additions & 0 deletions server/nt.microservice/infrastructure/nt.helper/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,25 @@ public static class EnvironmentVariable
public const string DbCollection = "MovieDatabase__MovieCollectionName";
}
}

public static class ReviewService
{
public const string ServiceName = "nt-reviewservice-service";

public static class Database
{
public const string InstanceName = "nt-reviewservice-db";
public const string ContainerName = "nt.reviewservice.db";
public const string UserNameKey = $"{ServiceName}-UserName";
public const string PasswordKey = $"{ServiceName}-Password";
}

public static class EnvironmentVariable
{
public const string DbUserNameKey = "MONGO_INITDB_ROOT_USERNAME";
public const string DbPasswordKey = "MONGO_INITDB_ROOT_PASSWORD";
public const string DbName = "ReviewDatabase__DatabaseName";
public const string DbCollection = "ReviewDatabase__ReviewCollectionName";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,22 @@
var mongoDbUsername = builder.AddParameter(Constants.MovieService.Database.UserNameKey, infrastructureSettings.MongoDb.UserName, secret: true);
var mongoDbPassword = builder.AddParameter(Constants.MovieService.Database.PasswordKey, infrastructureSettings.MongoDb.Password, secret: true);

var mongoDb = builder.AddMongoDB(Constants.MovieService.Database.InstanceName, 27017, userName: mongoDbUsername, password: mongoDbPassword)
var mongoDbMovie = builder.AddMongoDB(Constants.MovieService.Database.InstanceName, 27017, userName: mongoDbUsername, password: mongoDbPassword)
.WithEnvironment(Constants.MovieService.EnvironmentVariable.DbUserNameKey, infrastructureSettings.MongoDb.UserName)
.WithEnvironment(Constants.MovieService.EnvironmentVariable.DbPasswordKey, infrastructureSettings.MongoDb.Password)
//.WithEndpoint(port: 27017, targetPort: 27017, isProxied: true)
.WithContainerName(Constants.MovieService.Database.ContainerName)
.WithDataVolume()
.WithMongoExpress();

var mongoDbReview = builder.AddMongoDB(Constants.ReviewService.Database.InstanceName, 27018, userName: mongoDbUsername, password: mongoDbPassword)
.WithEnvironment(Constants.ReviewService.EnvironmentVariable.DbUserNameKey, infrastructureSettings.MongoDb.UserName)
.WithEnvironment(Constants.ReviewService.EnvironmentVariable.DbPasswordKey, infrastructureSettings.MongoDb.Password)
//.WithEndpoint(port: 27017, targetPort: 27017, isProxied: true)
.WithContainerName(Constants.ReviewService.Database.ContainerName)
.WithDataVolume()
.WithMongoExpress();

var blobStorage = builder.AddContainer("nt-userservice-blobstorage", infrastructureSettings.BlobStorage.DockerImage)
.WithVolume("//d/Source/nt/server/nt.microservice/services/UserService/BlobStorage:/data")
.WithArgs("azurite-blob", "--blobHost", "0.0.0.0", "-l", "/data")
Expand All @@ -70,14 +78,6 @@
.WithEnvironment("MSSQL_SA_PASSWORD", infrastructureSettings.SqlServer.Password)
.WithHttpEndpoint(port: infrastructureSettings.SqlServer.HostPort, targetPort: infrastructureSettings.SqlServer.TargetPort, isProxied: true);

var couchbase = builder.AddContainer("nt-reviewservice-db", "couchbase:community")
.WithEnvironment("CB_USERNAME", "Administrator")
.WithEnvironment("CB_PASSWORD", "password")
.WithEndpoint(port: 8091, targetPort:8091, scheme:"http")
.WithEndpoint(port: 8093, targetPort:8093)
.WithHttpHealthCheck("/pools");


var authServiceInstances = new List<IResourceBuilder<ProjectResource>>();
foreach(var port in serviceSettings.AuthService.InstancePorts)
{
Expand Down Expand Up @@ -167,8 +167,8 @@
.WithEnvironment(Constants.Infrastructure.Consul.Environement.ServiceHost, serviceSettings.MovieService.ServiceRegistrationConfig.ServiceHost)
.WithEnvironment(Constants.Infrastructure.Consul.Environement.RegistryUri, consulServiceDiscovery.GetEndpoint("http"))
.WithEnvironment(Constants.Infrastructure.Consul.Environement.DeregisterAfter, serviceSettings.MovieService.ServiceRegistrationConfig.DeregisterAfterMinutes.ToString())
.WithReference(mongoDb)
.WaitFor(mongoDb)
.WithReference(mongoDbMovie)
.WaitFor(mongoDbMovie)
.WaitFor(consulServiceDiscovery)
.WithUrls(c => c.Urls.ForEach(u => u.DisplayText = $"Open API ({u.Endpoint?.Port})")); ;

Expand All @@ -179,7 +179,8 @@
var reviewService = builder.AddProject<Projects.ReviewService_Presenation_Api>("nt-reviewservice-service")
.WithEnvironment(Constants.Global.EnvironmentVariables.RunningWithVariable, Constants.Global.EnvironmentVariables.RunningWithValue)
.WithUrls(c => c.Urls.ForEach(u => u.DisplayText = $"Open API ({u.Endpoint?.EndpointName})"))
.WaitFor(couchbase);
.WithReference(mongoDbReview)
.WaitFor(mongoDbReview);


var gateway = builder.AddProject<Projects.nt_gateway>(Constants.Gateway.ServiceName, launchProfileName: Constants.Gateway.LaunchProfile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace MovieService.Api.BackgroundServices;

public class ServiceRegistration : BackgroundService
public class ConsulServiceRegistrationService : BackgroundService
{
private readonly IConsulClient _consulClient;
private readonly ServiceRegistrationConfig _serviceDiscoveryConfiguration;
private readonly ILogger<ServiceRegistration> _logger;
private readonly ILogger<ConsulServiceRegistrationService> _logger;
private readonly IHostApplicationLifetime _lifetime;
public ServiceRegistration(IConsulClient consultClient,
public ConsulServiceRegistrationService(IConsulClient consultClient,
IOptions<ServiceRegistrationConfig> serviceDiscoveryConfigurations,
ILogger<ServiceRegistration> logger,
ILogger<ConsulServiceRegistrationService> logger,
IHostApplicationLifetime lifetime)
{
_consulClient = consultClient ?? throw new ArgumentNullException(nameof(consultClient));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using MovieService.Data;
using MovieService.Data.Interfaces.Entities;
using MovieService.Data.Seed;
using MovieService.Service.Interfaces.Dtos;

namespace MovieService.Api;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
return new ConsulClient(consulConfig);
});

builder.Services.AddHostedService<ServiceRegistration>();
builder.Services.AddHostedService<ConsulServiceRegistrationService>();

var app = builder.Build();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using MongoDB.Entities;

namespace ReviewService.Infrastructure.Repository.Documents;

[Collection(ReviewDocument.CollectionName)]
public class ReviewDocument:Entity
{
internal const string CollectionName = "reviews";


[Field("movieId")]
public Guid MovieId { get; set; }

[Field("title")]
public string Title { get; set; } = string.Empty;

[Field("content")]
public string Content { get; set; } = string.Empty;

[Field("rating")]
public int Rating { get; set; }

[Field("userName")]
public string UserName { get; set; } = string.Empty;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Entities" Version="23.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReviewService.Domain\ReviewService.Domain.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
using ReviewService.Infrastructure.Repository.Documents;

namespace ReviewService.Infrastructure.Repository.Seed;

public static class MalayalamReviewsSeed
{
public static IEnumerable<ReviewDocument> Reviews => [
new() {
Content = "A heartwarming tale with mouthwatering visuals and a soulful story. Loved it!",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("6191e634-14c8-45d1-898f-191060cdbec1"),
Rating = 5,
Title = "Ustad Hotel Feels",
UserName = "moviebuff_91"
},
new() {
Content = "Dulquer and Thilakan make this movie a beautiful emotional ride. Music was perfect.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("6191e634-14c8-45d1-898f-191060cdbec1"),
Rating = 4,
Title = "Beautiful Blend",
UserName = "cinemalover"
},
new() {
Content = "Joji is an intense, slow burn thriller. Brilliant acting by Fahadh as always.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bea50cb7-41b6-4a35-b77f-358e8c43f850"),
Rating = 4,
Title = "Dark and Gripping",
UserName = "screenaddict"
},
new() {
Content = "Minimal dialogues, maximum impact. Joji is a masterclass in modern Malayalam cinema.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bea50cb7-41b6-4a35-b77f-358e8c43f850"),
Rating = 5,
Title = "Minimalist Brilliance",
UserName = "cinecritic"
},
new() {
Content = "A hilarious ride with unexpected twists. Oru Vadakkan Selfie is pure fun.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bd4b80a0-1516-4b71-887b-714c52459f23"),
Rating = 4,
Title = "Comedy Hit",
UserName = "ajay.m"
},
new() {
Content = "Selfie gone wrong but in the best way possible. Loved the storytelling and humor.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bd4b80a0-1516-4b71-887b-714c52459f23"),
Rating = 5,
Title = "Smart Comedy",
UserName = "techjunkie"
},
new() {
Content = "Malik is powerful. A political saga with gripping performances. Fahadh nailed it!",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("0003be11-f19a-4b9c-a1b2-b7e195b53d3e"),
Rating = 5,
Title = "Political Power",
UserName = "seriouscinema"
},
new() {
Content = "One of the best performances by Fahadh. Malik stays with you long after it ends.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("0003be11-f19a-4b9c-a1b2-b7e195b53d3e"),
Rating = 5,
Title = "Brilliant Execution",
UserName = "rajfilm"
},
new() {
Content = "Premam is nostalgic, fun, and full of charm. Every phase of love was shown beautifully.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("af3e9bed-3e04-4f06-856d-3c572605bf4d"),
Rating = 5,
Title = "Love Story Goals",
UserName = "dreamy_eyes"
},
new() {
Content = "Great music, wonderful performances. Premam is a modern Malayalam classic.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("af3e9bed-3e04-4f06-856d-3c572605bf4d"),
Rating = 5,
Title = "Evergreen",
UserName = "anu_reviews"
},
new() {
Content = "Jana Gana Mana is thought-provoking. Raises valid questions about justice and media.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("47435a1d-6b24-4cfc-b3a6-0be543322187"),
Rating = 4,
Title = "Relevant and Bold",
UserName = "truthseeker"
},
new() {
Content = "Powerful script and solid performances. Worth watching more than once.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("47435a1d-6b24-4cfc-b3a6-0be543322187"),
Rating = 5,
Title = "Must Watch",
UserName = "prithvi_rules"
},
new() {
Content = "Ustad Hotel remains a comfort movie. It warms the soul and stirs the appetite.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("6191e634-14c8-45d1-898f-191060cdbec1"),
Rating = 5,
Title = "Feel-Good Watch",
UserName = "greenchili"
},
new() {
Content = "Malik's political layers and gripping visuals make it a standout Malayalam film.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("0003be11-f19a-4b9c-a1b2-b7e195b53d3e"),
Rating = 4,
Title = "Strong Narrative",
UserName = "malayalicritic"
},
new() {
Content = "Premam redefined romance in Malayalam cinema. A perfect blend of nostalgia and music.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("af3e9bed-3e04-4f06-856d-3c572605bf4d"),
Rating = 5,
Title = "Romantic Classic",
UserName = "cinepulse"
},
new() {
Content = "Joji’s silence speaks louder than words. A chilling adaptation of Macbeth.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bea50cb7-41b6-4a35-b77f-358e8c43f850"),
Rating = 4,
Title = "Psychological Drama",
UserName = "joji_fan"
},
new() {
Content = "Loved every bit of Oru Vadakkan Selfie. Light-hearted and perfect for a rewatch!",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("bd4b80a0-1516-4b71-887b-714c52459f23"),
Rating = 4,
Title = "Laugh Riot",
UserName = "minnal_m"
},
new() {
Content = "Jana Gana Mana deserves more attention. Thought-provoking and very well directed.",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("47435a1d-6b24-4cfc-b3a6-0be543322187"),
Rating = 5,
Title = "Social Eye-Opener",
UserName = "vocalviewer"
},
new() {
Content = "Premam’s characters grow on you. Sai Pallavi was just magical!",
ID = Guid.NewGuid().ToString(),
MovieId = Guid.Parse("af3e9bed-3e04-4f06-856d-3c572605bf4d"),
Rating = 5,
Title = "Romance and Charm"
}
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using ReviewService.Infrastructure.Repository.Documents;

namespace ReviewService.Infrastructure.Repository.Seed;

public static class Seed
{
public static IEnumerable<ReviewDocument> MalayalamReviews => MalayalamReviewsSeed.Reviews;

}
Loading