Skip to content

Commit 1cfdb6a

Browse files
(feat): Implement Contract Repo, VCS, Signing (#24)
* feat: contracts repo [WIP] * refactor: encryption to file wise * feat: vcs support for contracts * chore: dump this shit cause it works * fix: lint errors * feat: implement key management * feat: add UserPublicKey model and update related methods * chore: trying to fix casing * chore: `bruno` is finally lower case * chore: Remove files
1 parent b6f8e60 commit 1cfdb6a

File tree

89 files changed

+3649
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3649
-269
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ yarn-error.log*
77
pnpm-debug.log*
88
lerna-debug.log*
99

10+
*.pem
11+
/data/
1012
node_modules
1113
dist
1214
dist-ssr
@@ -49,4 +51,4 @@ __pycache__/
4951

5052
# swarm
5153
swarm.egg-info
52-
marai_agents.egg-info
54+
marai_agents.egg-info

CODE_OF_CONDUCT.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to creating a positive environment include:
18+
19+
* Using welcoming and inclusive language
20+
* Being respectful of differing viewpoints and experiences
21+
* Gracefully accepting constructive criticism
22+
* Focusing on what is best for the community
23+
* Showing empathy towards other community members
24+
25+
Examples of unacceptable behavior include:
26+
27+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
28+
* Trolling, insulting/derogatory comments, and personal or political attacks
29+
* Public or private harassment
30+
* Publishing others' private information, such as a physical or email address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a professional setting
32+
33+
## Enforcement Responsibilities
34+
35+
Project maintainers are responsible for clarifying and enforcing our standards of
36+
acceptable behavior and will take appropriate and fair corrective action in
37+
response to any behavior that they deem inappropriate, threatening, offensive,
38+
or harmful.
39+
40+
## Scope
41+
42+
This Code of Conduct applies within all community spaces, and also applies when
43+
an individual is representing the community in public spaces. Examples of
44+
representing a community include using an official project e-mail address,
45+
posting via an official social media account, or acting as an appointed
46+
representative at an online or offline event.
47+
48+
## Enforcement
49+
50+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
51+
reported to the project team. All complaints will be reviewed and investigated
52+
promptly and fairly.
53+
54+
All project team members are obligated to respect the privacy and security of the
55+
reporter of any incident.
56+
57+
## Attribution
58+
59+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
60+
version 2.1, available at
61+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,47 @@ The system consists of multiple AWS and Azure services interacting to form a rob
9292
5. Configure Azure OpenAI API for AI-driven processing.
9393
6. Monitor performance using AWS CloudWatch.
9494

95+
## Contract Management and Security
96+
97+
Marai ensures secure and efficient contract management through the following measures:
98+
99+
### Security Measures
100+
- **Role-Based Access Control (RBAC):**
101+
- Permissions are enforced based on user roles (e.g., owner, admin, member).
102+
- Only authorized users can create, update, delete, or view contracts.
103+
104+
- **Data Encryption:**
105+
- Contract files are encrypted using server-side encryption before being stored in the MinIO object storage.
106+
- SHA-256 hashing is used to ensure file integrity.
107+
108+
- **Audit Trails:**
109+
- All actions on contracts (e.g., signing, viewing) are logged as signature events.
110+
- These logs include metadata such as IP address, user agent, and timestamps.
111+
112+
- **Soft Deletion:**
113+
- Contracts are soft-deleted to prevent accidental data loss.
114+
- Deleted contracts are marked with a `is_deleted` flag and retain their metadata for auditing purposes.
115+
116+
- **Status Transitions:**
117+
- Contracts follow a strict lifecycle (e.g., draft → pending_signature → signed → void).
118+
- Invalid status transitions are rejected to maintain data integrity.
119+
120+
### Features
121+
- **File Uploads:**
122+
- Users can upload files to draft contracts.
123+
- Uploaded files are securely stored and accessible only to authorized users.
124+
125+
- **Party Management:**
126+
- Parties can be added or removed from draft contracts.
127+
- Each party has attributes like name, email, mobile, and role.
128+
129+
- **Digital Signatures:**
130+
- Parties can digitally sign contracts.
131+
- Once all parties have signed, the contract status is updated to `signed`.
132+
133+
- **Pagination and Filtering:**
134+
- Contracts can be listed with filters (e.g., status, isTemplate) and pagination for efficient retrieval.
135+
95136
## Future Improvements
96137
- Implement serverless functions (AWS Lambda) for improved scalability.
97138
- Enhance AI models for better legal text processing.

apps/server/.air.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pre_cmd = []
77
cmd = "make build"
88
post_cmd = ["make clean"]
99
delay = 0
10-
exclude_dir = ["public", "tmp", "vendor", "testdata"]
10+
exclude_dir = ["public", "tmp", "vendor", "testdata", "Bruno"]
1111
exclude_file = []
1212
exclude_regex = ["_test.go", "._templ.go", "._tmpl.go"]
1313
exclude_unchanged = false
@@ -41,4 +41,4 @@ clean_on_exit = true
4141

4242
[screen]
4343
clear_on_rebuild = false
44-
keep_scroll = true
44+
keep_scroll = true

apps/server/.env.example

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/marai"
1+
PORT = "8080"
2+
DEBUG = "true"
3+
ENV = "development"
4+
CLIENT_URL = "http://localhost:3000"
5+
DATABASE_URL = nil
6+
GORILLA_SESSIONS_MAXAGE = "604800"
7+
GORILLA_SESSIONS_KEY = "NotSoSecretKey-ChangeMe-Please"
8+
TWILIO_ACCOUNT_SID = nil
9+
TWILIO_AUTH_TOKEN = nil
10+
TWILIO_VERIFY_SERVICE_ID = nil
11+
MINIO_ACCESS_KEY = nil
12+
MINIO_ACCESS_SECRET = nil
13+
MINIO_SSL_POLICY = "false"
14+
MINIO_BUCKET_NAME = "codeflick"
15+
MINIO_ENDPOINT = "localhost:9000"
16+
ENCRYPTION_MASTER_KEY = "replace_with_generated_key"

apps/server/Bruno/Create Lawfirm.bru

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/server/Bruno/Get Lawfirm Detail.bru

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/server/Bruno/environments/Marai.bru

Lines changed: 0 additions & 4 deletions
This file was deleted.

apps/server/Bruno/signup req verify.bru

Lines changed: 0 additions & 18 deletions
This file was deleted.

apps/server/Dockerfile

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,29 @@
1-
# syntax=docker/dockerfile:1
1+
ARG GO_VERSION=1.24
2+
FROM golang:${GO_VERSION}-alpine AS build
23

3-
# Comments are provided throughout this file to help you get started.
4-
# If you need more help, visit the Dockerfile reference guide at
5-
# https://docs.docker.com/go/dockerfile-reference/
6-
7-
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
8-
9-
################################################################################
10-
# Create a stage for building the application.
11-
ARG GO_VERSION=1.23.6
12-
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build
134
WORKDIR /src
145

15-
# Download dependencies as a separate step to take advantage of Docker's caching.
16-
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds.
17-
# Leverage bind mounts to go.sum and go.mod to avoid having to copy them into
18-
# the container.
6+
COPY go.mod go.sum ./
197
RUN --mount=type=cache,target=/go/pkg/mod/ \
20-
--mount=type=bind,source=go.sum,target=go.sum \
21-
--mount=type=bind,source=go.mod,target=go.mod \
22-
go mod download -x
8+
go mod download || \
9+
go mod download
2310

24-
# This is the architecture you’re building for, which is passed in by the builder.
25-
# Placing it here allows the previous steps to be cached across architectures.
26-
ARG TARGETARCH
11+
COPY api/ ./api
12+
COPY cmd/ ./cmd
13+
COPY internal/ ./internal
14+
COPY go.mod .
15+
COPY go.sum .
2716

28-
# Build the application.
29-
# Leverage a cache mount to /go/pkg/mod/ to speed up subsequent builds.
30-
# Leverage a bind mount to the current directory to avoid having to copy the
31-
# source code into the container.
32-
RUN --mount=type=cache,target=/go/pkg/mod/ \
33-
--mount=type=bind,target=. \
17+
ARG TARGETARCH
18+
RUN --mount=type=cache,target=/root/.cache/go-build/ \
19+
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server cmd/main.go || \
3420
CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /bin/server cmd/main.go
3521

36-
FROM alpine:latest AS final
37-
38-
# Install any runtime dependencies that are needed to run your application.
39-
# Leverage a cache mount to /var/cache/apk/ to speed up subsequent builds.
40-
RUN --mount=type=cache,target=/var/cache/apk \
41-
apk --update add \
42-
ca-certificates \
43-
tzdata \
44-
curl \
45-
&& \
46-
update-ca-certificates
47-
48-
# Create a non-privileged user that the app will run under.
49-
# See https://docs.docker.com/go/dockerfile-user-best-practices/
50-
ARG UID=10001
51-
RUN adduser \
52-
--disabled-password \
53-
--gecos "" \
54-
--home "/nonexistent" \
55-
--shell "/sbin/nologin" \
56-
--no-create-home \
57-
--uid "${UID}" \
58-
appuser
59-
USER appuser
60-
61-
# copy the env file from .env
62-
COPY .env.local .env
63-
64-
# Copy the executable from the "build" stage.
65-
COPY --from=build /bin/server /bin/
22+
FROM alpine:latest
23+
WORKDIR /app
24+
COPY --from=build /bin/server /app/server
25+
COPY .env.local /app/.env
6626

67-
# Expose the port that the application listens on.
6827
EXPOSE 8080
6928

70-
# What the container should run when it is started.
71-
ENTRYPOINT [ "/bin/server" ]
29+
ENTRYPOINT ["/app/server"]

0 commit comments

Comments
 (0)