Skip to content

Commit

Permalink
Merge pull request #53 from dDevAhmed/feature/module-architecture
Browse files Browse the repository at this point in the history
Module Architecture Setup
  • Loading branch information
Xaxxoo authored Feb 18, 2025
2 parents 211db53 + d939c18 commit f39121d
Show file tree
Hide file tree
Showing 32 changed files with 486 additions and 1 deletion.
59 changes: 59 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# compiled output
/dist
/node_modules
/build

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# dotenv environment variable files
.env
.env.development.local
.env.development
.env.test.local
.env.test
.env.production.local
.env.production
.env.local

# temp directory
.temp
.tmp

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
21 changes: 21 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"@nestjs/common": "^11.0.1",
"@nestjs/core": "^11.0.1",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^11.0.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1"
Expand Down
6 changes: 5 additions & 1 deletion backend/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UsersModule } from './users/users.module';
import { AuthModule } from './auth/auth.module';
import { ChatModule } from './chat/chat.module';
import { WebsocketModule } from './websocket/websocket.module';

@Module({
imports: [],
imports: [UsersModule, AuthModule, ChatModule, WebsocketModule],
controllers: [AppController],
providers: [AppService],
})
Expand Down
24 changes: 24 additions & 0 deletions backend/src/auth/auth.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
type Auth {
# Example field (placeholder)
exampleField: Int
}

input CreateAuthInput {
# Example field (placeholder)
exampleField: Int
}

input UpdateAuthInput {
id: Int!
}

type Query {
auth: [Auth]!
auth(id: Int!): Auth
}

type Mutation {
createAuth(createAuthInput: CreateAuthInput!): Auth!
updateAuth(updateAuthInput: UpdateAuthInput!): Auth!
removeAuth(id: Int!): Auth
}
8 changes: 8 additions & 0 deletions backend/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthResolver } from './auth.resolver';

@Module({
providers: [AuthResolver, AuthService],
})
export class AuthModule {}
34 changes: 34 additions & 0 deletions backend/src/auth/auth.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Resolver, Query, Mutation, Args } from '@nestjs/graphql';
import { AuthService } from './auth.service';
import { CreateAuthInput } from './dto/create-auth.input';
import { UpdateAuthInput } from './dto/update-auth.input';

@Resolver('Auth')
export class AuthResolver {
constructor(private readonly authService: AuthService) {}

@Mutation('createAuth')
create(@Args('createAuthInput') createAuthInput: CreateAuthInput) {
return this.authService.create(createAuthInput);
}

@Query('auth')
findAll() {
return this.authService.findAll();
}

@Query('auth')
findOne(@Args('id') id: number) {
return this.authService.findOne(id);
}

@Mutation('updateAuth')
update(@Args('updateAuthInput') updateAuthInput: UpdateAuthInput) {
return this.authService.update(updateAuthInput.id, updateAuthInput);
}

@Mutation('removeAuth')
remove(@Args('id') id: number) {
return this.authService.remove(id);
}
}
26 changes: 26 additions & 0 deletions backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateAuthInput } from './dto/create-auth.input';
import { UpdateAuthInput } from './dto/update-auth.input';

@Injectable()
export class AuthService {
create(createAuthInput: CreateAuthInput) {
return 'This action adds a new auth';
}

findAll() {
return `This action returns all auth`;
}

findOne(id: number) {
return `This action returns a #${id} auth`;
}

update(id: number, updateAuthInput: UpdateAuthInput) {
return `This action updates a #${id} auth`;
}

remove(id: number) {
return `This action removes a #${id} auth`;
}
}
1 change: 1 addition & 0 deletions backend/src/auth/dto/create-auth.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateAuthInput {}
6 changes: 6 additions & 0 deletions backend/src/auth/dto/update-auth.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CreateAuthInput } from './create-auth.input';
import { PartialType } from '@nestjs/mapped-types';

export class UpdateAuthInput extends PartialType(CreateAuthInput) {
id: number;
}
1 change: 1 addition & 0 deletions backend/src/auth/entities/auth.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Auth {}
24 changes: 24 additions & 0 deletions backend/src/chat/chat.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
type Chat {
# Example field (placeholder)
exampleField: Int
}

input CreateChatInput {
# Example field (placeholder)
exampleField: Int
}

input UpdateChatInput {
id: Int!
}

type Query {
chat: [Chat]!
chat(id: Int!): Chat
}

type Mutation {
createChat(createChatInput: CreateChatInput!): Chat!
updateChat(updateChatInput: UpdateChatInput!): Chat!
removeChat(id: Int!): Chat
}
8 changes: 8 additions & 0 deletions backend/src/chat/chat.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { ChatService } from './chat.service';
import { ChatResolver } from './chat.resolver';

@Module({
providers: [ChatResolver, ChatService],
})
export class ChatModule {}
34 changes: 34 additions & 0 deletions backend/src/chat/chat.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Resolver, Query, Mutation, Args } from '@nestjs/graphql';
import { ChatService } from './chat.service';
import { CreateChatInput } from './dto/create-chat.input';
import { UpdateChatInput } from './dto/update-chat.input';

@Resolver('Chat')
export class ChatResolver {
constructor(private readonly chatService: ChatService) {}

@Mutation('createChat')
create(@Args('createChatInput') createChatInput: CreateChatInput) {
return this.chatService.create(createChatInput);
}

@Query('chat')
findAll() {
return this.chatService.findAll();
}

@Query('chat')
findOne(@Args('id') id: number) {
return this.chatService.findOne(id);
}

@Mutation('updateChat')
update(@Args('updateChatInput') updateChatInput: UpdateChatInput) {
return this.chatService.update(updateChatInput.id, updateChatInput);
}

@Mutation('removeChat')
remove(@Args('id') id: number) {
return this.chatService.remove(id);
}
}
26 changes: 26 additions & 0 deletions backend/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateChatInput } from './dto/create-chat.input';
import { UpdateChatInput } from './dto/update-chat.input';

@Injectable()
export class ChatService {
create(createChatInput: CreateChatInput) {
return 'This action adds a new chat';
}

findAll() {
return `This action returns all chat`;
}

findOne(id: number) {
return `This action returns a #${id} chat`;
}

update(id: number, updateChatInput: UpdateChatInput) {
return `This action updates a #${id} chat`;
}

remove(id: number) {
return `This action removes a #${id} chat`;
}
}
1 change: 1 addition & 0 deletions backend/src/chat/dto/create-chat.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateChatInput {}
6 changes: 6 additions & 0 deletions backend/src/chat/dto/update-chat.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CreateChatInput } from './create-chat.input';
import { PartialType } from '@nestjs/mapped-types';

export class UpdateChatInput extends PartialType(CreateChatInput) {
id: number;
}
1 change: 1 addition & 0 deletions backend/src/chat/entities/chat.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Chat {}
1 change: 1 addition & 0 deletions backend/src/users/dto/create-user.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateUserInput {}
6 changes: 6 additions & 0 deletions backend/src/users/dto/update-user.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CreateUserInput } from './create-user.input';
import { PartialType } from '@nestjs/mapped-types';

export class UpdateUserInput extends PartialType(CreateUserInput) {
id: number;
}
1 change: 1 addition & 0 deletions backend/src/users/entities/user.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class User {}
24 changes: 24 additions & 0 deletions backend/src/users/users.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
type User {
# Example field (placeholder)
exampleField: Int
}

input CreateUserInput {
# Example field (placeholder)
exampleField: Int
}

input UpdateUserInput {
id: Int!
}

type Query {
users: [User]!
user(id: Int!): User
}

type Mutation {
createUser(createUserInput: CreateUserInput!): User!
updateUser(updateUserInput: UpdateUserInput!): User!
removeUser(id: Int!): User
}
8 changes: 8 additions & 0 deletions backend/src/users/users.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { UsersService } from './users.service';
import { UsersResolver } from './users.resolver';

@Module({
providers: [UsersResolver, UsersService],
})
export class UsersModule {}
Loading

0 comments on commit f39121d

Please sign in to comment.